|
From: Christophe de V. <cde...@al...> - 2005-06-13 08:26:01
|
Le Dimanche 5 Juin 2005 20:29, Thomas Jarosch a =E9crit=A0:
> 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 wi=
th=20
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=20
libxml++ or a conflit between php and libxml++ which are not able to 'share=
'=20
their use of libxml2.
Moreover such a test ( checking to every constructor if the library was=20
already initialized) is basically what's being done by the static Init=20
instance. We could maybe add some checks in the Init constructor but I don'=
t=20
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 us=
er=20
being obliged to call the init/deinit functions) based on a compile-time=20
option is a good idea. Anyway if the problem really comes from here you can=
=20
try and patch libxml++ to see if it's fixing you problems.
Regards,
Christophe
|