[Gdal-dev] GDAL reentrancy issue

Marek Brudka mbrudka at aster.pl
Mon Nov 20 13:10:52 EST 2006

Hi Mir,
Mir Hassan Ali wrote:
> I am building a small web application in C# that uses a custom 
> assembly(dll) which in-turn uses the C# wrappers for gdal to read the 
> .shp files (only read not write).
> My question is, since OGR/GDAL is not reentrant (this is what I assume 
> after reading the post 
> http://lists.maptools.org/pipermail/gdal-dev/2006-September/010160.html 
> <http://lists.maptools.org/pipermail/gdal-dev/2006-September/010160.html>), 
> is it going to cause any problems to the web application as obviously 
> multiple users will be using the applications at the same time.
It depends on the architecture of this web application. If the 
application is launched per HTTP connection (simple CGI) then it really 
doesn't matter if OGR is or is not thread safe. But if the application 
is a service with pool of threads or even with thread per connection 
model, then you should expect problems.

The simple patch is "one mutex to rule them all" (tm),  namely before 
each call to the custom assembly you mentioned above the mutex should be 
locked. However, if you need more concurrent and really faster solution 
you should be prepared to modify OGR..

Marek Brudka

More information about the Gdal-dev mailing list