Scott Collins and Gagan Saksena,
It seems I am hitting brick walls every where I turn as I attempt to use
XPCOM and the Necko engine. Please take a minute to read the rest of this
e-mail so that I might explain.
I am building a DLL which will be using the NECKO engine as its interface to
the internet. The Necko engine is set up with an architechture requiring an
event loop to perform asynchronous reads. My DLL will be plugged into a
larger application with its own event loop. This causes me to spin a thread
for the Necko event loop, so as to not block the application. I first
attempted to Initialize XPCOM in the main thread prior to spawning off my
child thread for the asynch read. However, when my child thread attempted
to create a new URI, it asserted, as the functionality uses services first
created by XPCOM in the main thread; which are not thread safe (ie.
nsCategoryManager). So the next attempt involved initializing XPCOM in the
child thread (this seemed logical as the rest of the application will not
be using any mozilla components). It seems that this case was not thought of
when XPCOM was designed. The init for XPCOM makes calls to
nsIThread::SetMainThread and nsThread::Shutdown(). It is the shutdown that
causes my DLL to fault, as a (unjoinable) child thread already is set up to
clean up after it self.
Scott, Is it reasonable to expect to be able to set up XPCOM in a child
thread, or does XPCOM impose the requirement of being initialized in the
main thread? (if so, the responsibility then falls to the services to be
thread safe.) Bug #54639 is the nsCategoryManager problem. Also, I did not
mention this above, but the nsLoggingService is also not thread safe (Bug
#62097). The logging service is created even before XPCOM is initialized,
and if I initialize XPCOM in a child thread, I assert.
Gagan, Bug #59434 relates to my problem (nsHTTPHandler is not thread safe).
Is this bug on any project plan to be fixed any time soon. Have I over
looked another alternative?
Scott, Gagan So right now I am at an impass. I can not initialize XPCOM
in the main thread (due to NECKO using unsafe thread services), nor can I
initialize XPCOM in the child thread.
I would really appreciate it if we could start a conversation to resolve
this impass.
Kind Regards,
Rick Marvin
software engineer-Neoplanet.