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 /ipc/ipc_channel_posix.cc | |
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
Diffstat (limited to 'ipc/ipc_channel_posix.cc')
-rw-r--r-- | ipc/ipc_channel_posix.cc | 22 |
1 files changed, 11 insertions, 11 deletions
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. |