Re: [xml] register i/o callback functionality



Rob Richards wrote:
From: Mike Hommey


Well, let's take a simple case :
One module wants to format output with indentation.
Another wants to format output without.
So, the first sets xmlIndentTreeOutput to 1, and then calls
xmlDumpFormatMemory.
The second sets xmlIndentTreeOutput to 0, and then calls
xmlDumpFormatMemory.
When the two of them are not called "simulteanously", this is not a
problem. But now imagine this multithreaded scenario :
second module sets xmlIndentTreeOutput to 0
first module sets xmlIndentTreeOuput to 1
first module outputs
second module outputs
Well, it seems to me that the second module has made an indented output
while not expected to...


You should look at globals.h/c (particularly the xmlInitializeGlobalState
function for a list of handled vars/functions). This will show you how your
scenario would be handled (each thread would be able to handle its own state
without interfering with other threads).

Mmmmm interesting. Thanks for the tip.

Mike



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