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 /ppapi | |
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 'ppapi')
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 1 | ||||
-rw-r--r-- | ppapi/tests/test_broker.cc | 25 |
2 files changed, 19 insertions, 7 deletions
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; } |