Bug 239875 - fix xpconnect static guards so we can restart xpcom without crashing r=shaver sr=brendan
git-svn-id: svn://10.0.0.236/trunk@158170 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6cd2f70378
commit
f9f20186ed
@ -1127,6 +1127,11 @@ public:
|
||||
class XPCIDispatchExtension
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Reset the enabled flag if xpconnect is re-initialized.
|
||||
*/
|
||||
static void InitStatics() { mIsEnabled = PR_TRUE; }
|
||||
|
||||
/**
|
||||
* returns true if IDispatch extension is enabled
|
||||
* @return true if IDispatch extension is enabled
|
||||
|
||||
@ -390,6 +390,7 @@ nsXPCException::ToString(char **_retval)
|
||||
return final ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
JSBool nsXPCException::sEverMadeOneFromFactory = JS_FALSE;
|
||||
|
||||
// static
|
||||
nsresult
|
||||
@ -406,12 +407,11 @@ nsXPCException::NewException(const char *aMessage,
|
||||
// This is bad because it means that wrapped exceptions will never have a
|
||||
// shared prototype. So... We force one to be created via the factory
|
||||
// *once* and then go about our business.
|
||||
static JSBool everMadeOneFromFactory = JS_FALSE;
|
||||
if(!everMadeOneFromFactory)
|
||||
if(!sEverMadeOneFromFactory)
|
||||
{
|
||||
nsCOMPtr<nsIXPCException> e =
|
||||
do_CreateInstance(XPC_EXCEPTION_CONTRACTID);
|
||||
everMadeOneFromFactory = JS_TRUE;
|
||||
sEverMadeOneFromFactory = JS_TRUE;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@ -292,7 +292,6 @@ NS_METHOD GetSharedScriptableHelperForJSIID(PRUint32 language,
|
||||
|
||||
/******************************************************/
|
||||
|
||||
static JSBool gClassObjectsWereKilled = JS_FALSE;
|
||||
static JSBool gClassObjectsWereInited = JS_FALSE;
|
||||
|
||||
NS_DECL_CI_INTERFACE_GETTER(nsJSIID)
|
||||
@ -318,8 +317,6 @@ static const nsModuleComponentInfo CI_nsJSCID =
|
||||
|
||||
JSBool xpc_InitJSxIDClassObjects()
|
||||
{
|
||||
if(gClassObjectsWereKilled)
|
||||
return JS_FALSE;
|
||||
if(gClassObjectsWereInited)
|
||||
return JS_TRUE;
|
||||
|
||||
@ -366,7 +363,7 @@ void xpc_DestroyJSxIDClassObjects()
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSCID));
|
||||
NS_IF_RELEASE(gSharedScriptableHelperForJSIID);
|
||||
|
||||
gClassObjectsWereKilled = JS_TRUE;
|
||||
gClassObjectsWereInited = JS_FALSE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -744,6 +744,8 @@ XPCJSRuntime::~XPCJSRuntime()
|
||||
}
|
||||
|
||||
XPCConvert::RemoveXPCOMUCStringFinalizer();
|
||||
|
||||
gOldJSGCCallback = NULL;
|
||||
}
|
||||
|
||||
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect,
|
||||
|
||||
@ -105,6 +105,23 @@ static const nsModuleComponentInfo components[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
xpcModuleCtor(nsIModule* self)
|
||||
{
|
||||
nsXPConnect::InitStatics();
|
||||
nsXPCException::InitStatics();
|
||||
XPCWrappedNativeScope::InitStatics();
|
||||
XPCPerThreadData::InitStatics();
|
||||
nsJSRuntimeServiceImpl::InitStatics();
|
||||
nsXPCThreadJSContextStackImpl::InitStatics();
|
||||
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
XPCIDispatchExtension::InitStatics();
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
xpcModuleDtor(nsIModule* self)
|
||||
{
|
||||
@ -119,4 +136,4 @@ xpcModuleDtor(nsIModule* self)
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR(xpconnect, components, xpcModuleDtor)
|
||||
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(xpconnect, components, xpcModuleCtor, xpcModuleDtor)
|
||||
|
||||
@ -426,6 +426,8 @@ public:
|
||||
// NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR
|
||||
static nsXPConnect* GetSingleton();
|
||||
|
||||
// Called by module code in dll startup
|
||||
static void InitStatics() { gSelf = nsnull; gOnceAliveNowDead = JS_FALSE; }
|
||||
// Called by module code on dll shutdown.
|
||||
static void ReleaseXPConnectSingleton();
|
||||
|
||||
@ -1042,6 +1044,8 @@ public:
|
||||
void SetComponents(nsXPCComponents* aComponents);
|
||||
void SetGlobal(XPCCallContext& ccx, JSObject* aGlobal);
|
||||
|
||||
static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; }
|
||||
|
||||
protected:
|
||||
XPCWrappedNativeScope(XPCCallContext& ccx, JSObject* aGlobal);
|
||||
virtual ~XPCWrappedNativeScope();
|
||||
@ -2447,6 +2451,8 @@ public:
|
||||
nsXPCException();
|
||||
virtual ~nsXPCException();
|
||||
|
||||
static void InitStatics() { sEverMadeOneFromFactory = JS_FALSE; }
|
||||
|
||||
protected:
|
||||
void Reset();
|
||||
private:
|
||||
@ -2459,6 +2465,8 @@ private:
|
||||
int mLineNumber;
|
||||
nsIException* mInner;
|
||||
PRBool mInitialized;
|
||||
|
||||
static JSBool sEverMadeOneFromFactory;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
@ -2594,6 +2602,8 @@ private:
|
||||
/**************************************************************/
|
||||
// All of our thread local storage.
|
||||
|
||||
#define BAD_TLS_INDEX ((PRUint32) -1)
|
||||
|
||||
class XPCPerThreadData
|
||||
{
|
||||
public:
|
||||
@ -2687,6 +2697,9 @@ public:
|
||||
void MarkAutoRootsBeforeJSFinalize(JSContext* cx);
|
||||
void MarkAutoRootsAfterJSFinalize();
|
||||
|
||||
static void InitStatics()
|
||||
{ gLock = nsnull; gThreads = nsnull; gTLSIndex = BAD_TLS_INDEX; }
|
||||
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
JSUint32 IncrementWrappedNativeThreadsafetyReportDepth()
|
||||
{return ++mWrappedNativeThreadsafetyReportDepth;}
|
||||
@ -2740,6 +2753,7 @@ public:
|
||||
// NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR
|
||||
static nsXPCThreadJSContextStackImpl* GetSingleton();
|
||||
|
||||
static void InitStatics() { gXPCThreadJSContextStack = nsnull; }
|
||||
static void FreeSingleton();
|
||||
|
||||
nsXPCThreadJSContextStackImpl();
|
||||
@ -2749,6 +2763,8 @@ private:
|
||||
XPCJSContextStack* GetStackForCurrentThread()
|
||||
{XPCPerThreadData* data = XPCPerThreadData::GetData();
|
||||
return data ? data->GetJSContextStack() : nsnull;}
|
||||
|
||||
static nsXPCThreadJSContextStackImpl* gXPCThreadJSContextStack;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
@ -2772,8 +2788,11 @@ class nsJSRuntimeServiceImpl : public nsIJSRuntimeService,
|
||||
|
||||
nsJSRuntimeServiceImpl();
|
||||
virtual ~nsJSRuntimeServiceImpl();
|
||||
|
||||
static void InitStatics() { gJSRuntimeService = nsnull; }
|
||||
protected:
|
||||
JSRuntime *mRuntime;
|
||||
static nsJSRuntimeServiceImpl* gJSRuntimeService;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -69,7 +69,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsJSRuntimeServiceImpl,
|
||||
nsIJSRuntimeService,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
static nsJSRuntimeServiceImpl* gJSRuntimeService = nsnull;
|
||||
nsJSRuntimeServiceImpl*
|
||||
nsJSRuntimeServiceImpl::gJSRuntimeService = nsnull;
|
||||
|
||||
nsJSRuntimeServiceImpl*
|
||||
nsJSRuntimeServiceImpl::GetSingleton()
|
||||
|
||||
@ -209,7 +209,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsXPCThreadJSContextStackImpl,
|
||||
nsIJSContextStack,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
static nsXPCThreadJSContextStackImpl* gXPCThreadJSContextStack = nsnull;
|
||||
nsXPCThreadJSContextStackImpl*
|
||||
nsXPCThreadJSContextStackImpl::gXPCThreadJSContextStack = nsnull;
|
||||
|
||||
nsXPCThreadJSContextStackImpl::nsXPCThreadJSContextStackImpl()
|
||||
{
|
||||
@ -345,8 +346,6 @@ nsXPCThreadJSContextStackImpl::SetSafeJSContext(JSContext * aSafeJSContext)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static const PRUintn BAD_TLS_INDEX = (PRUintn) -1;
|
||||
|
||||
PRUintn XPCPerThreadData::gTLSIndex = BAD_TLS_INDEX;
|
||||
PRLock* XPCPerThreadData::gLock = nsnull;
|
||||
XPCPerThreadData* XPCPerThreadData::gThreads = nsnull;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user