nsresult NS_COM NS_InitXPCOM2(const char* productName,
nsIServiceManager* *result,
nsIFile* binDirectory
)
{ ....
rv = nsIThread::SetMainThread(); <- set gMainThread to current thread.
nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr)
{
.......
nsThread::Shutdown(); <- This calls exit on current thread. This
causes a double call to exit when XPCOM is running in a child thread; which
also calls exit on clean up.
nsThread::Shutdown()
{
if (gMainThread) <- should rather check that gMainThread is equal to
main thread.
{
// XXX nspr doesn't seem to be calling the main thread's destructor
// callback, so let's help it out:
nsThread::Exit(NS_STATIC_CAST(nsThread*, gMainThread));
nsrefcnt cnt;
NS_RELEASE2(gMainThread, cnt);
NS_WARN_IF_FALSE(cnt == 0, "Main thread being held past XPCOM
shutdown.");
}
}
needs to verfiy that g