From 7c36ce98208747b51ec0f9617fdd18adaa435eca Mon Sep 17 00:00:00 2001 From: Honza Bambas Date: Thu, 8 Mar 2012 17:24:17 +0100 Subject: [PATCH] Bug 720320 - Prevent stuck in offline mode when starting in link state managed mode w/o a link up, credits=standard8, r=biesi --- netwerk/base/src/nsIOService.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index d6bc5b62135..bf7b8551b75 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -176,7 +176,7 @@ PRUint32 nsIOService::gDefaultSegmentCount = 24; nsIOService::nsIOService() : mOffline(true) , mOfflineForProfileChange(false) - , mManageOfflineStatus(true) + , mManageOfflineStatus(false) , mSettingOffline(false) , mSetOfflineValue(false) , mShutdown(false) @@ -1119,10 +1119,19 @@ NS_IMETHODIMP nsIOService::SetManageOfflineStatus(bool aManage) { nsresult rv = NS_OK; - InitializeNetworkLinkService(); + // SetManageOfflineStatus must throw when we fail to go from non-managed + // to managed. Usually because there is no link monitoring service + // available. Failure to do this switch is detected by a failure of + // TrackNetworkLinkStatusForOffline(). When there is no network link + // available during call to InitializeNetworkLinkService(), application is + // put to offline mode. And when we change mMangeOfflineStatus to false + // on the next line we get stuck on being offline even though the link + // becomes later available. bool wasManaged = mManageOfflineStatus; mManageOfflineStatus = aManage; + InitializeNetworkLinkService(); + if (mManageOfflineStatus && !wasManaged) { rv = TrackNetworkLinkStatusForOffline(); if (NS_FAILED(rv))