author | David Keeler <dkeeler@mozilla.com> |
Thu, 15 Oct 2015 13:22:13 -0700 | |
changeset 301481 | cb5785379a0b33f9a825a01e7236baf239f2fcdc |
parent 301480 | c07248ffb45460b9afd12d75910146878165b2db |
child 301482 | 4f4e54b55fc8e048f0a0a4d882c45f02bdab99f9 |
push id | 5392 |
push user | raliiev@mozilla.com |
push date | Mon, 14 Dec 2015 20:08:23 +0000 |
treeherder | mozilla-beta@16ce8562a975 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Cykesiopka |
bugs | 1215270, 807757 |
milestone | 44.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/security/manager/ssl/nsNSSIOLayer.cpp +++ b/security/manager/ssl/nsNSSIOLayer.cpp @@ -925,18 +925,16 @@ nsSSLIOLayerClose(PRFileDesc* fd) return socketInfo->CloseSocketAndDestroy(locker); } PRStatus nsNSSSocketInfo::CloseSocketAndDestroy( const nsNSSShutDownPreventionLock& /*proofOfLock*/) { - nsNSSShutDownList::trackSSLSocketClose(); - PRFileDesc* popped = PR_PopIOLayer(mFd, PR_TOP_IO_LAYER); NS_ASSERTION(popped && popped->identity == nsSSLIOLayerHelpers::nsSSLIOLayerIdentity, "SSL Layer not on top of stack"); // The plain text layer is not always present - so its not a fatal error // if it cannot be removed PRFileDesc* poppedPlaintext = @@ -2709,18 +2707,16 @@ nsSSLIOLayerAddToSocket(int32_t family, layer->secret = (PRFilePrivate*) infoObject; stat = PR_PushIOLayer(sslSock, PR_GetLayersIdentity(sslSock), layer); if (stat == PR_FAILURE) { goto loser; } - nsNSSShutDownList::trackSSLSocketCreate(); - MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("[%p] Socket set up\n", (void*) sslSock)); infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) (info)); // We are going use a clear connection first // if (forSTARTTLS || proxyHost) { infoObject->SetHandshakeNotPending(); }
--- a/security/manager/ssl/nsNSSShutDown.cpp +++ b/security/manager/ssl/nsNSSShutDown.cpp @@ -35,17 +35,16 @@ static const PLDHashTableOps gSetOps = { PLDHashTable::ClearEntryStub, ObjectSetInitEntry }; nsNSSShutDownList *nsNSSShutDownList::singleton = nullptr; nsNSSShutDownList::nsNSSShutDownList() : mListLock("nsNSSShutDownList.mListLock") - , mActiveSSLSockets(0) , mObjects(&gSetOps, sizeof(ObjectHashEntry)) , mPK11LogoutCancelObjects(&gSetOps, sizeof(ObjectHashEntry)) { } nsNSSShutDownList::~nsNSSShutDownList() { PR_ASSERT(this == singleton); @@ -87,48 +86,16 @@ void nsNSSShutDownList::forget(nsOnPK11L if (!singleton) return; PR_ASSERT(o); MutexAutoLock lock(singleton->mListLock); singleton->mPK11LogoutCancelObjects.Remove(o); } -void nsNSSShutDownList::trackSSLSocketCreate() -{ - if (!singleton) - return; - - MutexAutoLock lock(singleton->mListLock); - ++singleton->mActiveSSLSockets; -} - -void nsNSSShutDownList::trackSSLSocketClose() -{ - if (!singleton) - return; - - MutexAutoLock lock(singleton->mListLock); - --singleton->mActiveSSLSockets; -} - -bool nsNSSShutDownList::areSSLSocketsActive() -{ - if (!singleton) { - // I'd rather prefer to be pessimistic and return true. - // However, maybe we will get called at a time when the singleton - // has already been freed, and returning true would bring up an - // unnecessary warning. - return false; - } - - MutexAutoLock lock(singleton->mListLock); - return (singleton->mActiveSSLSockets > 0); -} - nsresult nsNSSShutDownList::doPK11Logout() { MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("canceling all open SSL sockets to disallow future IO\n")); // During our iteration we will set a bunch of PRBools to true. // Nobody else ever modifies that bool, only we do. // We only must ensure that our objects do not go away. // This is guaranteed by holding the list lock. @@ -140,26 +107,19 @@ nsresult nsNSSShutDownList::doPK11Logout if (pklco) { pklco->logout(); } } return NS_OK; } -bool nsNSSShutDownList::isUIActive() -{ - bool canDisallow = mActivityState.ifPossibleDisallowUI(nsNSSActivityState::test_only); - bool bIsUIActive = !canDisallow; - return bIsUIActive; -} - bool nsNSSShutDownList::ifPossibleDisallowUI() { - bool isNowDisallowed = mActivityState.ifPossibleDisallowUI(nsNSSActivityState::do_it_for_real); + bool isNowDisallowed = mActivityState.ifPossibleDisallowUI(); return isNowDisallowed; } void nsNSSShutDownList::allowUI() { mActivityState.allowUI(); } @@ -260,36 +220,30 @@ bool nsNSSActivityState::isBlockingUIAct } bool nsNSSActivityState::isUIForbidden() { MutexAutoLock lock(mNSSActivityStateLock); return mIsUIForbidden; } -bool nsNSSActivityState::ifPossibleDisallowUI(RealOrTesting rot) +bool nsNSSActivityState::ifPossibleDisallowUI() { bool retval = false; MutexAutoLock lock(mNSSActivityStateLock); // Checking and disallowing the UI must be done atomically. if (!mBlockingUICounter) { // No UI is currently shown, we are able to evaporate. retval = true; - if (rot == do_it_for_real) { - // Remember to disallow UI. - mIsUIForbidden = true; - - // to clear the "forbidden" state, - // one must either call - // restrictActivityToCurrentThread() + releaseCurrentThreadActivityRestriction() - // or cancel the operation by calling - // unprepareCurrentThreadRestriction() - } + // Remember to disallow UI. + // To clear the "forbidden" state, call restrictActivityToCurrentThread() + // and releaseCurrentThreadActivityRestriction(). + mIsUIForbidden = true; } return retval; } void nsNSSActivityState::allowUI() { MutexAutoLock lock(mNSSActivityStateLock);
--- a/security/manager/ssl/nsNSSShutDown.h +++ b/security/manager/ssl/nsNSSShutDown.h @@ -32,22 +32,20 @@ public: void leaveBlockingUIState(); // Is the activity aware of any blocking PSM UI currently shown? bool isBlockingUIActive(); // Is it forbidden to bring up an UI while holding resources? bool isUIForbidden(); - // Check whether setting the current thread restriction is possible. - // If it is possible, and the "do_it_for_real" flag is used, - // the state tracking will have ensured that we will stay in this state. - // As of writing, this includes forbidding PSM UI. - enum RealOrTesting {test_only, do_it_for_real}; - bool ifPossibleDisallowUI(RealOrTesting rot); + // Check whether setting the current thread restriction is possible. If it + // is possible, the state tracking will have ensured that we will stay in + // this state. As of writing, this includes forbidding PSM UI. + bool ifPossibleDisallowUI(); // Notify the state tracking that going to the restricted state is // no longer planned. // As of writing, this includes clearing the "PSM UI forbidden" flag. void allowUI(); // If currently no UI is shown, wait for all activity to stop, // and block any other thread on entering relevant PSM code. @@ -111,26 +109,16 @@ public: static void remember(nsNSSShutDownObject *o); static void forget(nsNSSShutDownObject *o); // track instances that would like notification when // a PK11 logout operation is performed. static void remember(nsOnPK11LogoutCancelObject *o); static void forget(nsOnPK11LogoutCancelObject *o); - // track the creation and destruction of SSL sockets - // performed by clients using PSM services - static void trackSSLSocketCreate(); - static void trackSSLSocketClose(); - static bool areSSLSocketsActive(); - - // Are we able to do the early cleanup? - // Returns failure if at the current time "early cleanup" is not possible. - bool isUIActive(); - // If possible to do "early cleanup" at the current time, remember that we want to // do it, and disallow actions that would change the possibility. bool ifPossibleDisallowUI(); // Notify that it is no longer planned to do the "early cleanup". void allowUI(); // Do the "early cleanup", if possible. @@ -146,17 +134,16 @@ public: } private: nsNSSShutDownList(); protected: mozilla::Mutex mListLock; static nsNSSShutDownList *singleton; - uint32_t mActiveSSLSockets; PLDHashTable mObjects; PLDHashTable mPK11LogoutCancelObjects; nsNSSActivityState mActivityState; }; /* A class deriving from nsNSSShutDownObject will have its instances automatically tracked in a list. However, it must follow some rules