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:
kaie%kuix.de 2006-04-04 13:18:48 +00:00
parent 09d728cdf3
commit f837429d3d
5 changed files with 25 additions and 11 deletions

View File

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

View File

@ -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;
}

View File

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

View File

@ -39,6 +39,7 @@
#define _NSPSMBACKGROUNDTHREAD_H_
#include "nspr.h"
#include "nscore.h"
class nsPSMBackgroundThread
{
@ -65,6 +66,7 @@ public:
nsPSMBackgroundThread();
virtual ~nsPSMBackgroundThread();
nsresult startThread();
void requestExit();
};

View File

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