Re: [xml] returning existing handler in xmlNewCharEncodingHandler

Daniel Veillard wrote:

On Tue, Feb 10, 2004 at 11:50:02AM +0100, oliverst online de wrote:

patch against encoding.c version 1.77 as discussed with Igor on the list


    * Check for existing handler
   handler = xmlFindCharEncodingHandler(name);

   if (handler != NULL)


So long

  Hum, I might disagree with Igor on this, but it seems to me that
it might be better to call xmlFindCharEncodingHandler() before
calling xmlNewCharEncodingHandler(), rather than changing the semantic
of the existing call. In any case in a multithreaded program it seems
to me that you need to ensure some critical section when changing the
default handlers for an encoding. Usually this is best done at program
startup, but I may have missed something, sorry I couldn't participate
to last week discussion, but after rereading the archive I'm not sure
changing the behaviour is the best thing to do.

I agreed to the patch for the following reason.

The patch will change the behaviour of xmlNewCharEncodingHandler(), but not that of xmlFindCharEncodingHandler(). The idea was to prevent the registration of more than one handler for the same encoding name. That because only the handler which was registered first can ever be found by xmlFindCharEncodingHandler(). That's the whole reason, it has nothing to do with multithreading and related problems.

This of course cannot hold if there is code which relies on what xmlNewCharEncodingHandler() returns and does not use xmlFindCharEncodingHandler(). But the API suggests not to be used that way for the reasons above.

At the very end, I don't care particularily about that patch, it won't change anything for me. If it really breaks something somewhere, then better not to apply it.


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