[gdal-dev] [#3824][RFC] Introduce portable DllMain callback to DLL binary

Mateusz Loskot mateusz at loskot.net
Thu Nov 11 19:00:53 EST 2010

On 11/11/10 23:46, Even Rouault wrote:
> Mateusz,
> It looks good. Just minor comments :
> 1) The commented //CPLCleanupTLS();  in the GCC specific code is indeed 
> unneeded since both GDALDestroyDriverManager() and OGRCleanupAll() call it. 


I missed this detail.

> Well, it could be usefull if people only used CPL services without registering 
> any GDAL/OGR drivers, but I'm not sure that is a use case we should try to 
> cover.

Yes, I think you are right and there is little point to cover it.

> 2) The code inside #ifdef _MSC_VER could in theory work with any other 
> compiler for windows, for example MINGW. But as MINGW is also GCC, I'm not 
> sure which version is the prefered one ( provided that the +ming 
> ((constructor)) stuff actually works with MINGW ... ). Anyway the current 
> situation is safe

I'm not MinGW user, so I have no idea really.

> 3) The CPLCleanupTLS() call in the DLL_THREAD_DETACH is only necessary for 
> threads not created by CPLCreateThread(), since the jacket function already 
> calls it at its end. But calling it twice won't hurt.

It is the case, so I'd like to keep the CPLCleanupTLS there.
Though, as it's multi-threading, I wouldn't bet my head for that it's
100% bulletproof, though I've been already using this approach and
haven't found any problems so far.

> So all in all, the code seems OK to me as it.

Big thanks for review and comments.

Best regards,
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org

More information about the gdal-dev mailing list