diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 22:07:45 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 22:07:45 +0000 |
commit | 21dedcc12d21ccb288244249522d77bc074c501e (patch) | |
tree | c0c83a62c307975f440a22e5ea8ca5c0d2853bc7 /chrome/browser | |
parent | 69b56c1ae9b3f5f241fdfae592e595bd7eaacc1e (diff) | |
download | chromium_src-21dedcc12d21ccb288244249522d77bc074c501e.zip chromium_src-21dedcc12d21ccb288244249522d77bc074c501e.tar.gz chromium_src-21dedcc12d21ccb288244249522d77bc074c501e.tar.bz2 |
Clean up read FDs in async network alive. This prevents chrome from eating all FDs.
BUG=35229
TEST=Let Chrome idle with a flakey net connection, and check that the number of open FDs is not increasing.
Review URL: http://codereview.chromium.org/1336004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/sync/notifier/base/linux/async_network_alive_linux.cc | 18 |
1 files changed, 17 insertions, 1 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 9c096da..a9a8457 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 @@ -26,7 +26,17 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive { virtual ~AsyncNetworkAliveLinux() { if (exit_pipe_[1]) { + // 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; + } + if (exit_pipe_[0]) { + close(exit_pipe_[0]); + exit_pipe_[0] = 0; } } @@ -34,6 +44,7 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive { // SignalThread Interface virtual void DoWork() { if (!exit_pipe_[0]) { + 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. error_ = true; @@ -66,6 +77,7 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive { PLOG(ERROR) << "select() returned unexpected result " << result; close(fd); close(exit_pipe_[0]); + exit_pipe_[0] = 0; return; } @@ -82,10 +94,11 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive { close(fd); // If exit_pipe was written to, we must be shutting down. - if (FD_ISSET(exit_pipe_[0], &rdfs)) { + if (exit_pipe_[0] == 0 || FD_ISSET(exit_pipe_[0], &rdfs)) { alive_ = false; error_ = true; close(exit_pipe_[0]); + exit_pipe_[0] = 0; return; } @@ -98,6 +111,9 @@ class AsyncNetworkAliveLinux : public AsyncNetworkAlive { } else { alive_ = true; } + + close(exit_pipe_[0]); + exit_pipe_[0] = 0; } virtual void OnWorkStop() { |