Re: [xml] side effects of thread-enabling libxml2

On Sun, May 04, 2003 at 06:05:21PM +0200, Stéphane Bidoul wrote:
Daniel Veillard wrote:
Basically what you're asking for is the possibility to set up
the global variable default used to initialize the values inherited
from new threads, and that would be sufficient, right ? I doubt you
actually want to change the global variable dynamically in the 
various threads running at a given point in time.
 Seems to me that making the affectation in the "main thread" is one
way to do this. The other option is to generate xmlSetGlobalXXX()
funtions, which should be realtively easy to do within globals.c


The concept of "main thread" is unclear to me (running being mod_python 
and apache,
I don't control thread creation). Is the main thread the one that loads 
the library,
or the first one calling into libxml? [the patch I proposed to for win32 
assume it's the thread loading the library]

  It's the thread which initialized the library, right ...

And currently, per-thread globals don't inherit the values set in the 
main thread.

  Hum, right... maybe that should be changed, see
The problem then is that xmlInitializeGlobalState() should take
a lock if it's peeking in the main thread global variables I think.
What do you think of a flag controlling the use of per-thread globals at 
It could be something like xmlSet/GetPerThreadGlobalsEnabled();
And entries in global.c could read like

#undef    xmlGenericError
xmlGenericErrorFunc *
__xmlGenericError(void) {
    if (!perThreadGlobalsEnabled || IS_MAIN_THREAD)
    return (&xmlGenericError);
    return (&xmlGetGlobalState()->xmlGenericError);

  Sounds too heavy. I would prefer something per-variable, though
I understand that from your point of view it would garantee the same
behaviour at minimal costs. I'm not strongly sided, if other users of
the thread features could voice their concern/preferences this would
help ...


Daniel Veillard      | Red Hat Network
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]