Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: net/base/network_change_notifier_linux.cc

Issue 1550003: Stop watching the netlink file descriptor before the message pump is destroye... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: syn and resolve Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_change_notifier_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_change_notifier_linux.cc
===================================================================
--- net/base/network_change_notifier_linux.cc (revision 44286)
+++ net/base/network_change_notifier_linux.cc (working copy)
@@ -8,6 +8,7 @@
#include <sys/socket.h>
#include "base/basictypes.h"
+#include "base/eintr_wrapper.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "net/base/net_errors.h"
@@ -31,15 +32,14 @@
}
ListenForNotifications();
+ loop_->AddDestructionObserver(this);
}
NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() {
- if (netlink_fd_ != kInvalidSocket) {
- if (close(netlink_fd_) != 0)
- PLOG(ERROR) << "Failed to close socket";
- netlink_fd_ = kInvalidSocket;
- netlink_watcher_.StopWatchingFileDescriptor();
- }
+ StopWatching();
+
+ if (loop_)
+ loop_->RemoveDestructionObserver(this);
}
void NetworkChangeNotifierLinux::OnFileCanReadWithoutBlocking(int fd) {
@@ -52,6 +52,11 @@
NOTREACHED();
}
+void NetworkChangeNotifierLinux::WillDestroyCurrentMessageLoop() {
+ StopWatching();
+ loop_ = NULL;
+}
+
void NetworkChangeNotifierLinux::ListenForNotifications() {
char buf[4096];
int rv = ReadNotificationMessage(buf, arraysize(buf));
@@ -88,4 +93,13 @@
}
}
+void NetworkChangeNotifierLinux::StopWatching() {
+ if (netlink_fd_ != kInvalidSocket) {
+ if (HANDLE_EINTR(close(netlink_fd_)) != 0)
+ PLOG(ERROR) << "Failed to close socket";
+ netlink_fd_ = kInvalidSocket;
+ netlink_watcher_.StopWatchingFileDescriptor();
+ }
+}
+
} // namespace net
« no previous file with comments | « net/base/network_change_notifier_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698