mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Follow-up checkin to bug 111384, fixes the tinderbox tests failure.
If the thread runner C function calls the pure virtual Run too early, before the constructor finished, it will crash. This patch delays thread creation and virtual function call to a separate startThread call. Thanks a lot to Jag for his help in finding the problem! r=jag
This commit is contained in:
parent
09d728cdf3
commit
f837429d3d
@ -100,8 +100,6 @@ nsCertVerificationThread::nsCertVerificationThread()
|
||||
" to create another instance!");
|
||||
|
||||
verification_thread_singleton = this;
|
||||
|
||||
NS_ASSERTION(mThreadHandle, "Could not create nsThreadRunner thread\n");
|
||||
}
|
||||
|
||||
nsCertVerificationThread::~nsCertVerificationThread()
|
||||
|
@ -301,7 +301,11 @@ nsNSSComponent::nsNSSComponent()
|
||||
mShutdownObjectList = nsNSSShutDownList::construct();
|
||||
mIsNetworkDown = PR_FALSE;
|
||||
mSSLThread = new nsSSLThread();
|
||||
if (mSSLThread)
|
||||
mSSLThread->startThread();
|
||||
mCertVerificationThread = new nsCertVerificationThread();
|
||||
if (mCertVerificationThread)
|
||||
mCertVerificationThread->startThread();
|
||||
}
|
||||
|
||||
nsNSSComponent::~nsNSSComponent()
|
||||
@ -1953,8 +1957,12 @@ nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("receiving network restore topic\n"));
|
||||
delete mSSLThread;
|
||||
mSSLThread = new nsSSLThread();
|
||||
if (mSSLThread)
|
||||
mSSLThread->startThread();
|
||||
delete mCertVerificationThread;
|
||||
mCertVerificationThread = new nsCertVerificationThread();
|
||||
if (mCertVerificationThread)
|
||||
mCertVerificationThread->startThread();
|
||||
mIsNetworkDown = PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -52,14 +52,22 @@ nsPSMBackgroundThread::nsPSMBackgroundThread()
|
||||
{
|
||||
mMutex = PR_NewLock();
|
||||
mCond = PR_NewCondVar(mMutex);
|
||||
}
|
||||
|
||||
if (mMutex && mCond)
|
||||
{
|
||||
mThreadHandle = PR_CreateThread(PR_USER_THREAD, nsThreadRunner, NS_STATIC_CAST(void*, this),
|
||||
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
|
||||
nsresult nsPSMBackgroundThread::startThread()
|
||||
{
|
||||
if (!mMutex || !mCond)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ASSERTION(mThreadHandle, "Could not create nsPSMBackgroundThread\n");
|
||||
}
|
||||
mThreadHandle = PR_CreateThread(PR_USER_THREAD, nsThreadRunner, NS_STATIC_CAST(void*, this),
|
||||
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
|
||||
|
||||
NS_ASSERTION(mThreadHandle, "Could not create nsPSMBackgroundThread\n");
|
||||
|
||||
if (!mThreadHandle)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPSMBackgroundThread::~nsPSMBackgroundThread()
|
||||
|
@ -39,6 +39,7 @@
|
||||
#define _NSPSMBACKGROUNDTHREAD_H_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsPSMBackgroundThread
|
||||
{
|
||||
@ -64,7 +65,8 @@ protected:
|
||||
public:
|
||||
nsPSMBackgroundThread();
|
||||
virtual ~nsPSMBackgroundThread();
|
||||
|
||||
|
||||
nsresult startThread();
|
||||
void requestExit();
|
||||
};
|
||||
|
||||
|
@ -50,8 +50,6 @@ nsSSLThread::nsSSLThread()
|
||||
NS_ASSERTION(!ssl_thread_singleton, "nsSSLThread is a singleton, caller attempts to create another instance!");
|
||||
|
||||
ssl_thread_singleton = this;
|
||||
|
||||
NS_ASSERTION(mThreadHandle, "Could not create nsSSLThreadRunner thread\n");
|
||||
}
|
||||
|
||||
nsSSLThread::~nsSSLThread()
|
||||
|
Loading…
Reference in New Issue
Block a user