Re: [xml] FW: Re: make libxml2 slightly more thread-friendly



On Fri, Apr 27, 2007 at 12:10:53AM +0300, Vlad Gusev wrote:
Dear Daniel,

Honestly, I spent no time to check my problems with libxml2 in the bug list
properly
and found the only close topic in
<http://mail.gnome.org/archives/xml/2007-February/msg00064.html>
http://mail.gnome.org/archives/xml/2007-February/msg00064.html.

Let me shortly explain the problem. Look, please, at the code sequence
starting from xmlReadFile:

xmlReadFile  
    xmlCreateURLParserCtxt
        xmlNewParserCtxt
            xmlInitParserCtxt
                xmlDefaultSAXHandlerInit
    xmlDoRead
        xmlParseDocument
            xmlInitParser
                xmlInitThreads
                    InitializeCriticalSection(&cleanup_helpers_cs)
                xmlDefaultSAXHandlerInit
...etc...
 
Thus, there are two calls of xmlDefaultSAXHandlerInit causing in its turn:
 
xmlDefaultSAXHandlerInit 
    __htmlDefaultSAXHandler
        xmlGetGlobalState
            EnterCriticalSection(&cleanup_helpers_cs)
 
under condition of not main thread. That is the first call of
xmlDefaultSAXHandlerInit can access the critical section
with no initializing it while the second one is ok.

  Have you read the associated doc ?
    http://xmlsoft.org/threads.html 

 call xmlInitParser() in the "main" thread before using any of the libxml2 API 
and especially before calling xmlReadFile, the critical section should then be
initialized.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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