Re: [xml] xmlCleanupParser() question / patch
- From: "Martin B." <0xCDCDCDCD gmx at>
- To: xml gnome org
- Subject: Re: [xml] xmlCleanupParser() question / patch
- Date: Tue, 19 Jan 2010 19:21:12 +0100
Daniel Veillard wrote:
On Tue, Jan 19, 2010 at 07:54:20AM -0700, James Hart wrote:
(....)
For example, in our system we have specifically used a RAII design
pattern so multiple libraries can access libxml and the initialization
and cleanup of the library is handled by a reference counting systems
because we have no control of the order these libraries will be loaded
in our system. The goal we have is to completely unload and cleanup
the library when there are no libraries requiring it's use anymore and
to reload it if a library requires it again. If the API changes
functionality, yet is link compatible it is very possible the change
you proposed will go unnoticed for some time.
suffice one of the shared library used by your system start using
libxml2 under the hood, say to parse a configuration file, suddenly
everything breaks. The problem is that this is safe to call only in a
fully controlled environment, for example in xmllint .
Hmm ... but this point of view would mean that the whole mechanism for
this function is bad for a shared-lib environment, no matter how it's
called.
So I could think of this:
* xmlInitParser() and xmlCleanupParser() get deprecated (via the various
compiler specific attributes)
* xmlInitParser() is left the same as now
* xmlCleanupParser() is made a noop
* New Functions xmlInitLibrary() and xmlCleanupLibrary() that have one
additional treat: They maintain a counter, so that each call to
xmlInitLibrary() must be matched by a call to xmlCleanupLibrary() and
only if the counter reaches zero in the cleanup function is the cleanup
actually performed. This way the shared lib problem would go away if all
shared libs are well-behaved.
Would this make sense?
br,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]