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 /scripts/create_c_api_projections.py | |
| 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 'scripts/create_c_api_projections.py')
| -rwxr-xr-x | scripts/create_c_api_projections.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/create_c_api_projections.py b/scripts/create_c_api_projections.py index a56e99b3..a551469d 100755 --- a/scripts/create_c_api_projections.py +++ b/scripts/create_c_api_projections.py @@ -137,6 +137,7 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(" * Angular parameters are expressed in (angUnitName, angUnitConvFactor).\n") cppfile.write(" */\n") cppfile.write("PJ_OBJ* " + decl + "{\n"); + cppfile.write(" SANITIZE_CTX(ctx);\n"); cppfile.write(" try {\n"); if has_linear: cppfile.write(" UnitOfMeasure linearUnit(createLinearUnit(linearUnitName, linearUnitConvFactor));\n") @@ -156,7 +157,7 @@ for sectiondef in compounddef.iter('sectiondef'): cppfile.write(", Scale(" + param[1] + ")") cppfile.write(");\n") - cppfile.write(" return proj_obj_create_conversion(ctx, conv);\n") + cppfile.write(" return proj_obj_create_conversion(conv);\n") cppfile.write(" } catch (const std::exception &e) {\n"); cppfile.write(" proj_log_error(ctx, __FUNCTION__, e.what());\n") cppfile.write(" }\n") |
