RE: [xml] Windows threading issues



Igor Zlatkovic wrote:
IIS is notorious for its threading. I have seen it before, 
unloading DLL 
code from memory with a dozen threads still sleeping. When 
one of these then 
wakes up, the OS scheduler will load the CPU registers with 
the context of 
that thread and the instruction pointer will point into the blight.

An IIS extension may therefore never create threads.
That's a bit strong. An extension may create threads, as long as it ensures
they terminate before IIS unloads the extension. Suppose libxml created a
watchdog thread that waited for an event rather than a thread, and
xmlCleanupThreads() signaled that event. As long as xmlCleanupThreads() was
called in an appropriate place (like ExitInstance()), the thread would
resume while its code was still loaded. xmlCleanupThreads() would need to
wait for the watchdog thread to terminate, as it might otherwise get
unloaded before terminating.

It looks to me like libxml is not presently designed to work as a
library
statically linked into a DLL. 
No, rather Windows thread API wasn't designed for usage in a 
module which 
doesn't control thread creation and termination, be it a 
static library, 
dynamic library, whatever.
A valid point, but in a pragmatic sense, it doesn't matter. Either way, I
can't use a statically linked libxml in an ISAPI extension without modifying
it or determining what synchronization is necessary and handling it myself.

In the core of the problem, you must stop libxml from creating extra 
threads. When thread-enabled, libxml needs to associate a TSD 
key with each 
IIS's thread which calls into libxml. If you have a way to 
free this TSD key 
without creating an extra thread, then that is your solution. 
Possible ways are:
   1) Link dynamically to libxml.
   2) Make a thread-disabled libxml and do the sync from within your 
extension code, if needed at all.
I think I'll check out Eugene's patch. If it doesn't work for me, I'll look
into the options you suggest.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]