summaryrefslogtreecommitdiffstats
path: root/net/base/network_change_notifier_mac.cc
diff options
context:
space:
mode:
authoradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 21:28:15 +0000
committeradamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 21:28:15 +0000
commit88a59c8f29a1fd4180eeb418728bba9f79609365 (patch)
tree5874c006400096b58dbdf2c9cf6b77d7b14eae8f /net/base/network_change_notifier_mac.cc
parent7abec0424c8943483bee9d15cb245ea7bfc7ed65 (diff)
downloadchromium_src-88a59c8f29a1fd4180eeb418728bba9f79609365.zip
chromium_src-88a59c8f29a1fd4180eeb418728bba9f79609365.tar.gz
chromium_src-88a59c8f29a1fd4180eeb418728bba9f79609365.tar.bz2
NetworkChangeNotifierMac: synchronize destruction order with helper thread.
Previously, it was possible for NetworkChangeNotifierMac to unschedule the SCNetworkReachability callback before it had been scheduled. Under the hypothesis that this is causing crashes on shutdown, this change makes sure that the helper thread (on which reachability is initially scheduled) runs to completion before we check to see if we need to unschedule the callback. BUG=91767 Review URL: http://codereview.chromium.org/7862006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/network_change_notifier_mac.cc')
-rw-r--r--net/base/network_change_notifier_mac.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/net/base/network_change_notifier_mac.cc b/net/base/network_change_notifier_mac.cc
index ecf2845..69024c7 100644
--- a/net/base/network_change_notifier_mac.cc
+++ b/net/base/network_change_notifier_mac.cc
@@ -5,12 +5,6 @@
#include "net/base/network_change_notifier_mac.h"
#include <netinet/in.h>
-#include <SystemConfiguration/SCDynamicStoreKey.h>
-#include <SystemConfiguration/SCNetworkReachability.h>
-#include <SystemConfiguration/SCSchemaDefinitions.h>
-
-#include "base/mac/scoped_cftyperef.h"
-#include "base/synchronization/lock.h"
namespace net {
@@ -23,11 +17,19 @@ static bool CalculateReachability(SCNetworkConnectionFlags flags) {
NetworkChangeNotifierMac::NetworkChangeNotifierMac()
: online_state_(UNINITIALIZED),
initial_state_cv_(&online_state_lock_),
- forwarder_(this),
- config_watcher_(&forwarder_) {
+ forwarder_(this) {
+ // Must be initialized after the rest of this object, as it may call back into
+ // SetInitialState().
+ config_watcher_.reset(new NetworkConfigWatcherMac(&forwarder_));
}
NetworkChangeNotifierMac::~NetworkChangeNotifierMac() {
+ // Delete the ConfigWatcher to join the notifier thread, ensuring that
+ // SetDynamicStoreNotificationKeys() has an opportunity to run to completion.
+ config_watcher_.reset();
+
+ // Now that SetDynamicStoreNotificationKeys has either run to completion or
+ // never run at all, unschedule reachability_ if it was previously scheduled.
if (reachability_.get() && run_loop_.get()) {
SCNetworkReachabilityUnscheduleFromRunLoop(reachability_.get(),
run_loop_.get(),