summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 21:19:33 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 21:19:33 +0000
commitcb97608ca914fa4c557c1c645c55192cd21281a4 (patch)
treeecb5fd86d0581a50c6c9da8277209de2177eb867 /chrome
parentab8949ac2e50880bc8adb40080287ad89758d772 (diff)
downloadchromium_src-cb97608ca914fa4c557c1c645c55192cd21281a4.zip
chromium_src-cb97608ca914fa4c557c1c645c55192cd21281a4.tar.gz
chromium_src-cb97608ca914fa4c557c1c645c55192cd21281a4.tar.bz2
Use the invalid file handle value instead of 0 when creating pipes.
BUG=none TEST=none Review URL: http://codereview.chromium.org/1409002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc b/chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc
index a9a8457..0feb0ce 100644
--- a/chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc
+++ b/chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc
@@ -10,8 +10,11 @@
#include <linux/rtnetlink.h>
#include "base/logging.h"
+#include "base/platform_file.h"
#include "talk/base/physicalsocketserver.h"
+using base::kInvalidPlatformFileValue;
+
namespace notifier {
class AsyncNetworkAliveLinux : public AsyncNetworkAlive {
@@ -19,31 +22,31 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive {
AsyncNetworkAliveLinux() {
if (pipe(exit_pipe_) == -1) {
PLOG(ERROR) << "Could not create pipe for exit signal.";
- exit_pipe_[0] = 0;
- exit_pipe_[1] = 0;
+ exit_pipe_[0] = kInvalidPlatformFileValue;
+ exit_pipe_[1] = kInvalidPlatformFileValue;
}
}
virtual ~AsyncNetworkAliveLinux() {
- if (exit_pipe_[1]) {
+ if (exit_pipe_[1] != kInvalidPlatformFileValue) {
// Ensure that we've signalled the thread to quit.
char data = 0;
if (write(exit_pipe_[1], &data, 1) == -1) {
PLOG(WARNING) << "Error sending error signal to AsyncNetworkAliveLinux";
}
close(exit_pipe_[1]);
- exit_pipe_[1] = 0;
+ exit_pipe_[1] = kInvalidPlatformFileValue;
}
- if (exit_pipe_[0]) {
+ if (exit_pipe_[0] != kInvalidPlatformFileValue) {
close(exit_pipe_[0]);
- exit_pipe_[0] = 0;
+ exit_pipe_[0] = kInvalidPlatformFileValue;
}
}
protected:
// SignalThread Interface
virtual void DoWork() {
- if (!exit_pipe_[0]) {
+ if (exit_pipe_[0] == kInvalidPlatformFileValue) {
PLOG(ERROR) << "No exit flag to listen for.";
// If we don't have an exit flag to listen for, set the error flag and
// abort.
@@ -77,7 +80,7 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive {
PLOG(ERROR) << "select() returned unexpected result " << result;
close(fd);
close(exit_pipe_[0]);
- exit_pipe_[0] = 0;
+ exit_pipe_[0] = kInvalidPlatformFileValue;
return;
}
@@ -94,11 +97,12 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive {
close(fd);
// If exit_pipe was written to, we must be shutting down.
- if (exit_pipe_[0] == 0 || FD_ISSET(exit_pipe_[0], &rdfs)) {
+ if (exit_pipe_[0] == kInvalidPlatformFileValue ||
+ FD_ISSET(exit_pipe_[0], &rdfs)) {
alive_ = false;
error_ = true;
close(exit_pipe_[0]);
- exit_pipe_[0] = 0;
+ exit_pipe_[0] = kInvalidPlatformFileValue;
return;
}
@@ -113,11 +117,11 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive {
}
close(exit_pipe_[0]);
- exit_pipe_[0] = 0;
+ exit_pipe_[0] = kInvalidPlatformFileValue;
}
virtual void OnWorkStop() {
- if (exit_pipe_[1]) {
+ if (exit_pipe_[1] != kInvalidPlatformFileValue) {
char data = 0;
// We can't ignore the return value on write(), since that generates a
// compile warning. However, since we're exiting, there's nothing we can