[Gdal-dev] Is OGR reentrant?

Frank Warmerdam warmerdam at pobox.com
Fri Sep 22 19:13:56 EDT 2006


ugeni79 at gmail.com wrote:
> Given that OGR is not reentrant and is not thread safe, is there any way 
> I can get OgrDatasources to work for concurrent reading from different 
> threads? or is ot my only choice to spin off a separate process for each 
> of the data sources?

Eugene,

I would say that OGR has not been reviewed for threadsafety, though I
am not aware of problems with threadsafety in OGR off hand.  Of course,
with it never having been through a careful review there are likely to
be a few problems.

If you really really want concurrent reading (as opposed to syncronized
reading sliced amoung several threads), you would pretty much have to
use separate processes *or* review and fix thread safety issues in OGR
yourself.

> Marek,
> I have no need for OGR to be thread safe, since I would prefer to have 
> each of my threads to instantiate its own OGR objects, therefore they 
> would not need to be protected from simultaneous access.  Are you saying 
> that it is the limitations of PROJ.4 that make OGR not reentrant thus 
> causing my problem?
> Please forgive my ignorance, I am just not that familiar with the code...

I'm aware of two main issues with PROJ.4.  One was the static "start"
variable used by pj_init(), which I have just fixed.  And the other is
related to maintaining the grid shift file list (managed via a static
buffer) which I would claim has a low risk of actually failing.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list