RE: [xml] xmlInitParser/xmlCleanupParser

I see you point, but as is it's not suitable for me...

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Monday, August 25, 2003 2:01 AM
To: maksim likharev com
Cc: xml gnome org
Subject: Re: [xml] xmlInitParser/xmlCleanupParser

On Mon, Aug 25, 2003 at 12:41:33AM -0700, maksim likharev com wrote:
So really when I init parser it set xmlParserInitialized flag and eats
next attempts to initialize,


For cleanup it checks xmlParserInitialized, and clean up global state,


But problem is for some sort of addins  ( modules that do not know
they loaded/unloaded ) as well as 

COM like DLLs ( Win32 ), it is highly possible to call
xmlInitParser/xmlCleanupParser several times,

and without any order, so call of xmlInitParser in one thread might be
corresponding to call xmlCleanupParser in other thread

which effectively screws everything up. 

Proposal is following, use reference count instead, like increment it
every time  xmlInitParser called and init only during first attempt,

And decrement it on every xmlCleanupParser call and cleanup only
last call.

  I don't like this for the very simple reason that it changes the
semantic of those two calls. This may solve your problem but will
as well generate troubles for those relying on the fact that 
xmlInitParser() call is idempotent in case it already was initialized.
An that may break simpler code, without dynamic loading or threading
or any of the complex interactions you seems to have. Even
internal code has been designed that way and may actually call
xmlInitParser() multiple times, which means that the subsequent
xmlCleanupParser() will not free the memory. No it's really a too
serious breakage of API to be considered.

  If you need a special semantic, I really don't see why you can't put
the global semaphore in your program and call both routines only 
when appropriate. Why put the special semantic within libxml2 itself ?


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]