Re: [xml] Some things about xmlCharEncodingHandler

Oliver Stöneberg wrote:

Might this cause some problems, if you just change the callbacks
while libxml2 might be in use? I am not sure how it is protected or
sync'd internally. Because if somebody is using the handler while you
change it might use the first callback, which still be the old one
and then the second callback, which is already the new one. Would be
a bad thing IMO.

While somebody is using it? Who is somebody? When your program loads
libxml, its data belong to your program's address space. There can never
be another who uses that. Any other process has its own address space
and its own instance of libxml data.

OK, "somebody" is the wrong wording. I meant another thread in a
multi-threaded enviroment. As the handler are global and when I
change one handler with a class, that creates XMLs and saves and at
the same time there is another thread, that is using the libxml2 to
just simply parse an existing document. IMO that might affect the XML
output or parsing result depending on what handler you modify. If you
just modify your own handler, that isn't registered by default it
should not have big impact, because it's quite under your control.
But if you e.g. overwite the UTF-8 handler while some other thread is
using it, the scenario about using one old and one new callback could
happen. Or are the handlers global in the thread-safe data? IIRC they
aren't because I already ran into the problem of handler being
cleared and causing exceptions, because another thread was still
working (OK, that was caused because of bad implementation)

So long

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