From 8afd0c31d1ccefe6855220a66565017c6b661a96 Mon Sep 17 00:00:00 2001 From: "dp%netscape.com" Date: Fri, 18 Jun 1999 23:27:09 +0000 Subject: [PATCH] Fixed crash due to multi-threading. bug# 7308, bug# 8150 git-svn-id: svn://10.0.0.236/trunk@35882 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libreg/xpcom/nsRegistry.cpp | 2 ++ .../xpcom/components/nsComponentManager.cpp | 23 +++++++++++++++++++ mozilla/xpcom/components/nsRegistry.cpp | 2 ++ 3 files changed, 27 insertions(+) diff --git a/mozilla/modules/libreg/xpcom/nsRegistry.cpp b/mozilla/modules/libreg/xpcom/nsRegistry.cpp index be08a055a6d..dfadd8f9b8b 100644 --- a/mozilla/modules/libreg/xpcom/nsRegistry.cpp +++ b/mozilla/modules/libreg/xpcom/nsRegistry.cpp @@ -814,7 +814,9 @@ NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result // Make sure we have a place for the result. if( result ) { // Get key. + PR_Lock(mregLock); mErr = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result ); + PR_Unlock(mregLock); // Convert result. rv = regerr2nsresult( mErr ); } else { diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 8920c019494..483fd06fb08 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -875,7 +875,18 @@ nsComponentManagerImpl::FindFactory(const nsCID &aClass, { PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("\t\tnot found in factory cache. Looking in registry")); + + // bug# 7308 , bug# 8150 + // Findfactory randomly fails if a ProgIDToCLSID() happenes + // at the same time from another thread. + // The registry seems to be locking properly. Until I figureout + // what the right problem is, I am putting this major locks on + // these two routines + // PlatformFind() and PlatformProgIDToCLSID() + //to achieve mutual exclusion at a course level. + PR_EnterMonitor(mMon); nsresult rv = PlatformFind(aClass, &entry); + PR_ExitMonitor(mMon); // If we got one, cache it in our hashtable if (NS_SUCCEEDED(rv)) @@ -957,7 +968,19 @@ nsComponentManagerImpl::ProgIDToCLSID(const char *aProgID, nsCID *aClass) else { // This is the first time someone has asked for this // ProgID. Go to the registry to find the CID. + + // bug# 7308 , bug# 8150 + // Findfactory randomly fails if a ProgIDToCLSID() happenes + // at the same time from another thread. + // The registry seems to be locking properly. Until I figureout + // what the right problem is, I am putting this major locks on + // these two routines + // PlatformFind() and PlatformProgIDToCLSID() + //to achieve mutual exclusion at a course level. + PR_EnterMonitor(mMon); res = PlatformProgIDToCLSID(aProgID, aClass); + PR_ExitMonitor(mMon); + if (NS_SUCCEEDED(res)) { // Found it. So put it into the cache. diff --git a/mozilla/xpcom/components/nsRegistry.cpp b/mozilla/xpcom/components/nsRegistry.cpp index be08a055a6d..dfadd8f9b8b 100644 --- a/mozilla/xpcom/components/nsRegistry.cpp +++ b/mozilla/xpcom/components/nsRegistry.cpp @@ -814,7 +814,9 @@ NS_IMETHODIMP nsRegistry::GetSubtree( Key baseKey, const char *path, Key *result // Make sure we have a place for the result. if( result ) { // Get key. + PR_Lock(mregLock); mErr = NR_RegGetKey( mReg,(RKEY)baseKey,(char*)path,(RKEY*)result ); + PR_Unlock(mregLock); // Convert result. rv = regerr2nsresult( mErr ); } else {