Re: [xml] Thread safety of libXML2?

On Thu, Oct 26, 2006 at 04:33:49PM -0500, David Hagood wrote:
Assume that I have a single xmlSaveCtxtPtr that has been created, and is
visible to multiple threads within a program.

Assume that I have multiple threads creating multiple document fragments
(separate xmlNodePtr objects, one per thread), using various xmlNewChild
and the like calls. Assume that only one thread manipulates any given

Is the call to xmlSaveTree intrinsically thread safe, or do I have to do
my thread protection outside of xmlSaveTree?

  One context per thread like for parsing contexts. Multiple threads
accessing the same xmlSaveCtxtPtr won't be synchronized by libxml2, it will
fail at some point. You need to add your own locking on top.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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