diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-11-30 02:36:00 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-11-30 02:43:57 +0100 |
| commit | 664bd689bf8dd3ca38a5071459902b89114e88eb (patch) | |
| tree | 88db8dd01621321635c2ea4bc8782dbdc9305e14 /src/proj_4D_api.c | |
| parent | 28d69400b04eb683bfccb3e7d3ad8a054ad73897 (diff) | |
| download | PROJ-664bd689bf8dd3ca38a5071459902b89114e88eb.tar.gz PROJ-664bd689bf8dd3ca38a5071459902b89114e88eb.zip | |
C API: do not 'cache' PROJ context in PJ_OBJ objects
We store the PJ_CONTEXT* in the PJ_OBJ objects, but this
might cause issues in multi-threaded uses.
For example, before this change, let's imagie:
- a PJ_OBJ is created in thread A with a PJ_CONTEXT that
is specific to this thread A
- PJ_OBJ is transfered to another thread that operates on
it. It might thus use the PJ_CONTEXT that was TLS(A)
- in the meantime thread A does completely different things,
but still operate on its PJ_CONTEXT. We might get a
concurrent use of the PJ_CONTEXT despite working on
different PJ_OBJ
Another situation is when using constructor functions that
take two PJ_OBJ. Up to now, we arbitrarily selected the context
of one of the arguments to attach it to the new object.
So better be explicit on which context is used.
For reference, in those wrappers of the C++ API, the
context is mostly used for two things:
- reporting C++ exceptions as PROJ errors with the error handler
attached to the PJ_CONTEXT
- using the database handle that is associated with the PJ_CONTEXT.
Diffstat (limited to 'src/proj_4D_api.c')
| -rw-r--r-- | src/proj_4D_api.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c index 6afabcaa..6ba56764 100644 --- a/src/proj_4D_api.c +++ b/src/proj_4D_api.c @@ -771,6 +771,7 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char if( area && area->bbox_set ) { proj_operation_factory_context_set_area_of_interest( + ctx, operation_ctx, area->west_lon_degree, area->south_lat_degree, @@ -779,9 +780,9 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char } proj_operation_factory_context_set_grid_availability_use( - operation_ctx, PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID); + ctx, operation_ctx, PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID); - op_list = proj_obj_create_operations(src, dst, operation_ctx); + op_list = proj_obj_create_operations(ctx, src, dst, operation_ctx); proj_operation_factory_context_unref(operation_ctx); proj_obj_unref(src); @@ -796,13 +797,13 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char return NULL; } - op = proj_obj_list_get(op_list, 0); + op = proj_obj_list_get(ctx, op_list, 0); proj_obj_list_unref(op_list); if( !op ) { return NULL; } - proj_string = proj_obj_as_proj_string(op, PJ_PROJ_5, NULL); + proj_string = proj_obj_as_proj_string(ctx, op, PJ_PROJ_5, NULL); if( !proj_string) { proj_obj_unref(op); return NULL; |
