Re: [libxml++] Global initialization code



Le Dimanche 5 Juin 2005 20:29, Thomas Jarosch a écrit :
> Hi,
>

Hi Thomas,

Sorry about the delay...

> libxml++ uses global initialization code like this:
>
> Document::Init::Init()
> {
>    xmlInitParser(); //Not always necessary, but necessary for thread
> safety. xmlRegisterNodeDefault(on_libxml_construct);
>    xmlDeregisterNodeDefault(on_libxml_destruct);
>    xmlThrDefRegisterNodeDefault(on_libxml_construct);
>    xmlThrDefDeregisterNodeDefault(on_libxml_destruct);
> }
>
> Document::Init Document::init_;
>
> We use PHP as apache module and have another module linking libxml++.
> The above piece of code totally breaks PHP's XML parser
> just by loading the second module.

Can you be more precise ? What is broken exactly ?
It the php xml parser is base on libxml2 and use it's callback (as we do with 
libxml++), then I don't think a cohexistence is possible.

>
> Changing the code is not easy as it would break existing applications.
> One possible solution would be to add a check to every constructor if the
> library was already initialized. On the destruction of the last libxml++
> class if would have to be uninitialized.

It's unclear to me if the problem comes from a double-initialisation of 
libxml++ or a conflit between php and libxml++ which are not able to 'share' 
their use of libxml2.
Moreover such a test ( checking to every constructor if the library was 
already initialized) is basically what's being done by the static Init 
instance. We could maybe add some checks in the Init constructor but I don't 
see a case where it's needed : static should do it for us.

> A more clean way would be to have an init()/deinit() function.
> Perhaps the use of this mode could be a compile time option?
>
> Please let me know what you think about this.

I'm unsure about this. I don't think having a different behavior (ie the user 
being obliged to call the init/deinit functions) based on a compile-time 
option is a good idea. Anyway if the problem really comes from here you can 
try and patch libxml++ to see if it's fixing you problems.


Regards,

Christophe

Attachment: pgp5pA0QIK1MT.pgp
Description: PGP signature



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