2016.11.16 12:04 "Re: [Tiff] Global variables in LibTIFF", by Gerben Vos
Why is the context named? It smells like magic behavior at a distance (even though it doesn't seem to be) that the name of the context and the opened tiff are the same.
I did a thread-safety analysis a few years ago, but did not contact the mailing list about it. My implementation ideas for fixing those were more among the lines of those in the patch attached to http://bugzilla.maptools.org/show_bug.cgi?id=2255, except that I thought of calling the context object with the formerly global variables a TIFFContext instead of a TIFFApplication. There would then be a default context (that would still be the, only, global variable) that would be used by code that didn’t create their own context. I don't have an implementation, though.
Here are the main notes from my thread-safety analysis at that time (September 2014; I think it was for libtiff 4.0.3):
- TIFFSetErrorHandler/TIFFSetErrorHandlerExt/TIFFError/TIFFErrorExt: TIFFErrorHandlerExt _TIFFerrorHandlerExt; TIFFErrorHandler _TIFFerrorHandler;
- TIFFSetWarningHandler/TIFFSetWarningHandlerExt/TIFFWarning/TIFFWarningExt: TIFFErrorHandlerExt _TIFFwarningHandlerExt; TIFFErrorHandler _TIFFwarningHandler;
- TIFFSetTagExtender/TIFFDefaultDirectory: static TIFFExtendProc _TIFFextender;
- TIFFRegisterCODEC/TIFFUnRegisterCODEC: static codec_t* registeredCODECS; (linked list)
- TIFFFindCODEC/TIFFIsCODECConfigured/TIFFGetConfiguredCODECs: static codec_t* registeredCODECS; (linked list)
- TIFFPrintDirectory: static uint16 dotrange;
- oog_encode: static int oog_table[NANGLES]; static int initialized = 0;
- PixarLogMakeTables/PixarLogEncode: static float Fltsize; static float LogK1, LogK2;
Note that there are also a few static variables whose initialization might be a problem in a multithreaded environment, although they always initialize the same data every time.
DISCLAIMER: This e-mail and any attachments are intended only for the individual or company to which it is addressed and may contain information which is privileged, confidential and prohibited from disclosure or unauthorized use under applicable law. If you are not the intended recipient of this e-mail, you are hereby notified, any use, dissemination, or copying of this e-mail or the information contained in this e-mail is strictly prohibited by the sender. If you have received this transmission in error, please return the material received to the sender and delete all copies from your system. This email has been scanned by the Email Security.cloud service.