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

Even Rouault even.rouault at mines-paris.org
Thu Nov 11 18:46:15 EST 2010


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. 
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.
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 __attribute__ 
((constructor)) stuff actually works with MINGW ... ). Anyway the current 
situation is safe
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.

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

Le jeudi 11 novembre 2010 23:42:39, Mateusz Loskot a écrit :
> Hi,
> 
> I have proposed implementation of entry and exit points for GDAL shared
> library. Initially, it was Windows-specific DllMain callback, but later
> I found it may be possible to use GCC extensions implement similar
> behaviour for Linux (Unix?) system. Here is the related ticket:
> 
> http://trac.osgeo.org/gdal/ticket/3824
> 
> 
> The main motivation is to sanitize the run-time environment and
> perform all necessary clean-up during GDAL library unload,
> so it does not leave any resources (memory) unreleased.
> 
> Frank suggested to discuss this idea on the list, so here we go
> and I'm looking forward to hearing your comments.
> 
> Best regards,


More information about the gdal-dev mailing list