Bug 708813 - LDAP connection broken (application deadlocks) starting with version 9. r=honza,a=Standard8 for checkin to Thunderbird/SeaMonkey specific relbranch COMM100_2012012414_RELBRANCH SEAMONKEY_2_7b5_BUILD1 SEAMONKEY_2_7b5_RELEASE THUNDERBIRD_10_0b5_BUILD1 THUNDERBIRD_10_0b5_RELEASE
authorBrian Smith <bsmith@mozilla.com>
Tue, 24 Jan 2012 22:01:07 +0000
branchCOMM100_2012012414_RELBRANCH
changeset 81629 87215b657b0c37e49954d7f012c1092f86c51a51
parent 81623 b4091c66fdffa9eb5d1adac6f4c212fcf3d62efb
child 81630 14555ef2626f7dc98cfd8f8aa760d201f5c98a04
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewershonza, Standard8
bugs708813
milestone10.0
Bug 708813 - LDAP connection broken (application deadlocks) starting with version 9. r=honza,a=Standard8 for checkin to Thunderbird/SeaMonkey specific relbranch
security/manager/ssl/src/PSMRunnable.cpp
security/manager/ssl/src/nsNSSCallbacks.cpp
security/manager/ssl/src/nsNSSIOLayer.cpp
--- a/security/manager/ssl/src/PSMRunnable.cpp
+++ b/security/manager/ssl/src/PSMRunnable.cpp
@@ -41,24 +41,28 @@ namespace mozilla { namespace psm {
 SyncRunnableBase::SyncRunnableBase()
   : monitor("SyncRunnableBase::monitor")
 {
 }
 
 nsresult
 SyncRunnableBase::DispatchToMainThreadAndWait()
 {
-  NS_ASSERTION(!NS_IsMainThread(),
-               "DispatchToMainThreadAndWait called on the main thread.");
+  nsresult rv;
+  if (NS_IsMainThread()) {
+    RunOnTargetThread();
+    rv = NS_OK;
+  } else {
+    mozilla::MonitorAutoLock lock(monitor);
+    rv = NS_DispatchToMainThread(this);
+    if (NS_SUCCEEDED(rv)) {
+      lock.Wait();
+    }
+  }
 
-  mozilla::MonitorAutoLock lock(monitor);
-  nsresult rv = NS_DispatchToMainThread(this);
-  if (NS_SUCCEEDED(rv)) {
-    lock.Wait();
-  }
   return rv;
 }
 
 NS_IMETHODIMP
 SyncRunnableBase::Run()
 {
   RunOnTargetThread();
   mozilla::MonitorAutoLock(monitor).Notify();
--- a/security/manager/ssl/src/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/src/nsNSSCallbacks.cpp
@@ -820,21 +820,17 @@ void PK11PasswordPromptRunnable::RunOnTa
 }
 
 char* PR_CALLBACK
 PK11PasswordPrompt(PK11SlotInfo* slot, PRBool retry, void* arg)
 {
   nsRefPtr<PK11PasswordPromptRunnable> runnable = 
     new PK11PasswordPromptRunnable(slot,
                                    static_cast<nsIInterfaceRequestor*>(arg));
-  if (NS_IsMainThread()) {
-    runnable->RunOnTargetThread();
-  } else {
-    runnable->DispatchToMainThreadAndWait();
-  }
+  runnable->DispatchToMainThreadAndWait();
   return runnable->mResult;
 }
 
 void PR_CALLBACK HandshakeCallback(PRFileDesc* fd, void* client_data) {
   nsNSSShutDownPreventionLock locker;
   PRInt32 sslStatus;
   char* signer = nsnull;
   char* cipherName = nsnull;
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -822,21 +822,16 @@ private:
   nsCOMPtr<nsIInterfaceRequestor> mCallbacks; // in
 };
 
 void nsNSSSocketInfo::GetPreviousCert(nsIX509Cert** _result)
 {
   NS_ASSERTION(_result, "_result parameter to GetPreviousCert is null");
   *_result = nsnull;
 
-  if (NS_IsMainThread()) {
-    NS_ERROR("nsNSSSocketInfo::GetPreviousCert called on the main thread");
-    return;
-  }
-
   nsRefPtr<PreviousCertRunnable> runnable = new PreviousCertRunnable(mCallbacks);
   nsresult rv = runnable->DispatchToMainThreadAndWait();
   NS_ASSERTION(NS_SUCCEEDED(rv), "runnable->DispatchToMainThreadAndWait() failed");
   runnable->mPreviousCert.forget(_result);
 }
 
 nsresult nsNSSSocketInfo::GetSSLStatus(nsISSLStatus** _result)
 {