Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: rlz/lib/recursive_cross_process_lock_posix.cc

Issue 100253002: Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/local_input_monitor_linux.cc ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "rlz/lib/recursive_cross_process_lock_posix.h" 5 #include "rlz/lib/recursive_cross_process_lock_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/file.h> 9 #include <sys/file.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 while ((flock_result = 52 while ((flock_result =
53 HANDLE_EINTR(flock(file_lock_, LOCK_EX | LOCK_NB))) == -1 && 53 HANDLE_EINTR(flock(file_lock_, LOCK_EX | LOCK_NB))) == -1 &&
54 errno == EWOULDBLOCK && 54 errno == EWOULDBLOCK &&
55 elapsed_ms < kMaxTimeoutMS) { 55 elapsed_ms < kMaxTimeoutMS) {
56 usleep(kSleepPerTryMS * 1000); 56 usleep(kSleepPerTryMS * 1000);
57 elapsed_ms += kSleepPerTryMS; 57 elapsed_ms += kSleepPerTryMS;
58 } 58 }
59 59
60 if (flock_result == -1) { 60 if (flock_result == -1) {
61 perror("flock"); 61 perror("flock");
62 ignore_result(HANDLE_EINTR(close(file_lock_))); 62 close(file_lock_);
63 file_lock_ = -1; 63 file_lock_ = -1;
64 return false; 64 return false;
65 } 65 }
66 return true; 66 return true;
67 } else { 67 } else {
68 return file_lock_ != -1; 68 return file_lock_ != -1;
69 } 69 }
70 } 70 }
71 71
72 void RecursiveCrossProcessLock::ReleaseLock() { 72 void RecursiveCrossProcessLock::ReleaseLock() {
73 if (file_lock_ != -1) { 73 if (file_lock_ != -1) {
74 ignore_result(HANDLE_EINTR(flock(file_lock_, LOCK_UN))); 74 ignore_result(HANDLE_EINTR(flock(file_lock_, LOCK_UN)));
75 ignore_result(HANDLE_EINTR(close(file_lock_))); 75 close(file_lock_);
76 file_lock_ = -1; 76 file_lock_ = -1;
77 } 77 }
78 78
79 locking_thread_ = 0; 79 locking_thread_ = 0;
80 pthread_mutex_unlock(&recursive_lock_); 80 pthread_mutex_unlock(&recursive_lock_);
81 } 81 }
82 82
83 } // namespace rlz_lib 83 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « remoting/host/local_input_monitor_linux.cc ('k') | sandbox/linux/seccomp-bpf/sandbox_bpf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698