diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 14:10:59 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 14:10:59 +0000 |
commit | d89eec809e2d25aee8d386186653699f5017b15b (patch) | |
tree | b8b0433f5766958907ea4cebb7b954e82fc1148a | |
parent | 34b5946e889071a9c838a4b87d32437415148fed (diff) | |
download | chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.zip chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.tar.gz chromium_src-d89eec809e2d25aee8d386186653699f5017b15b.tar.bz2 |
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
83 files changed, 234 insertions, 189 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 414cee8..f0e77e9 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -202,6 +202,30 @@ _BANNED_CPP_FUNCTIONS = ( True, (), ), + ( + r'/HANDLE_EINTR\(.*close', + ( + 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file', + 'descriptor will be closed, and it is incorrect to retry the close.', + 'Either call close directly and ignore its return value, or wrap close', + 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623' + ), + True, + (), + ), + ( + r'/IGNORE_EINTR\((?!.*close)', + ( + 'IGNORE_EINTR is only valid when wrapping close. To wrap other system', + 'calls, use HANDLE_EINTR. See http://crbug.com/269623', + ), + True, + ( + # Files that #define IGNORE_EINTR. + r'^base[\\\/]posix[\\\/]eintr_wrapper\.h$', + r'^ppapi[\\\/]tests[\\\/]test_broker\.cc$', + ), + ), ) @@ -375,7 +399,14 @@ def _CheckNoBannedFunctions(input_api, output_api): return False if IsBlacklisted(f, excluded_paths): continue - if func_name in line: + matched = False + if func_name[0:1] == '/': + regex = func_name[1:] + if input_api.re.search(regex, line): + matched = True + elif func_name in line: + matched = True + if matched: problems = warnings; if error: problems = errors; diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc index cab4c48..60ad521 100644 --- a/base/debug/debugger_posix.cc +++ b/base/debug/debugger_posix.cc @@ -157,7 +157,7 @@ bool BeingDebugged() { char buf[1024]; ssize_t num_read = HANDLE_EINTR(read(status_fd, buf, sizeof(buf))); - if (HANDLE_EINTR(close(status_fd)) < 0) + if (IGNORE_EINTR(close(status_fd)) < 0) return false; if (num_read <= 0) diff --git a/base/file_util.h b/base/file_util.h index 35225c7..acced28 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -414,7 +414,7 @@ class ScopedFDClose { public: inline void operator()(int* x) const { if (x && *x >= 0) { - if (HANDLE_EINTR(close(*x)) < 0) + if (IGNORE_EINTR(close(*x)) < 0) DPLOG(ERROR) << "close"; } } diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index b6a4945..0557350 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -538,7 +538,7 @@ bool CreateTemporaryFile(FilePath* path) { int fd = CreateAndOpenFdForTemporaryFile(directory, path); if (fd < 0) return false; - ignore_result(HANDLE_EINTR(close(fd))); + close(fd); return true; } @@ -557,14 +557,14 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { FILE* file = fdopen(fd, "a+"); if (!file) - ignore_result(HANDLE_EINTR(close(fd))); + close(fd); return file; } bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) { base::ThreadRestrictions::AssertIOAllowed(); // For call to close(). int fd = CreateAndOpenFdForTemporaryFile(dir, temp_file); - return ((fd >= 0) && !HANDLE_EINTR(close(fd))); + return ((fd >= 0) && !IGNORE_EINTR(close(fd))); } static bool CreateTemporaryDirInDirImpl(const FilePath& base_dir, @@ -740,7 +740,7 @@ int ReadFile(const FilePath& filename, char* data, int size) { return -1; ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size)); - if (int ret = HANDLE_EINTR(close(fd)) < 0) + if (int ret = IGNORE_EINTR(close(fd)) < 0) return ret; return bytes_read; } @@ -752,7 +752,7 @@ int WriteFile(const FilePath& filename, const char* data, int size) { return -1; int bytes_written = WriteFileDescriptor(fd, data, size); - if (int ret = HANDLE_EINTR(close(fd)) < 0) + if (int ret = IGNORE_EINTR(close(fd)) < 0) return ret; return bytes_written; } @@ -779,7 +779,7 @@ int AppendToFile(const FilePath& filename, const char* data, int size) { return -1; int bytes_written = WriteFileDescriptor(fd, data, size); - if (int ret = HANDLE_EINTR(close(fd)) < 0) + if (int ret = IGNORE_EINTR(close(fd)) < 0) return ret; return bytes_written; } @@ -936,7 +936,7 @@ bool CopyFileUnsafe(const FilePath& from_path, const FilePath& to_path) { int outfile = HANDLE_EINTR(creat(to_path.value().c_str(), 0666)); if (outfile < 0) { - ignore_result(HANDLE_EINTR(close(infile))); + close(infile); return false; } @@ -967,9 +967,9 @@ bool CopyFileUnsafe(const FilePath& from_path, const FilePath& to_path) { } while (bytes_written_per_read < bytes_read); } - if (HANDLE_EINTR(close(infile)) < 0) + if (IGNORE_EINTR(close(infile)) < 0) result = false; - if (HANDLE_EINTR(close(outfile)) < 0) + if (IGNORE_EINTR(close(outfile)) < 0) result = false; return result; 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 @@ class DirReaderLinux { ~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 @@ void FilePathWatcherImpl::CloseFileDescriptor(uintptr_t* fd) { return; } - if (HANDLE_EINTR(close(*fd)) != 0) { + if (IGNORE_EINTR(close(*fd)) != 0) { DPLOG(ERROR) << "close"; } *fd = kNoFileDescriptor; @@ -497,7 +497,7 @@ void FilePathWatcherImpl::CancelOnMessageLoopThread() { 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 2bd9cd0b..028a382 100644 --- a/base/files/file_posix.cc +++ b/base/files/file_posix.cc @@ -221,7 +221,7 @@ FILE* FdopenPlatformFile(PlatformFile file, const char* mode) { 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 @@ void MemoryMappedFile::CloseHandles() { if (data_ != NULL) munmap(data_, length_); if (file_ != kInvalidPlatformFileValue) - ignore_result(HANDLE_EINTR(close(file_))); + close(file_); data_ = NULL; length_ = 0; diff --git a/base/memory/discardable_memory_android.cc b/base/memory/discardable_memory_android.cc index 3850439..8fee53e 100644 --- a/base/memory/discardable_memory_android.cc +++ b/base/memory/discardable_memory_android.cc @@ -12,7 +12,6 @@ #include "base/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" -#include "base/posix/eintr_wrapper.h" #include "base/synchronization/lock.h" #include "third_party/ashmem/ashmem.h" diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc index f378db2..e6d25ece 100644 --- a/base/message_loop/message_loop_unittest.cc +++ b/base/message_loop/message_loop_unittest.cc @@ -944,9 +944,9 @@ TEST(MessageLoopTest, FileDescriptorWatcherOutlivesMessageLoop) { // and don't run the message loop, just destroy it. } } - if (HANDLE_EINTR(close(pipefds[0])) < 0) + if (IGNORE_EINTR(close(pipefds[0])) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipefds[1])) < 0) + if (IGNORE_EINTR(close(pipefds[1])) < 0) PLOG(ERROR) << "close"; } @@ -969,9 +969,9 @@ TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) { controller.StopWatchingFileDescriptor(); } } - if (HANDLE_EINTR(close(pipefds[0])) < 0) + if (IGNORE_EINTR(close(pipefds[0])) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipefds[1])) < 0) + if (IGNORE_EINTR(close(pipefds[1])) < 0) PLOG(ERROR) << "close"; } diff --git a/base/message_loop/message_pump_io_ios_unittest.cc b/base/message_loop/message_pump_io_ios_unittest.cc index 9c7a8fb..f3b598c 100644 --- a/base/message_loop/message_pump_io_ios_unittest.cc +++ b/base/message_loop/message_pump_io_ios_unittest.cc @@ -31,9 +31,9 @@ class MessagePumpIOSForIOTest : public testing::Test { } virtual void TearDown() OVERRIDE { - if (HANDLE_EINTR(close(pipefds_[0])) < 0) + if (IGNORE_EINTR(close(pipefds_[0])) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipefds_[1])) < 0) + if (IGNORE_EINTR(close(pipefds_[1])) < 0) PLOG(ERROR) << "close"; } diff --git a/base/message_loop/message_pump_libevent.cc b/base/message_loop/message_pump_libevent.cc index 6d862d1..26be687 100644 --- a/base/message_loop/message_pump_libevent.cc +++ b/base/message_loop/message_pump_libevent.cc @@ -125,11 +125,11 @@ MessagePumpLibevent::~MessagePumpLibevent() { event_del(wakeup_event_); delete wakeup_event_; if (wakeup_pipe_in_ >= 0) { - if (HANDLE_EINTR(close(wakeup_pipe_in_)) < 0) + if (IGNORE_EINTR(close(wakeup_pipe_in_)) < 0) DPLOG(ERROR) << "close"; } if (wakeup_pipe_out_ >= 0) { - if (HANDLE_EINTR(close(wakeup_pipe_out_)) < 0) + if (IGNORE_EINTR(close(wakeup_pipe_out_)) < 0) DPLOG(ERROR) << "close"; } event_base_free(event_base_); diff --git a/base/message_loop/message_pump_libevent_unittest.cc b/base/message_loop/message_pump_libevent_unittest.cc index 52ca95b..bf6d21c 100644 --- a/base/message_loop/message_pump_libevent_unittest.cc +++ b/base/message_loop/message_pump_libevent_unittest.cc @@ -30,9 +30,9 @@ class MessagePumpLibeventTest : public testing::Test { } virtual void TearDown() OVERRIDE { - if (HANDLE_EINTR(close(pipefds_[0])) < 0) + if (IGNORE_EINTR(close(pipefds_[0])) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipefds_[1])) < 0) + if (IGNORE_EINTR(close(pipefds_[1])) < 0) PLOG(ERROR) << "close"; } diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc index 2bd9cd0b..028a382 100644 --- a/base/platform_file_posix.cc +++ b/base/platform_file_posix.cc @@ -221,7 +221,7 @@ FILE* FdopenPlatformFile(PlatformFile file, const char* mode) { 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/posix/eintr_wrapper.h b/base/posix/eintr_wrapper.h index 8e26752..854c43a 100644 --- a/base/posix/eintr_wrapper.h +++ b/base/posix/eintr_wrapper.h @@ -9,6 +9,9 @@ // caller will nonetheless see an EINTR in Debug builds. // // On Windows, this wrapper macro does nothing. +// +// Don't wrap close calls in HANDLE_EINTR. Use IGNORE_EINTR if the return +// value of close is significant. See http://crbug.com/269623. #ifndef BASE_POSIX_EINTR_WRAPPER_H_ #define BASE_POSIX_EINTR_WRAPPER_H_ @@ -20,6 +23,7 @@ #include <errno.h> #if defined(NDEBUG) + #define HANDLE_EINTR(x) ({ \ typeof(x) eintr_wrapper_result; \ do { \ @@ -42,9 +46,21 @@ #endif // NDEBUG +#define IGNORE_EINTR(x) ({ \ + typeof(x) eintr_wrapper_result; \ + do { \ + eintr_wrapper_result = (x); \ + if (eintr_wrapper_result == -1 && errno == EINTR) { \ + eintr_wrapper_result = 0; \ + } \ + } while (0); \ + eintr_wrapper_result; \ +}) + #else #define HANDLE_EINTR(x) (x) +#define IGNORE_EINTR(x) (x) #endif // OS_POSIX diff --git a/base/posix/file_descriptor_shuffle.cc b/base/posix/file_descriptor_shuffle.cc index b5b7339..7bc9e26 100644 --- a/base/posix/file_descriptor_shuffle.cc +++ b/base/posix/file_descriptor_shuffle.cc @@ -89,7 +89,7 @@ bool FileDescriptorTableInjection::Move(int src, int dest) { } void FileDescriptorTableInjection::Close(int fd) { - int ret = HANDLE_EINTR(close(fd)); + int ret = IGNORE_EINTR(close(fd)); DPCHECK(ret == 0); } diff --git a/base/posix/unix_domain_socket_linux_unittest.cc b/base/posix/unix_domain_socket_linux_unittest.cc index 1343555..22bb172 100644 --- a/base/posix/unix_domain_socket_linux_unittest.cc +++ b/base/posix/unix_domain_socket_linux_unittest.cc @@ -45,7 +45,7 @@ TEST(UnixDomainSocketTest, SendRecvMsgAbortOnReplyFDClose) { ASSERT_EQ(1U, message_fds.size()); // Close the reply FD. - ASSERT_EQ(0, HANDLE_EINTR(close(message_fds.front()))); + ASSERT_EQ(0, IGNORE_EINTR(close(message_fds.front()))); // Check that the thread didn't get blocked. WaitableEvent event(false, false); @@ -63,7 +63,7 @@ TEST(UnixDomainSocketTest, SendRecvMsgAvoidsSIGPIPE) { int fds[2]; ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds)); file_util::ScopedFD scoped_fd1(&fds[1]); - ASSERT_EQ(0, HANDLE_EINTR(close(fds[0]))); + ASSERT_EQ(0, IGNORE_EINTR(close(fds[0]))); // Have the thread send a synchronous message via the socket. Unless the // message is sent with MSG_NOSIGNAL, this shall result in SIGPIPE. diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc index de6286d..8dc8f9e 100644 --- a/base/process/launch_posix.cc +++ b/base/process/launch_posix.cc @@ -230,7 +230,7 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { // Since we're just trying to close anything we can find, // ignore any error return values of close(). - ignore_result(HANDLE_EINTR(close(fd))); + close(fd); } return; } @@ -264,7 +264,7 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { // these FDs are >= |max_fds|, so we can check against that here // before closing. See https://bugs.kde.org/show_bug.cgi?id=191758 if (fd < static_cast<int>(max_fds)) { - int ret = HANDLE_EINTR(close(fd)); + int ret = IGNORE_EINTR(close(fd)); DPCHECK(ret == 0); } } diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc index 2e533067..67d6618 100644 --- a/base/process/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc @@ -442,7 +442,7 @@ MULTIPROCESS_TEST_MAIN(ProcessUtilsLeakFDChildProcess) { int written = HANDLE_EINTR(write(write_pipe, &num_open_files, sizeof(num_open_files))); DCHECK_EQ(static_cast<size_t>(written), sizeof(num_open_files)); - int ret = HANDLE_EINTR(close(write_pipe)); + int ret = IGNORE_EINTR(close(write_pipe)); DPCHECK(ret == 0); return 0; @@ -458,7 +458,7 @@ int ProcessUtilTest::CountOpenFDsInChild() { base::ProcessHandle handle = this->SpawnChild( "ProcessUtilsLeakFDChildProcess", fd_mapping_vec, false); CHECK(handle); - int ret = HANDLE_EINTR(close(fds[1])); + int ret = IGNORE_EINTR(close(fds[1])); DPCHECK(ret == 0); // Read number of open files in client process from pipe; @@ -474,7 +474,7 @@ int ProcessUtilTest::CountOpenFDsInChild() { CHECK(base::WaitForSingleProcess(handle, base::TimeDelta::FromSeconds(1))); #endif base::CloseProcessHandle(handle); - ret = HANDLE_EINTR(close(fds[0])); + ret = IGNORE_EINTR(close(fds[0])); DPCHECK(ret == 0); return num_open_files; @@ -502,11 +502,11 @@ TEST_F(ProcessUtilTest, MAYBE_FDRemapping) { ASSERT_EQ(fds_after, fds_before); int ret; - ret = HANDLE_EINTR(close(sockets[0])); + ret = IGNORE_EINTR(close(sockets[0])); DPCHECK(ret == 0); - ret = HANDLE_EINTR(close(sockets[1])); + ret = IGNORE_EINTR(close(sockets[1])); DPCHECK(ret == 0); - ret = HANDLE_EINTR(close(dev_null)); + ret = IGNORE_EINTR(close(dev_null)); DPCHECK(ret == 0); } @@ -535,13 +535,13 @@ std::string TestLaunchProcess(const base::EnvironmentMap& env_changes, CHECK_EQ(0, clone_flags); #endif // OS_LINUX EXPECT_TRUE(base::LaunchProcess(args, options, NULL)); - PCHECK(HANDLE_EINTR(close(fds[1])) == 0); + PCHECK(IGNORE_EINTR(close(fds[1])) == 0); char buf[512]; const ssize_t n = HANDLE_EINTR(read(fds[0], buf, sizeof(buf))); PCHECK(n > 0); - PCHECK(HANDLE_EINTR(close(fds[0])) == 0); + PCHECK(IGNORE_EINTR(close(fds[0])) == 0); return std::string(buf, n); } diff --git a/base/test/multiprocess_test_android.cc b/base/test/multiprocess_test_android.cc index 9367426..51c2ce02 100644 --- a/base/test/multiprocess_test_android.cc +++ b/base/test/multiprocess_test_android.cc @@ -8,7 +8,6 @@ #include "base/containers/hash_tables.h" #include "base/logging.h" -#include "base/posix/eintr_wrapper.h" #include "testing/multiprocess_func_list.h" namespace base { @@ -42,7 +41,7 @@ ProcessHandle MultiProcessTest::SpawnChildImpl( const int kFdForAndroidLogging = 3; // FD used by __android_log_write(). for (int fd = kFdForAndroidLogging + 1; fd < getdtablesize(); ++fd) { if (fds_to_keep_open.find(fd) == fds_to_keep_open.end()) { - HANDLE_EINTR(close(fd)); + close(fd); } } for (FileHandleMappingVector::const_iterator it = fds_to_remap.begin(); @@ -52,7 +51,7 @@ ProcessHandle MultiProcessTest::SpawnChildImpl( if (dup2(old_fd, new_fd) < 0) { PLOG(FATAL) << "dup2"; } - HANDLE_EINTR(close(old_fd)); + close(old_fd); } _exit(multi_process_function_list::InvokeChildProcessTest(procname)); return 0; diff --git a/chrome/browser/extensions/api/serial/serial_connection_posix.cc b/chrome/browser/extensions/api/serial/serial_connection_posix.cc index ee07701..b1ad1dc 100644 --- a/chrome/browser/extensions/api/serial/serial_connection_posix.cc +++ b/chrome/browser/extensions/api/serial/serial_connection_posix.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/posix/eintr_wrapper.h" #include "chrome/browser/extensions/api/serial/serial_connection.h" #include <sys/ioctl.h> diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc index c30a883..e968048 100644 --- a/chrome/browser/process_info_snapshot_mac_unittest.cc +++ b/chrome/browser/process_info_snapshot_mac_unittest.cc @@ -116,7 +116,7 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { base::LaunchOptions options; options.fds_to_remap = &fds_to_remap; ASSERT_TRUE(base::LaunchProcess(argv, options, &process_handle)); - PCHECK(HANDLE_EINTR(close(fds[1])) == 0); + PCHECK(IGNORE_EINTR(close(fds[1])) == 0); // Wait until there's some output form top. This is an easy way to tell that // the exec() call is done and top is actually running. @@ -136,5 +136,5 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) { EXPECT_EQ(proc_info.uid, geteuid()); ASSERT_TRUE(base::KillProcess(process_handle, 0, true)); - PCHECK(HANDLE_EINTR(close(fds[0])) == 0); + PCHECK(IGNORE_EINTR(close(fds[0])) == 0); } diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc index cf84c5b..5887bf5 100644 --- a/chrome/browser/process_singleton_linux.cc +++ b/chrome/browser/process_singleton_linux.cc @@ -125,7 +125,7 @@ int SetCloseOnExec(int fd) { // Close a socket and check return value. void CloseSocket(int fd) { - int rv = HANDLE_EINTR(close(fd)); + int rv = IGNORE_EINTR(close(fd)); DCHECK_EQ(0, rv) << "Error closing socket: " << safe_strerror(errno); } diff --git a/chrome/browser/process_singleton_mac.cc b/chrome/browser/process_singleton_mac.cc index 8ff4cae..bf326ea 100644 --- a/chrome/browser/process_singleton_mac.cc +++ b/chrome/browser/process_singleton_mac.cc @@ -110,7 +110,7 @@ bool ProcessSingleton::Create() { void ProcessSingleton::Cleanup() { // Closing the file also releases the lock. if (lock_fd_ != -1) { - int rc = HANDLE_EINTR(close(lock_fd_)); + int rc = IGNORE_EINTR(close(lock_fd_)); DPCHECK(!rc) << "Closing lock_fd_:"; } lock_fd_ = -1; diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index a2186ba..61a0092 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -147,14 +147,14 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename, O_CREAT | O_EXCL | O_WRONLY, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); if (fd < 0) { - if (HANDLE_EINTR(close(desktop_fd)) < 0) + if (IGNORE_EINTR(close(desktop_fd)) < 0) PLOG(ERROR) << "close"; return false; } ssize_t bytes_written = file_util::WriteFileDescriptor(fd, contents.data(), contents.length()); - if (HANDLE_EINTR(close(fd)) < 0) + if (IGNORE_EINTR(close(fd)) < 0) PLOG(ERROR) << "close"; if (bytes_written != static_cast<ssize_t>(contents.length())) { @@ -165,7 +165,7 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename, unlinkat(desktop_fd, shortcut_filename.value().c_str(), 0); } - if (HANDLE_EINTR(close(desktop_fd)) < 0) + if (IGNORE_EINTR(close(desktop_fd)) < 0) PLOG(ERROR) << "close"; return true; diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc index c3494aa..07d6635 100644 --- a/chrome/common/multi_process_lock_linux.cc +++ b/chrome/common/multi_process_lock_linux.cc @@ -78,7 +78,7 @@ class MultiProcessLockLinux : public MultiProcessLock { DVLOG(1) << "Couldn't bind socket - " << &(address.sun_path[1]) << " Length: " << length; - if (HANDLE_EINTR(close(socket_fd)) < 0) { + if (IGNORE_EINTR(close(socket_fd)) < 0) { PLOG(ERROR) << "close"; } return false; @@ -90,7 +90,7 @@ class MultiProcessLockLinux : public MultiProcessLock { DLOG(ERROR) << "Over-unlocked MultiProcessLock - " << name_; return; } - if (HANDLE_EINTR(close(fd_)) < 0) { + if (IGNORE_EINTR(close(fd_)) < 0) { DPLOG(ERROR) << "close"; } fd_ = -1; diff --git a/chrome/common/service_process_util_posix.cc b/chrome/common/service_process_util_posix.cc index df57c91..92b79b5 100644 --- a/chrome/common/service_process_util_posix.cc +++ b/chrome/common/service_process_util_posix.cc @@ -133,12 +133,12 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ServiceProcessState::StateData::~StateData() { if (sockets_[0] != -1) { - if (HANDLE_EINTR(close(sockets_[0]))) { + if (IGNORE_EINTR(close(sockets_[0]))) { DPLOG(ERROR) << "close"; } } if (sockets_[1] != -1) { - if (HANDLE_EINTR(close(sockets_[1]))) { + if (IGNORE_EINTR(close(sockets_[1]))) { DPLOG(ERROR) << "close"; } } diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc index 8c11a97..9d06e5f 100644 --- a/chromeos/dbus/debug_daemon_client.cc +++ b/chromeos/dbus/debug_daemon_client.cc @@ -56,7 +56,7 @@ class PipeReader { virtual ~PipeReader() { // Don't close pipe_fd_[0] as it's closed by data_stream_. if (pipe_fd_[1] != -1) - if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) + if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) PLOG(ERROR) << "close[1]"; } @@ -66,7 +66,7 @@ class PipeReader { // Closes writeable descriptor; normally used in parent process after fork. void CloseWriteFD() { if (pipe_fd_[1] != -1) { - if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) + if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) PLOG(ERROR) << "close"; pipe_fd_[1] = -1; } diff --git a/chromeos/process_proxy/process_output_watcher.cc b/chromeos/process_proxy/process_output_watcher.cc index 40ed8cf..f063984 100644 --- a/chromeos/process_proxy/process_output_watcher.cc +++ b/chromeos/process_proxy/process_output_watcher.cc @@ -26,7 +26,7 @@ void InitReadFdSet(int out_fd, int stop_fd, fd_set* set) { void CloseFd(int* fd) { if (*fd >= 0) { - if (HANDLE_EINTR(close(*fd)) != 0) + if (IGNORE_EINTR(close(*fd)) != 0) DPLOG(WARNING) << "close fd " << *fd << " failed."; } *fd = -1; diff --git a/chromeos/process_proxy/process_output_watcher_unittest.cc b/chromeos/process_proxy/process_output_watcher_unittest.cc index 9ff8d89..b45d137 100644 --- a/chromeos/process_proxy/process_output_watcher_unittest.cc +++ b/chromeos/process_proxy/process_output_watcher_unittest.cc @@ -127,8 +127,8 @@ public: // Send stop signal. It is not important which string we send. EXPECT_EQ(1, file_util::WriteFileDescriptor(stop_pipe[1], "q", 1)); - EXPECT_NE(-1, HANDLE_EINTR(close(stop_pipe[1]))); - EXPECT_NE(-1, HANDLE_EINTR(close(pt_pipe[1]))); + EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); + EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); output_watch_thread.Stop(); } diff --git a/chromeos/process_proxy/process_proxy.cc b/chromeos/process_proxy/process_proxy.cc index b61ec9f..3ae1d21 100644 --- a/chromeos/process_proxy/process_proxy.cc +++ b/chromeos/process_proxy/process_proxy.cc @@ -244,7 +244,7 @@ void ProcessProxy::CloseFdPair(int* pipe) { void ProcessProxy::CloseFd(int* fd) { if (*fd != kInvalidFd) { - if (HANDLE_EINTR(close(*fd)) != 0) + if (IGNORE_EINTR(close(*fd)) != 0) DPLOG(WARNING) << "close fd failed."; } *fd = kInvalidFd; diff --git a/chromeos/process_proxy/process_proxy_unittest.cc b/chromeos/process_proxy/process_proxy_unittest.cc index 429c868..badb7dc 100644 --- a/chromeos/process_proxy/process_proxy_unittest.cc +++ b/chromeos/process_proxy/process_proxy_unittest.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/posix/eintr_wrapper.h" #include "base/process/kill.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" diff --git a/components/breakpad/browser/crash_handler_host_linux.cc b/components/breakpad/browser/crash_handler_host_linux.cc index b8794d2..cefcd19 100644 --- a/components/breakpad/browser/crash_handler_host_linux.cc +++ b/components/breakpad/browser/crash_handler_host_linux.cc @@ -108,8 +108,8 @@ CrashHandlerHostLinux::CrashHandlerHostLinux(const std::string& process_type, } CrashHandlerHostLinux::~CrashHandlerHostLinux() { - (void) HANDLE_EINTR(close(process_socket_)); - (void) HANDLE_EINTR(close(browser_socket_)); + close(process_socket_); + close(browser_socket_); } void CrashHandlerHostLinux::StartUploaderThread() { @@ -236,7 +236,7 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { LOG(ERROR) << "Death signal contained wrong number of descriptors;" << " num_fds:" << num_fds; for (unsigned i = 0; i < num_fds; ++i) - (void) HANDLE_EINTR(close(reinterpret_cast<int*>(CMSG_DATA(hdr))[i])); + close(reinterpret_cast<int*>(CMSG_DATA(hdr))[i]); return; } else { partner_fd = reinterpret_cast<int*>(CMSG_DATA(hdr))[0]; @@ -253,9 +253,9 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { LOG(ERROR) << "Death signal message didn't contain all expected control" << " messages"; if (partner_fd >= 0) - (void) HANDLE_EINTR(close(partner_fd)); + close(partner_fd); if (signal_fd >= 0) - (void) HANDLE_EINTR(close(signal_fd)); + close(signal_fd); return; } @@ -273,17 +273,17 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { ino_t inode_number; if (!base::FileDescriptorGetInode(&inode_number, partner_fd)) { LOG(WARNING) << "Failed to get inode number for passed socket"; - (void) HANDLE_EINTR(close(partner_fd)); - (void) HANDLE_EINTR(close(signal_fd)); + close(partner_fd); + close(signal_fd); return; } - (void) HANDLE_EINTR(close(partner_fd)); + close(partner_fd); pid_t actual_crashing_pid = -1; if (!base::FindProcessHoldingSocket(&actual_crashing_pid, inode_number)) { LOG(WARNING) << "Failed to find process holding other end of crash reply " "socket"; - (void) HANDLE_EINTR(close(signal_fd)); + close(signal_fd); return; } @@ -442,7 +442,7 @@ void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, msg.msg_iovlen = 1; (void) HANDLE_EINTR(sendmsg(signal_fd, &msg, MSG_DONTWAIT | MSG_NOSIGNAL)); - (void) HANDLE_EINTR(close(signal_fd)); + close(signal_fd); uploader_thread_->message_loop()->PostTask( FROM_HERE, diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index aa79f4f..e44df89 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -686,7 +686,7 @@ net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { } if (listen(s, 1)) { LOG(ERROR) << "listen() failed on debug stub socket"; - if (HANDLE_EINTR(close(s)) < 0) + if (IGNORE_EINTR(close(s)) < 0) PLOG(ERROR) << "failed to close debug stub socket"; return net::kInvalidSocket; } diff --git a/components/nacl/loader/nacl_helper_linux.cc b/components/nacl/loader/nacl_helper_linux.cc index 55b6c06..37e0dd5 100644 --- a/components/nacl/loader/nacl_helper_linux.cc +++ b/components/nacl/loader/nacl_helper_linux.cc @@ -50,7 +50,7 @@ void BecomeNaClLoader(const std::vector<int>& child_fds, const NaClLoaderSystemInfo& system_info) { VLOG(1) << "NaCl loader: setting up IPC descriptor"; // don't need zygote FD any more - if (HANDLE_EINTR(close(kNaClZygoteDescriptor)) != 0) + if (IGNORE_EINTR(close(kNaClZygoteDescriptor)) != 0) LOG(ERROR) << "close(kNaClZygoteDescriptor) failed."; bool sandbox_initialized = InitializeBpfSandbox(); if (!sandbox_initialized) { @@ -98,9 +98,9 @@ void ChildNaClLoaderInit(const std::vector<int>& child_fds, validack = true; } } - if (HANDLE_EINTR(close(dummy_fd)) != 0) + if (IGNORE_EINTR(close(dummy_fd)) != 0) LOG(ERROR) << "close(dummy_fd) failed"; - if (HANDLE_EINTR(close(parent_fd)) != 0) + if (IGNORE_EINTR(close(parent_fd)) != 0) LOG(ERROR) << "close(parent_fd) failed"; if (validack) { BecomeNaClLoader(child_fds, system_info); @@ -137,7 +137,7 @@ bool HandleForkRequest(const std::vector<int>& child_fds, // First, close the dummy_fd so the sandbox won't find me when // looking for the child's pid in /proc. Also close other fds. for (size_t i = 0; i < child_fds.size(); i++) { - if (HANDLE_EINTR(close(child_fds[i])) != 0) + if (IGNORE_EINTR(close(child_fds[i])) != 0) LOG(ERROR) << "close(child_fds[i]) failed"; } VLOG(1) << "nacl_helper: child_pid is " << child_pid; @@ -180,7 +180,7 @@ bool HandleGetTerminationStatusRequest(PickleIterator* input_iter, bool IsSandboxed() { int proc_fd = open("/proc/self/exe", O_RDONLY); if (proc_fd >= 0) { - HANDLE_EINTR(close(proc_fd)); + close(proc_fd); return false; } return true; diff --git a/components/nacl/zygote/nacl_fork_delegate_linux.cc b/components/nacl/zygote/nacl_fork_delegate_linux.cc index 9f6f7b4..1546bdd 100644 --- a/components/nacl/zygote/nacl_fork_delegate_linux.cc +++ b/components/nacl/zygote/nacl_fork_delegate_linux.cc @@ -206,7 +206,7 @@ void NaClForkDelegate::Init(const int sandboxdesc) { status_ = kNaClHelperLaunchFailed; // parent and error cases are handled below } - if (HANDLE_EINTR(close(fds[1])) != 0) + if (IGNORE_EINTR(close(fds[1])) != 0) LOG(ERROR) << "close(fds[1]) failed"; if (status_ == kNaClHelperUnused) { const ssize_t kExpectedLength = strlen(kNaClHelperStartupAck); @@ -228,7 +228,7 @@ void NaClForkDelegate::Init(const int sandboxdesc) { // TODO(bradchen): Make this LOG(ERROR) when the NaCl helper // becomes the default. fd_ = -1; - if (HANDLE_EINTR(close(fds[0])) != 0) + if (IGNORE_EINTR(close(fds[0])) != 0) LOG(ERROR) << "close(fds[0]) failed"; } @@ -243,7 +243,7 @@ void NaClForkDelegate::InitialUMA(std::string* uma_name, NaClForkDelegate::~NaClForkDelegate() { // side effect of close: delegate process will terminate if (status_ == kNaClHelperSuccess) { - if (HANDLE_EINTR(close(fd_)) != 0) + if (IGNORE_EINTR(close(fd_)) != 0) LOG(ERROR) << "close(fd_) failed"; } } diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc index b35ac73..a018043 100644 --- a/content/browser/renderer_host/render_sandbox_host_linux.cc +++ b/content/browser/renderer_host/render_sandbox_host_linux.cc @@ -241,7 +241,7 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, result_fd); if (result_fd >= 0) { - int err = HANDLE_EINTR(close(result_fd)); + int err = IGNORE_EINTR(close(result_fd)); DCHECK(!err); } } @@ -516,7 +516,7 @@ class SandboxIPCProcess { SendRendererReply(fds, reply, font_fd); if (font_fd >= 0) { - if (HANDLE_EINTR(close(font_fd)) < 0) + if (IGNORE_EINTR(close(font_fd)) < 0) PLOG(ERROR) << "close"; } } @@ -718,9 +718,9 @@ void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { #endif pid_ = fork(); if (pid_ == 0) { - if (HANDLE_EINTR(close(fds[0])) < 0) + if (IGNORE_EINTR(close(fds[0])) < 0) DPLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipefds[1])) < 0) + if (IGNORE_EINTR(close(pipefds[1])) < 0) DPLOG(ERROR) << "close"; SandboxIPCProcess handler(child_lifeline_fd, browser_socket, sandbox_path); @@ -731,9 +731,9 @@ void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { RenderSandboxHostLinux::~RenderSandboxHostLinux() { if (initialized_) { - if (HANDLE_EINTR(close(renderer_socket_)) < 0) + if (IGNORE_EINTR(close(renderer_socket_)) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) + if (IGNORE_EINTR(close(childs_lifeline_fd_)) < 0) PLOG(ERROR) << "close"; } } diff --git a/content/browser/renderer_host/render_widget_helper.cc b/content/browser/renderer_host/render_widget_helper.cc index 7f772e3..10e4e0f 100644 --- a/content/browser/renderer_host/render_widget_helper.cc +++ b/content/browser/renderer_host/render_widget_helper.cc @@ -381,7 +381,7 @@ void RenderWidgetHelper::FreeTransportDIB(TransportDIB::Id dib_id) { i = allocated_dibs_.find(dib_id); if (i != allocated_dibs_.end()) { - if (HANDLE_EINTR(close(i->second)) < 0) + if (IGNORE_EINTR(close(i->second)) < 0) PLOG(ERROR) << "close"; allocated_dibs_.erase(i); } else { @@ -392,7 +392,7 @@ void RenderWidgetHelper::FreeTransportDIB(TransportDIB::Id dib_id) { void RenderWidgetHelper::ClearAllocatedDIBs() { for (std::map<TransportDIB::Id, int>::iterator i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { - if (HANDLE_EINTR(close(i->second)) < 0) + if (IGNORE_EINTR(close(i->second)) < 0) PLOG(ERROR) << "close: " << i->first; } diff --git a/content/common/font_config_ipc_linux.cc b/content/common/font_config_ipc_linux.cc index b61a8cc..2d976c4 100644 --- a/content/common/font_config_ipc_linux.cc +++ b/content/common/font_config_ipc_linux.cc @@ -33,7 +33,7 @@ SkStream* StreamFromFD(int fd) { } void CloseFD(int fd) { - int err = HANDLE_EINTR(close(fd)); + int err = IGNORE_EINTR(close(fd)); DCHECK(!err); } diff --git a/content/common/gpu/media/exynos_video_decode_accelerator.cc b/content/common/gpu/media/exynos_video_decode_accelerator.cc index 26fe624..cfa3443 100644 --- a/content/common/gpu/media/exynos_video_decode_accelerator.cc +++ b/content/common/gpu/media/exynos_video_decode_accelerator.cc @@ -221,13 +221,13 @@ ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { DCHECK(!device_poll_thread_.IsRunning()); if (device_poll_interrupt_fd_ != -1) { - HANDLE_EINTR(close(device_poll_interrupt_fd_)); + close(device_poll_interrupt_fd_); device_poll_interrupt_fd_ = -1; } if (mfc_fd_ != -1) { DestroyMfcInputBuffers(); DestroyMfcOutputBuffers(); - HANDLE_EINTR(close(mfc_fd_)); + close(mfc_fd_); mfc_fd_ = -1; } @@ -1906,7 +1906,7 @@ void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { MfcOutputRecord& output_record = mfc_output_buffer_map_[i]; for (size_t j = 0; j < arraysize(output_record.fds); ++j) { if (output_record.fds[j] != -1) - HANDLE_EINTR(close(output_record.fds[j])); + close(output_record.fds[j]); if (output_record.egl_image != EGL_NO_IMAGE_KHR) eglDestroyImageKHR(egl_display_, output_record.egl_image); if (output_record.egl_sync != EGL_NO_SYNC_KHR) diff --git a/content/common/gpu/media/exynos_video_encode_accelerator.cc b/content/common/gpu/media/exynos_video_encode_accelerator.cc index 4c8e8e5..e8a2196 100644 --- a/content/common/gpu/media/exynos_video_encode_accelerator.cc +++ b/content/common/gpu/media/exynos_video_encode_accelerator.cc @@ -115,19 +115,19 @@ ExynosVideoEncodeAccelerator::~ExynosVideoEncodeAccelerator() { DCHECK(!device_poll_thread_.IsRunning()); if (device_poll_interrupt_fd_ != -1) { - HANDLE_EINTR(close(device_poll_interrupt_fd_)); + close(device_poll_interrupt_fd_); device_poll_interrupt_fd_ = -1; } if (gsc_fd_ != -1) { DestroyGscInputBuffers(); DestroyGscOutputBuffers(); - HANDLE_EINTR(close(gsc_fd_)); + close(gsc_fd_); gsc_fd_ = -1; } if (mfc_fd_ != -1) { DestroyMfcInputBuffers(); DestroyMfcOutputBuffers(); - HANDLE_EINTR(close(mfc_fd_)); + close(mfc_fd_); mfc_fd_ = -1; } } @@ -1512,7 +1512,7 @@ void ExynosVideoEncodeAccelerator::DestroyMfcInputBuffers() { MfcInputRecord& input_record = mfc_input_buffer_map_[buf]; for (size_t plane = 0; plane < arraysize(input_record.fd); ++plane) - HANDLE_EINTR(close(mfc_input_buffer_map_[buf].fd[plane])); + close(mfc_input_buffer_map_[buf].fd[plane]); } struct v4l2_requestbuffers reqbufs; diff --git a/content/common/plugin_list_posix.cc b/content/common/plugin_list_posix.cc index a5d7fac..abc74ba 100644 --- a/content/common/plugin_list_posix.cc +++ b/content/common/plugin_list_posix.cc @@ -173,7 +173,7 @@ bool ELFMatchesCurrentArchitecture(const base::FilePath& filename) { if (fd < 0) return false; bool ret = (fstat(fd, &stat_buf) >= 0 && S_ISREG(stat_buf.st_mode)); - if (HANDLE_EINTR(close(fd)) < 0) + if (IGNORE_EINTR(close(fd)) < 0) return false; if (!ret) return false; diff --git a/content/common/sandbox_linux.cc b/content/common/sandbox_linux.cc index b9cfe0e..85a3e36 100644 --- a/content/common/sandbox_linux.cc +++ b/content/common/sandbox_linux.cc @@ -289,7 +289,7 @@ bool LinuxSandbox::HasOpenDirectories() { void LinuxSandbox::SealSandbox() { if (proc_fd_ >= 0) { - int ret = HANDLE_EINTR(close(proc_fd_)); + int ret = IGNORE_EINTR(close(proc_fd_)); CHECK_EQ(0, ret); proc_fd_ = -1; } diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc index fe618c7..089c4ed 100644 --- a/content/plugin/plugin_channel.cc +++ b/content/plugin/plugin_channel.cc @@ -23,7 +23,6 @@ #include "third_party/WebKit/public/web/WebBindings.h" #if defined(OS_POSIX) -#include "base/posix/eintr_wrapper.h" #include "ipc/ipc_channel_posix.h" #endif diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc index 93ab269..1d32ab0 100644 --- a/content/zygote/zygote_main_linux.cc +++ b/content/zygote/zygote_main_linux.cc @@ -5,6 +5,7 @@ #include "content/zygote/zygote_main.h" #include <dlfcn.h> +#include <errno.h> #include <fcntl.h> #include <pthread.h> #include <stdio.h> @@ -21,7 +22,6 @@ #include "base/linux_util.h" #include "base/native_library.h" #include "base/pickle.h" -#include "base/posix/eintr_wrapper.h" #include "base/posix/unix_domain_socket_linux.h" #include "base/rand_util.h" #include "base/sys_info.h" @@ -311,7 +311,7 @@ static void PreSandboxInit() { } static void CloseFdAndHandleEintr(int fd) { - (void) HANDLE_EINTR(close(fd)); + close(fd); } // This will set the *using_suid_sandbox variable to true if the SUID sandbox diff --git a/device/bluetooth/bluetooth_socket_chromeos.cc b/device/bluetooth/bluetooth_socket_chromeos.cc index 81395dc..3a881d1 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.cc +++ b/device/bluetooth/bluetooth_socket_chromeos.cc @@ -44,7 +44,7 @@ BluetoothSocketChromeOS::BluetoothSocketChromeOS(int fd) } BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { - HANDLE_EINTR(close(fd_)); + close(fd_); } bool BluetoothSocketChromeOS::Receive(net::GrowableIOBuffer *buffer) { diff --git a/ipc/file_descriptor_set_posix.cc b/ipc/file_descriptor_set_posix.cc index fc15c2d..1aa86a7 100644 --- a/ipc/file_descriptor_set_posix.cc +++ b/ipc/file_descriptor_set_posix.cc @@ -31,7 +31,7 @@ FileDescriptorSet::~FileDescriptorSet() { for (unsigned i = consumed_descriptor_highwater_; i < descriptors_.size(); ++i) { if (descriptors_[i].auto_close) - if (HANDLE_EINTR(close(descriptors_[i].fd)) < 0) + if (IGNORE_EINTR(close(descriptors_[i].fd)) < 0) PLOG(ERROR) << "close"; } } @@ -119,7 +119,7 @@ void FileDescriptorSet::CommitAll() { for (std::vector<base::FileDescriptor>::iterator i = descriptors_.begin(); i != descriptors_.end(); ++i) { if (i->auto_close) - if (HANDLE_EINTR(close(i->fd)) < 0) + if (IGNORE_EINTR(close(i->fd)) < 0) PLOG(ERROR) << "close"; } descriptors_.clear(); diff --git a/ipc/file_descriptor_set_posix_unittest.cc b/ipc/file_descriptor_set_posix_unittest.cc index b4a0141..d9107f9 100644 --- a/ipc/file_descriptor_set_posix_unittest.cc +++ b/ipc/file_descriptor_set_posix_unittest.cc @@ -24,8 +24,8 @@ int GetSafeFd() { bool VerifyClosed(int fd) { const int duped = dup(fd); if (duped != -1) { - EXPECT_NE(HANDLE_EINTR(close(duped)), -1); - EXPECT_NE(HANDLE_EINTR(close(fd)), -1); + EXPECT_NE(IGNORE_EINTR(close(duped)), -1); + EXPECT_NE(IGNORE_EINTR(close(fd)), -1); return false; } return true; diff --git a/ipc/ipc_channel_factory.cc b/ipc/ipc_channel_factory.cc index f3ad11a..5c24284 100644 --- a/ipc/ipc_channel_factory.cc +++ b/ipc/ipc_channel_factory.cc @@ -76,7 +76,7 @@ void ChannelFactory::OnFileCanWriteWithoutBlocking(int fd) { void ChannelFactory::Close() { if (listen_fd_ < 0) return; - if (HANDLE_EINTR(close(listen_fd_)) < 0) + if (IGNORE_EINTR(close(listen_fd_)) < 0) PLOG(ERROR) << "close"; listen_fd_ = -1; if (unlink(path_.value().c_str()) < 0) diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index a74178a..8788532 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -206,9 +206,9 @@ bool SocketPair(int* fd1, int* fd2) { if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 || fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { PLOG(ERROR) << "fcntl(O_NONBLOCK)"; - if (HANDLE_EINTR(close(pipe_fds[0])) < 0) + if (IGNORE_EINTR(close(pipe_fds[0])) < 0) PLOG(ERROR) << "close"; - if (HANDLE_EINTR(close(pipe_fds[1])) < 0) + if (IGNORE_EINTR(close(pipe_fds[1])) < 0) PLOG(ERROR) << "close"; return false; } @@ -547,7 +547,7 @@ void Channel::ChannelImpl::CloseClientFileDescriptor() { base::AutoLock lock(client_pipe_lock_); if (client_pipe_ != -1) { PipeMap::GetInstance()->Remove(pipe_name_); - if (HANDLE_EINTR(close(client_pipe_)) < 0) + if (IGNORE_EINTR(close(client_pipe_)) < 0) PLOG(ERROR) << "close " << pipe_name_; client_pipe_ = -1; } @@ -571,18 +571,18 @@ void Channel::ChannelImpl::ResetToAcceptingConnectionState() { read_watcher_.StopWatchingFileDescriptor(); write_watcher_.StopWatchingFileDescriptor(); if (pipe_ != -1) { - if (HANDLE_EINTR(close(pipe_)) < 0) + if (IGNORE_EINTR(close(pipe_)) < 0) PLOG(ERROR) << "close pipe_ " << pipe_name_; pipe_ = -1; } #if defined(IPC_USES_READWRITE) if (fd_pipe_ != -1) { - if (HANDLE_EINTR(close(fd_pipe_)) < 0) + if (IGNORE_EINTR(close(fd_pipe_)) < 0) PLOG(ERROR) << "close fd_pipe_ " << pipe_name_; fd_pipe_ = -1; } if (remote_fd_pipe_ != -1) { - if (HANDLE_EINTR(close(remote_fd_pipe_)) < 0) + if (IGNORE_EINTR(close(remote_fd_pipe_)) < 0) PLOG(ERROR) << "close remote_fd_pipe_ " << pipe_name_; remote_fd_pipe_ = -1; } @@ -602,7 +602,7 @@ void Channel::ChannelImpl::ResetToAcceptingConnectionState() { for (std::set<int>::iterator i = fds_to_close_.begin(); i != fds_to_close_.end(); ++i) { - if (HANDLE_EINTR(close(*i)) < 0) + if (IGNORE_EINTR(close(*i)) < 0) PLOG(ERROR) << "close"; } fds_to_close_.clear(); @@ -637,7 +637,7 @@ void Channel::ChannelImpl::OnFileCanReadWithoutBlocking(int fd) { // close our new descriptor. if (HANDLE_EINTR(shutdown(new_pipe, SHUT_RDWR)) < 0) DPLOG(ERROR) << "shutdown " << pipe_name_; - if (HANDLE_EINTR(close(new_pipe)) < 0) + if (IGNORE_EINTR(close(new_pipe)) < 0) DPLOG(ERROR) << "close " << pipe_name_; listener()->OnChannelDenied(); return; @@ -927,7 +927,7 @@ bool Channel::ChannelImpl::ExtractFileDescriptorsFromMsghdr(msghdr* msg) { void Channel::ChannelImpl::ClearInputFDs() { for (size_t i = 0; i < input_fds_.size(); ++i) { - if (HANDLE_EINTR(close(input_fds_[i])) < 0) + if (IGNORE_EINTR(close(input_fds_[i])) < 0) PLOG(ERROR) << "close "; } input_fds_.clear(); @@ -996,7 +996,7 @@ void Channel::ChannelImpl::HandleInternalMessage(const Message& msg) { NOTREACHED(); if (hops == 0) { if (fds_to_close_.erase(fd) > 0) { - if (HANDLE_EINTR(close(fd)) < 0) + if (IGNORE_EINTR(close(fd)) < 0) PLOG(ERROR) << "close"; } else { NOTREACHED(); @@ -1020,7 +1020,7 @@ void Channel::ChannelImpl::Close() { must_unlink_ = false; } if (server_listen_pipe_ != -1) { - if (HANDLE_EINTR(close(server_listen_pipe_)) < 0) + if (IGNORE_EINTR(close(server_listen_pipe_)) < 0) DPLOG(ERROR) << "close " << server_listen_pipe_; server_listen_pipe_ = -1; // Unregister libevent for the listening socket and close it. diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc index 66ddeb2..eca78f1 100644 --- a/ipc/ipc_channel_posix_unittest.cc +++ b/ipc/ipc_channel_posix_unittest.cc @@ -219,7 +219,7 @@ TEST_F(IPCChannelPosixTest, BasicConnected) { ASSERT_TRUE(channel.Connect()); ASSERT_FALSE(channel.AcceptsConnections()); channel.Close(); - ASSERT_TRUE(HANDLE_EINTR(close(pipe_fds[1])) == 0); + ASSERT_TRUE(IGNORE_EINTR(close(pipe_fds[1])) == 0); // Make sure that we can use the socket that is created for us by // a standard channel. diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc index 20c3ed5..aeec890 100644 --- a/ipc/ipc_send_fds_test.cc +++ b/ipc/ipc_send_fds_test.cc @@ -153,7 +153,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsClient) { struct stat st; int fd = open(kDevZeroPath, O_RDONLY); fstat(fd, &st); - EXPECT_GE(HANDLE_EINTR(close(fd)), 0); + EXPECT_GE(IGNORE_EINTR(close(fd)), 0); return SendFdsClientCommon("SendFdsClient", st.st_ino); } @@ -169,7 +169,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) { struct stat st; const int fd = open(kDevZeroPath, O_RDONLY); fstat(fd, &st); - if (HANDLE_EINTR(close(fd)) < 0) + if (IGNORE_EINTR(close(fd)) < 0) return -1; // Enable the sandbox. @@ -321,7 +321,7 @@ class IPCMultiSendingFdsTest : public testing::Test { pipe_fds.second)); char tmp = 'x'; CHECK_EQ(1, HANDLE_EINTR(write(pipe_fds.first, &tmp, 1))); - CHECK_EQ(0, HANDLE_EINTR(close(pipe_fds.first))); + CHECK_EQ(0, IGNORE_EINTR(close(pipe_fds.first))); received_.Wait(); } } @@ -330,7 +330,7 @@ class IPCMultiSendingFdsTest : public testing::Test { char tmp = 'y'; CHECK_EQ(1, HANDLE_EINTR(read(fd, &tmp, 1))); CHECK_EQ(tmp, 'x'); - CHECK_EQ(0, HANDLE_EINTR(close(fd))); + CHECK_EQ(0, IGNORE_EINTR(close(fd))); received_.Signal(); } diff --git a/media/base/user_input_monitor_linux.cc b/media/base/user_input_monitor_linux.cc index 361fd01..70090ea 100644 --- a/media/base/user_input_monitor_linux.cc +++ b/media/base/user_input_monitor_linux.cc @@ -18,7 +18,6 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_pump_libevent.h" -#include "base/posix/eintr_wrapper.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/lock.h" #include "media/base/keyboard_event_counter.h" diff --git a/net/base/address_tracker_linux.cc b/net/base/address_tracker_linux.cc index 886811a..f863ccd 100644 --- a/net/base/address_tracker_linux.cc +++ b/net/base/address_tracker_linux.cc @@ -306,7 +306,7 @@ void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { void AddressTrackerLinux::OnFileCanWriteWithoutBlocking(int /* fd */) {} void AddressTrackerLinux::CloseSocket() { - if (netlink_fd_ >= 0 && HANDLE_EINTR(close(netlink_fd_)) < 0) + if (netlink_fd_ >= 0 && IGNORE_EINTR(close(netlink_fd_)) < 0) PLOG(ERROR) << "Could not close NETLINK socket."; netlink_fd_ = -1; } diff --git a/net/base/net_util_posix.cc b/net/base/net_util_posix.cc index 4882ff6..4ff3ee9 100644 --- a/net/base/net_util_posix.cc +++ b/net/base/net_util_posix.cc @@ -8,7 +8,6 @@ #include "base/files/file_path.h" #include "base/logging.h" -#include "base/posix/eintr_wrapper.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" diff --git a/net/dns/address_sorter_posix.cc b/net/dns/address_sorter_posix.cc index c4bf74d..5e2fe94 100644 --- a/net/dns/address_sorter_posix.cc +++ b/net/dns/address_sorter_posix.cc @@ -19,7 +19,6 @@ #include "base/logging.h" #include "base/memory/scoped_vector.h" -#include "base/posix/eintr_wrapper.h" #include "net/socket/client_socket_factory.h" #include "net/udp/datagram_client_socket.h" diff --git a/net/socket/tcp_listen_socket_unittest.cc b/net/socket/tcp_listen_socket_unittest.cc index 2410677..41c41f8 100644 --- a/net/socket/tcp_listen_socket_unittest.cc +++ b/net/socket/tcp_listen_socket_unittest.cc @@ -73,7 +73,7 @@ void TCPListenSocketTester::TearDown() { #if defined(OS_WIN) ASSERT_EQ(0, closesocket(test_socket_)); #elif defined(OS_POSIX) - ASSERT_EQ(0, HANDLE_EINTR(close(test_socket_))); + ASSERT_EQ(0, IGNORE_EINTR(close(test_socket_))); #endif NextAction(); ASSERT_EQ(ACTION_CLOSE, last_action_.type()); diff --git a/net/socket/tcp_socket_libevent.cc b/net/socket/tcp_socket_libevent.cc index ab96afb..f4e4fe8 100644 --- a/net/socket/tcp_socket_libevent.cc +++ b/net/socket/tcp_socket_libevent.cc @@ -521,7 +521,7 @@ void TCPSocketLibevent::Close() { DCHECK(ok); if (socket_ != kInvalidSocket) { - if (HANDLE_EINTR(close(socket_)) < 0) + if (IGNORE_EINTR(close(socket_)) < 0) PLOG(ERROR) << "close"; socket_ = kInvalidSocket; } @@ -590,7 +590,7 @@ int TCPSocketLibevent::AcceptInternal(scoped_ptr<TCPSocketLibevent>* socket, IPEndPoint ip_end_point; if (!ip_end_point.FromSockAddr(storage.addr, storage.addr_len)) { NOTREACHED(); - if (HANDLE_EINTR(close(new_socket)) < 0) + if (IGNORE_EINTR(close(new_socket)) < 0) PLOG(ERROR) << "close"; net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, ERR_ADDRESS_INVALID); diff --git a/net/socket/unix_domain_socket_posix.cc b/net/socket/unix_domain_socket_posix.cc index 2b781d5..3141f71 100644 --- a/net/socket/unix_domain_socket_posix.cc +++ b/net/socket/unix_domain_socket_posix.cc @@ -130,7 +130,7 @@ SocketDescriptor UnixDomainSocket::CreateAndBind(const std::string& path, LOG(ERROR) << "Could not bind unix domain socket to " << path; if (use_abstract_namespace) LOG(ERROR) << " (with abstract namespace enabled)"; - if (HANDLE_EINTR(close(s)) < 0) + if (IGNORE_EINTR(close(s)) < 0) LOG(ERROR) << "close() error"; return kInvalidSocket; } @@ -145,7 +145,7 @@ void UnixDomainSocket::Accept() { gid_t group_id; if (!GetPeerIds(conn, &user_id, &group_id) || !auth_callback_.Run(user_id, group_id)) { - if (HANDLE_EINTR(close(conn)) < 0) + if (IGNORE_EINTR(close(conn)) < 0) LOG(ERROR) << "close() error"; return; } diff --git a/net/socket/unix_domain_socket_posix_unittest.cc b/net/socket/unix_domain_socket_posix_unittest.cc index 6520985..b1857e6 100644 --- a/net/socket/unix_domain_socket_posix_unittest.cc +++ b/net/socket/unix_domain_socket_posix_unittest.cc @@ -306,7 +306,7 @@ TEST_F(UnixDomainSocketTest, TestWithClient) { ASSERT_EQ(kMsg, socket_delegate_->ReceivedData()); // Close the client socket. - ret = HANDLE_EINTR(close(sock)); + ret = IGNORE_EINTR(close(sock)); event = event_manager_->WaitForEvent(); ASSERT_EQ(EVENT_CLOSE, event); } diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc index 990aa57..7ef9c3c 100644 --- a/net/udp/udp_socket_libevent.cc +++ b/net/udp/udp_socket_libevent.cc @@ -83,7 +83,7 @@ void UDPSocketLibevent::Close() { ok = write_socket_watcher_.StopWatchingFileDescriptor(); DCHECK(ok); - if (HANDLE_EINTR(close(socket_)) < 0) + if (IGNORE_EINTR(close(socket_)) < 0) PLOG(ERROR) << "close"; socket_ = kInvalidSocket; diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc index c9f30a7..d2745b9 100644 --- a/net/udp/udp_socket_win.cc +++ b/net/udp/udp_socket_win.cc @@ -11,7 +11,6 @@ #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/metrics/stats_counters.h" -#include "base/posix/eintr_wrapper.h" #include "base/rand_util.h" #include "net/base/io_buffer.h" #include "net/base/ip_endpoint.h" diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index d6d0d90..4dc3a45 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -35,7 +35,6 @@ #include "ppapi/shared_impl/resource.h" #if defined(OS_POSIX) && !defined(OS_NACL) -#include "base/posix/eintr_wrapper.h" #include "ipc/ipc_channel_posix.h" #endif diff --git a/ppapi/tests/test_broker.cc b/ppapi/tests/test_broker.cc index 0537b95..db2fa3f 100644 --- a/ppapi/tests/test_broker.cc +++ b/ppapi/tests/test_broker.cc @@ -58,13 +58,26 @@ PlatformFile IntToPlatformFile(int32_t handle) { } #if defined(OS_POSIX) + #define HANDLE_EINTR(x) ({ \ - typeof(x) __eintr_result__; \ + typeof(x) eintr_wrapper_result; \ do { \ - __eintr_result__ = x; \ - } while (__eintr_result__ == -1 && errno == EINTR); \ - __eintr_result__;\ + eintr_wrapper_result = (x); \ + } while (eintr_wrapper_result == -1 && errno == EINTR); \ + eintr_wrapper_result; \ }) + +#define IGNORE_EINTR(x) ({ \ + typeof(x) eintr_wrapper_result; \ + do { \ + eintr_wrapper_result = (x); \ + if (eintr_wrapper_result == -1 && errno == EINTR) { \ + eintr_wrapper_result = 0; \ + } \ + } while (0); \ + eintr_wrapper_result; \ +}) + #endif bool ReadMessage(PlatformFile file, size_t message_len, char* message) { @@ -121,7 +134,7 @@ bool ClosePlatformFile(PlatformFile file) { #if defined(OS_WIN) return !!::CloseHandle(file); #elif defined(OS_POSIX) - return !HANDLE_EINTR(::close(file)); + return !IGNORE_EINTR(::close(file)); #endif } @@ -147,7 +160,7 @@ bool VerifyIsUnsandboxed() { if (-1 == fd) return false; - if (HANDLE_EINTR(::close(fd))) { + if (IGNORE_EINTR(::close(fd))) { ::remove(file_name); return false; } diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index 2242cfc..57e635a 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -212,7 +212,7 @@ bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { } if (fd.auto_close) { - if (HANDLE_EINTR(close(fd.fd)) < 0) { + if (IGNORE_EINTR(close(fd.fd)) < 0) { DPLOG(WARNING) << "close"; result = false; } diff --git a/remoting/host/ipc_util_posix.cc b/remoting/host/ipc_util_posix.cc index 55f215d..d7c6a5d 100644 --- a/remoting/host/ipc_util_posix.cc +++ b/remoting/host/ipc_util_posix.cc @@ -33,9 +33,9 @@ bool CreateConnectedIpcChannel( if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 || fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) { PLOG(ERROR) << "fcntl(O_NONBLOCK)"; - if (HANDLE_EINTR(close(pipe_fds[0])) < 0) + if (IGNORE_EINTR(close(pipe_fds[0])) < 0) PLOG(ERROR) << "close()"; - if (HANDLE_EINTR(close(pipe_fds[1])) < 0) + if (IGNORE_EINTR(close(pipe_fds[1])) < 0) PLOG(ERROR) << "close()"; return false; } diff --git a/remoting/host/local_input_monitor_linux.cc b/remoting/host/local_input_monitor_linux.cc index 3d85bf8..0f69597 100644 --- a/remoting/host/local_input_monitor_linux.cc +++ b/remoting/host/local_input_monitor_linux.cc @@ -17,7 +17,6 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_pump_libevent.h" -#include "base/posix/eintr_wrapper.h" #include "base/single_thread_task_runner.h" #include "base/threading/non_thread_safe.h" #include "remoting/host/client_session_control.h" diff --git a/rlz/lib/recursive_cross_process_lock_posix.cc b/rlz/lib/recursive_cross_process_lock_posix.cc index aa15897..c44cacf 100644 --- a/rlz/lib/recursive_cross_process_lock_posix.cc +++ b/rlz/lib/recursive_cross_process_lock_posix.cc @@ -59,7 +59,7 @@ bool RecursiveCrossProcessLock::TryGetCrossProcessLock( if (flock_result == -1) { perror("flock"); - ignore_result(HANDLE_EINTR(close(file_lock_))); + close(file_lock_); file_lock_ = -1; return false; } @@ -72,7 +72,7 @@ bool RecursiveCrossProcessLock::TryGetCrossProcessLock( void RecursiveCrossProcessLock::ReleaseLock() { if (file_lock_ != -1) { ignore_result(HANDLE_EINTR(flock(file_lock_, LOCK_UN))); - ignore_result(HANDLE_EINTR(close(file_lock_))); + close(file_lock_); file_lock_ = -1; } diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc index 3a4b678..b598d76 100644 --- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc +++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc @@ -104,9 +104,9 @@ bool IsSingleThreaded(int proc_fd) { struct stat sb; int task = -1; if ((task = openat(proc_fd, "self/task", O_RDONLY | O_DIRECTORY)) < 0 || - fstat(task, &sb) != 0 || sb.st_nlink != 3 || HANDLE_EINTR(close(task))) { + fstat(task, &sb) != 0 || sb.st_nlink != 3 || IGNORE_EINTR(close(task))) { if (task >= 0) { - if (HANDLE_EINTR(close(task))) { + if (IGNORE_EINTR(close(task))) { } } return false; @@ -287,7 +287,7 @@ bool Sandbox::RunFunctionInPolicy(void (*code_in_sandbox)(), Die::EnableSimpleExit(); errno = 0; - if (HANDLE_EINTR(close(fds[0]))) { + if (IGNORE_EINTR(close(fds[0]))) { // This call to close() has been failing in strange ways. See // crbug.com/152530. So we only fail in debug mode now. #if !defined(NDEBUG) @@ -309,7 +309,7 @@ bool Sandbox::RunFunctionInPolicy(void (*code_in_sandbox)(), SANDBOX_DIE(NULL); #endif } - if (HANDLE_EINTR(close(fds[1]))) { + if (IGNORE_EINTR(close(fds[1]))) { // This call to close() has been failing in strange ways. See // crbug.com/152530. So we only fail in debug mode now. #if !defined(NDEBUG) @@ -329,7 +329,7 @@ bool Sandbox::RunFunctionInPolicy(void (*code_in_sandbox)(), } // In the parent process. - if (HANDLE_EINTR(close(fds[1]))) { + if (IGNORE_EINTR(close(fds[1]))) { SANDBOX_DIE("close() failed"); } if (sigprocmask(SIG_SETMASK, &old_mask, NULL)) { @@ -357,7 +357,7 @@ bool Sandbox::RunFunctionInPolicy(void (*code_in_sandbox)(), SANDBOX_DIE(buf); } } - if (HANDLE_EINTR(close(fds[0]))) { + if (IGNORE_EINTR(close(fds[0]))) { SANDBOX_DIE("close() failed"); } @@ -451,7 +451,7 @@ void Sandbox::StartSandbox() { // before installing the filters, just in case that our policy denies // close(). if (proc_fd_ >= 0) { - if (HANDLE_EINTR(close(proc_fd_))) { + if (IGNORE_EINTR(close(proc_fd_))) { SANDBOX_DIE("Failed to close file descriptor for /proc"); } proc_fd_ = -1; diff --git a/sandbox/linux/seccomp-bpf/syscall_unittest.cc b/sandbox/linux/seccomp-bpf/syscall_unittest.cc index 0472448..261453b 100644 --- a/sandbox/linux/seccomp-bpf/syscall_unittest.cc +++ b/sandbox/linux/seccomp-bpf/syscall_unittest.cc @@ -64,7 +64,7 @@ TEST(Syscall, TrivialSyscallOneArg) { int new_fd; // Duplicate standard error and close it. ASSERT_GE(new_fd = SandboxSyscall(__NR_dup, 2), 0); - int close_return_value = HANDLE_EINTR(SandboxSyscall(__NR_close, new_fd)); + int close_return_value = IGNORE_EINTR(SandboxSyscall(__NR_close, new_fd)); ASSERT_EQ(close_return_value, 0); } @@ -160,7 +160,7 @@ TEST(Syscall, ComplexSyscallSixArgs) { // Clean up EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr1, 4096L)); - EXPECT_EQ(0, HANDLE_EINTR(SandboxSyscall(__NR_close, fd))); + EXPECT_EQ(0, IGNORE_EINTR(SandboxSyscall(__NR_close, fd))); // Check that the offset argument (i.e. the sixth argument) is processed // correctly. @@ -193,7 +193,7 @@ TEST(Syscall, ComplexSyscallSixArgs) { // Clean up EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr2, 8192L)); EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr3, 4096L)); - EXPECT_EQ(0, HANDLE_EINTR(SandboxSyscall(__NR_close, fd))); + EXPECT_EQ(0, IGNORE_EINTR(SandboxSyscall(__NR_close, fd))); } } // namespace diff --git a/sandbox/linux/seccomp-bpf/trap.cc b/sandbox/linux/seccomp-bpf/trap.cc index de701a7..3dcd256 100644 --- a/sandbox/linux/seccomp-bpf/trap.cc +++ b/sandbox/linux/seccomp-bpf/trap.cc @@ -13,7 +13,6 @@ #include <limits> #include "base/logging.h" -#include "base/posix/eintr_wrapper.h" #include "sandbox/linux/seccomp-bpf/codegen.h" #include "sandbox/linux/seccomp-bpf/die.h" #include "sandbox/linux/seccomp-bpf/syscall.h" diff --git a/sandbox/linux/services/broker_process.cc b/sandbox/linux/services/broker_process.cc index 0e91c20..316883d 100644 --- a/sandbox/linux/services/broker_process.cc +++ b/sandbox/linux/services/broker_process.cc @@ -131,7 +131,7 @@ BrokerProcess::BrokerProcess(int denied_errno, BrokerProcess::~BrokerProcess() { if (initialized_ && ipc_socketpair_ != -1) { - void (HANDLE_EINTR(close(ipc_socketpair_))); + close(ipc_socketpair_); } } @@ -148,13 +148,13 @@ bool BrokerProcess::Init(bool (*sandbox_callback)(void)) { int child_pid = fork(); if (child_pid == -1) { - ignore_result(HANDLE_EINTR(close(socket_pair[0]))); - ignore_result(HANDLE_EINTR(close(socket_pair[1]))); + close(socket_pair[0]); + close(socket_pair[1]); return false; } if (child_pid) { // We are the parent and we have just forked our broker process. - ignore_result(HANDLE_EINTR(close(socket_pair[0]))); + close(socket_pair[0]); // We should only be able to write to the IPC channel. We'll always send // a new file descriptor to receive the reply on. shutdown(socket_pair[1], SHUT_RD); @@ -165,7 +165,7 @@ bool BrokerProcess::Init(bool (*sandbox_callback)(void)) { return true; } else { // We are the broker. - ignore_result(HANDLE_EINTR(close(socket_pair[1]))); + close(socket_pair[1]); // We should only be able to read from this IPC channel. We will send our // replies on a new file descriptor attached to the requests. shutdown(socket_pair[0], SHUT_WR); @@ -329,7 +329,7 @@ bool BrokerProcess::HandleRequest() const { r = false; break; } - int ret = HANDLE_EINTR(close(temporary_ipc)); + int ret = IGNORE_EINTR(close(temporary_ipc)); DCHECK(!ret) << "Could not close temporary IPC channel"; return r; } @@ -374,7 +374,7 @@ bool BrokerProcess::HandleRemoteCommand(IPCCommands command_type, int reply_ipc, // Close anything we have opened in this process. for (std::vector<int>::iterator it = opened_files.begin(); it < opened_files.end(); ++it) { - int ret = HANDLE_EINTR(close(*it)); + int ret = IGNORE_EINTR(close(*it)); DCHECK(!ret) << "Could not close file descriptor"; } diff --git a/sandbox/linux/services/broker_process_unittest.cc b/sandbox/linux/services/broker_process_unittest.cc index 4cb9c6f..f163ef9 100644 --- a/sandbox/linux/services/broker_process_unittest.cc +++ b/sandbox/linux/services/broker_process_unittest.cc @@ -48,7 +48,7 @@ class ScopedTemporaryFile { } ~ScopedTemporaryFile() { CHECK_EQ(0, unlink(full_file_name_)); - CHECK_EQ(0, HANDLE_EINTR(close(fd_))); + CHECK_EQ(0, IGNORE_EINTR(close(fd_))); } int fd() const { return fd_; } diff --git a/sandbox/linux/services/init_process_reaper.cc b/sandbox/linux/services/init_process_reaper.cc index f5473ba..2e0b90b 100644 --- a/sandbox/linux/services/init_process_reaper.cc +++ b/sandbox/linux/services/init_process_reaper.cc @@ -33,9 +33,9 @@ bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { pid_t child_pid = fork(); if (child_pid == -1) { int close_ret; - close_ret = HANDLE_EINTR(close(sync_fds[0])); + close_ret = IGNORE_EINTR(close(sync_fds[0])); DPCHECK(!close_ret); - close_ret = HANDLE_EINTR(close(sync_fds[1])); + close_ret = IGNORE_EINTR(close(sync_fds[1])); DPCHECK(!close_ret); return false; } @@ -50,7 +50,7 @@ bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { CHECK(sigaction(SIGCHLD, &action, NULL) == 0); int close_ret; - close_ret = HANDLE_EINTR(close(sync_fds[0])); + close_ret = IGNORE_EINTR(close(sync_fds[0])); DPCHECK(!close_ret); close_ret = shutdown(sync_fds[1], SHUT_RD); DPCHECK(!close_ret); @@ -58,7 +58,7 @@ bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { post_fork_parent_callback->Run(); // Tell the child to continue CHECK(HANDLE_EINTR(send(sync_fds[1], "C", 1, MSG_NOSIGNAL)) == 1); - close_ret = HANDLE_EINTR(close(sync_fds[1])); + close_ret = IGNORE_EINTR(close(sync_fds[1])); DPCHECK(!close_ret); for (;;) { @@ -83,13 +83,13 @@ bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { // The child needs to wait for the parent to run the callback to avoid a // race condition. int close_ret; - close_ret = HANDLE_EINTR(close(sync_fds[1])); + close_ret = IGNORE_EINTR(close(sync_fds[1])); DPCHECK(!close_ret); close_ret = shutdown(sync_fds[0], SHUT_WR); DPCHECK(!close_ret); char should_continue; int read_ret = HANDLE_EINTR(read(sync_fds[0], &should_continue, 1)); - close_ret = HANDLE_EINTR(close(sync_fds[0])); + close_ret = IGNORE_EINTR(close(sync_fds[0])); DPCHECK(!close_ret); if (read_ret == 1) return true; diff --git a/sandbox/linux/tests/unit_tests.cc b/sandbox/linux/tests/unit_tests.cc index 320f52b..ad30d84 100644 --- a/sandbox/linux/tests/unit_tests.cc +++ b/sandbox/linux/tests/unit_tests.cc @@ -150,7 +150,7 @@ void UnitTests::RunTestInProcess(UnitTests::Test test, _exit(kExpectedValue); } - (void)HANDLE_EINTR(close(fds[1])); + close(fds[1]); std::vector<char> msg_buf; ssize_t rc; @@ -175,7 +175,7 @@ void UnitTests::RunTestInProcess(UnitTests::Test test, } ASSERT_NE(poll_ret, -1) << "poll() failed"; ASSERT_NE(poll_ret, 0) << "Timeout while reading child state"; - (void)HANDLE_EINTR(close(fds[0])); + close(fds[0]); std::string msg(msg_buf.begin(), msg_buf.end()); int status = 0; diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 0239fc7..ad9aef0 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -537,7 +537,7 @@ Status ChromiumWritableFile::SyncParent() { s = MakeIOError( parent_dir_, strerror(saved_errno), kSyncParent, saved_errno); }; - HANDLE_EINTR(close(parent_fd)); + close(parent_fd); #endif return s; } diff --git a/tools/android/common/adb_connection.cc b/tools/android/common/adb_connection.cc index 91c25fe..9985a3a 100644 --- a/tools/android/common/adb_connection.cc +++ b/tools/android/common/adb_connection.cc @@ -22,7 +22,7 @@ namespace { void CloseSocket(int fd) { if (fd >= 0) { int old_errno = errno; - (void) HANDLE_EINTR(close(fd)); + close(fd); errno = old_errno; } } diff --git a/tools/android/common/daemon.cc b/tools/android/common/daemon.cc index 9eafdbc..699c615 100644 --- a/tools/android/common/daemon.cc +++ b/tools/android/common/daemon.cc @@ -4,6 +4,7 @@ #include "tools/android/common/daemon.h" +#include <errno.h> #include <signal.h> #include <stdio.h> #include <sys/types.h> @@ -11,7 +12,6 @@ #include "base/command_line.h" #include "base/logging.h" -#include "base/posix/eintr_wrapper.h" namespace { @@ -25,7 +25,7 @@ void Exit(int unused) { void CloseFileDescriptor(int fd) { int old_errno = errno; - (void) HANDLE_EINTR(close(fd)); + close(fd); errno = old_errno; } diff --git a/tools/android/forwarder/forwarder.cc b/tools/android/forwarder/forwarder.cc index e77c806..fe49903 100644 --- a/tools/android/forwarder/forwarder.cc +++ b/tools/android/forwarder/forwarder.cc @@ -31,7 +31,7 @@ volatile bool g_killed = false; void CloseSocket(int fd) { if (fd >= 0) { int old_errno = errno; - (void) HANDLE_EINTR(close(fd)); + close(fd); errno = old_errno; } } diff --git a/tools/android/forwarder2/common.cc b/tools/android/forwarder2/common.cc index c97ed80..3b7387d 100644 --- a/tools/android/forwarder2/common.cc +++ b/tools/android/forwarder2/common.cc @@ -19,7 +19,7 @@ void PError(const char* msg) { void CloseFD(int fd) { const int errno_copy = errno; - if (HANDLE_EINTR(close(fd)) < 0) { + if (IGNORE_EINTR(close(fd)) < 0) { PError("close"); errno = errno_copy; } diff --git a/tools/android/forwarder2/host_forwarder_main.cc b/tools/android/forwarder2/host_forwarder_main.cc index 9d53900..185bcea 100644 --- a/tools/android/forwarder2/host_forwarder_main.cc +++ b/tools/android/forwarder2/host_forwarder_main.cc @@ -28,7 +28,6 @@ #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "base/pickle.h" -#include "base/posix/eintr_wrapper.h" #include "base/safe_strerror_posix.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" diff --git a/tools/android/forwarder2/pipe_notifier.cc b/tools/android/forwarder2/pipe_notifier.cc index 3aba18b..9110fff 100644 --- a/tools/android/forwarder2/pipe_notifier.cc +++ b/tools/android/forwarder2/pipe_notifier.cc @@ -25,8 +25,8 @@ PipeNotifier::PipeNotifier() { } PipeNotifier::~PipeNotifier() { - (void) HANDLE_EINTR(close(receiver_fd_)); - (void) HANDLE_EINTR(close(sender_fd_)); + close(receiver_fd_); + close(sender_fd_); } bool PipeNotifier::Notify() { diff --git a/ui/surface/transport_dib_posix.cc b/ui/surface/transport_dib_posix.cc index cd9ac62..28095f2 100644 --- a/ui/surface/transport_dib_posix.cc +++ b/ui/surface/transport_dib_posix.cc @@ -13,7 +13,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" -#include "base/posix/eintr_wrapper.h" #include "skia/ext/platform_canvas.h" TransportDIB::TransportDIB() |