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))