Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close.
It is incorrect to wrap close in HANDLE_EINTR on Linux. Correctness is
generally undefined on Mac, but as of r223369, it is incorrect in Chrome on
Mac.
To avoid new offenders, a PRESUBMIT check ensures that HANDLE_EINTR is not
used with close, and that IGNORE_EINTR is only used with close. Unnecessary
#includes of eintr_wrapper.h are also removed.
base/posix/einter_wrapper.h, PRESUBMIT.py, and ppapi/tests/test_broker.cc
contain non-mechanical changes. Variable naming within the latter is updated
per r178174. Missing #includes for <errno.h> in
content/zygote/zygote_main_linux.cc and tools/android/common/daemon.cc were
manually added. Mechanical changes were generated by running:
sed -E -i '' \
-e 's/((=|if|return|CHECK|EXPECT|ASSERT).*)HANDLE(_EINTR\(.*close)/\1IGNORE\3/' \
-e 's/(ignore_result|void ?)\(HANDLE_EINTR\((.*close\(.*)\)\)/\2/' \
-e 's/(\(void\) ?)?HANDLE_EINTR\((.*close\(.*)\)/\2/' \
$(git grep -El 'HANDLE_EINTR.*close')
sed -E -i '' -e '/#include.*eintr_wrapper\.h"/d' \
$(grep -EL '(HANDLE|IGNORE)_EINTR' \
$(git grep -El '#include.*eintr_wrapper\.h"'))
BUG=269623
R=agl@chromium.org, jln@chromium.org
TBR=OWNERS
Review URL: https://codereview.chromium.org/100253002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238390 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: d89eec809e2d25aee8d386186653699f5017b15b
diff --git a/base/files/dir_reader_linux.h b/base/files/dir_reader_linux.h
index 3e0721e..cb0cbd3 100644
--- a/base/files/dir_reader_linux.h
+++ b/base/files/dir_reader_linux.h
@@ -37,7 +37,7 @@
~DirReaderLinux() {
if (fd_ >= 0) {
- if (HANDLE_EINTR(close(fd_)))
+ if (IGNORE_EINTR(close(fd_)))
RAW_LOG(ERROR, "Failed to close directory handle");
}
}
diff --git a/base/files/file_path_watcher_kqueue.cc b/base/files/file_path_watcher_kqueue.cc
index 2ffb836..e035f22 100644
--- a/base/files/file_path_watcher_kqueue.cc
+++ b/base/files/file_path_watcher_kqueue.cc
@@ -210,7 +210,7 @@
return;
}
- if (HANDLE_EINTR(close(*fd)) != 0) {
+ if (IGNORE_EINTR(close(*fd)) != 0) {
DPLOG(ERROR) << "close";
}
*fd = kNoFileDescriptor;
@@ -497,7 +497,7 @@
if (!is_cancelled()) {
set_cancelled();
kqueue_watcher_.StopWatchingFileDescriptor();
- if (HANDLE_EINTR(close(kqueue_)) != 0) {
+ if (IGNORE_EINTR(close(kqueue_)) != 0) {
DPLOG(ERROR) << "close kqueue";
}
kqueue_ = -1;
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 2bd9cd0..028a382 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -221,7 +221,7 @@
bool ClosePlatformFile(PlatformFile file) {
base::ThreadRestrictions::AssertIOAllowed();
- return !HANDLE_EINTR(close(file));
+ return !IGNORE_EINTR(close(file));
}
int64 SeekPlatformFile(PlatformFile file,
diff --git a/base/files/memory_mapped_file_posix.cc b/base/files/memory_mapped_file_posix.cc
index ba00946..c4c477a 100644
--- a/base/files/memory_mapped_file_posix.cc
+++ b/base/files/memory_mapped_file_posix.cc
@@ -9,7 +9,6 @@
#include <unistd.h>
#include "base/logging.h"
-#include "base/posix/eintr_wrapper.h"
#include "base/threading/thread_restrictions.h"
namespace base {
@@ -44,7 +43,7 @@
if (data_ != NULL)
munmap(data_, length_);
if (file_ != kInvalidPlatformFileValue)
- ignore_result(HANDLE_EINTR(close(file_)));
+ close(file_);
data_ = NULL;
length_ = 0;