Re: [xml] [Q] libxml-2.2.2.3 Thread Safe ?

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Wed Sep 27 2000 - 14:53:09 EDT


On Wed, Sep 27, 2000 at 02:17:32PM -0400, Marc Sanfacon wrote:
>
> Hi there,
> I am using libxml-2.2.2.3 under Windows 2000, with VC 6.0. I have
> written a small test that creates 5 threads and calls the following
> functions of libxml:
>
> - htmlCreateFileParserCtxt
> - htmlParseDocument
> - htmlFreeParserCtxt
> - MyPrintFunction: Print out the result in a file.
>
> Before creating the threads, I execute the test in a single-threaded
> environment to get the output file that will be used to compare the results
> of the threaded parsing.
>
> I have tried to put a mutex (that locks the parser, so it can parser only
> one file at a time) in all possible places, here are the results:
>
> 1- Works fine
> {Mutex - htmlCreateFileParserCtxt
> - htmlParseDocument
> - htmlFreeParserCtxt
> - MyPrintFunction: Print out the result in a file.
> }
>
> 2- Works fine
> {Mutex - htmlCreateFileParserCtxt
> - htmlParseDocument
> - htmlFreeParserCtxt
> }
> - MyPrintFunction: Print out the result in a file.
>
> 3- Works fine
> {Mutex - htmlCreateFileParserCtxt
> - htmlParseDocument
> }
> - htmlFreeParserCtxt
> - MyPrintFunction: Print out the result in a file.
>
> 4- Works fine
> - htmlCreateFileParserCtxt
> {Mutex - htmlParseDocument
> }
> - htmlFreeParserCtxt
> - MyPrintFunction: Print out the result in a file.
>
> 5- Does not work
> NO MUTEX
> - htmlCreateFileParserCtxt
> - htmlParseDocument
> - htmlFreeParserCtxt
> - MyPrintFunction: Print out the result in a file.
>
> Since 'htmlParseDocument' and 'xmlParseDocument' are the functions that does
> the main job, anybody that can point me out where the problem might come
> from ?
>
> I have begun to trace the code, but there are lots of code, so any pointer
> would be really appreciated.

  Hummm interesting
  parser functions uses the parsing context for their informations
Since it's HTML parsing the entites stuff should not give problems.
You should try to focuse on the global variables, they are likely to
come from HTMLparser.c parserInternals.c or the xmlIO.c modules ...
There should have that many.

  Good luck, those kind of bug chaing are hard :-(, tell us what you
find and on't hesitate to ask for more informations ... I would really
like this bug to be found because I have tried to design it to be
thread safe at least at parsing time.

  Check that the allocation/feeing functions a re thread safe, if needed
override them with thread-safe routines (there is a function for this
exported in xmlmemory.h).

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Sep 27 2000 - 15:43:16 EDT