-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix missing pj_acquire_lock etc. in proj.def #950
Conversation
I don't think this is something we would want. Why would you want to use those locks from outside the library? Note that the header those functions are defined in will soon be removed from the public API. I don't want people to start using those functions and then remove access them to again a short time after it was made available. |
Agreed with @kbevers . Those are proj internal implementation details. |
If you happen to have a projection with a shift grid then the shift grid is loaded on the first projection which calls Manual call of the |
For the POSIX implementation making core_lock_created volatile should help a lot, since this would prevent compiler code re-ordering, and due to all the pthread_() things happening, this should also prevent CPU out-of-order execution. Or we may use pthread_once() For Windows, perhaps InitOnceExecuteOnce() ( https://msdn.microsoft.com/en-us/library/ms683493(VS.85).aspx ) could be asolution |
Do you experience the same behaviour if you also add a context for each thread? |
@kbevers I doubt having a per-thread context will help: grid loading involves global variable (typically |
Could that be moved to the context? If not now maybe in version 7 where we are not restricted by keeping the promises made in |
I guess Re context-per-thread: as mentioned by @rouault, these are global variables. Not to mention that HA! I've probably found workaround for our workaround. projCtx pj_get_default_ctx()
{
pj_acquire_lock(); So, I can call Anyway, fixing the lock creation would be nice. Even providing some global initialization function would be enough. |
That would be a waste of memory and CPU time to have each context load grids. |
Aren't your needs met with /~https://github.com/OSGeo/proj.4/blob/968fcad7ae5064e733978f47d5e93a9baf6a5c46/src/pj_ctx.c#L104-L114 |
Okay. It was actually my impression that was what happen already. Oh well, I am not that familiar with this part of the code. |
Anyway, thanks for help. I'll update our workaround, however it would be nice to have this whole machinery working correctly out of the box. |
So this is really an issue of how GDAL uses PROJ? We can't solve that here but I am sure Even is willing to accept a PR that make things work more smoothly in GDAL. |
GDAL uses a proj context per OGRCoordinateTransformation object. I believe the issue is more in the potentially unsafe lock initialization in proj itself. So either proj needs to improve this internally (preferred way), or offer an initialization function |
@rouault Okay. Do you want to propose a solution for this? Or at least write up an issue that we can return to later? I don't understand the problem well enough to do so myself I am afraid. |
closing that one since we have opened #954 instead |
make functions
pj_acquire_lock, pj_release_lock and pj_cleanup_lock
available to users of the dll on windows builds.