diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2021-10-27 17:54:20 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2021-11-05 14:32:19 +0000 |
commit | 91e29d42a601689f13e9202fc6b582d53901fbc2 (patch) | |
tree | 7a8526c18f050af408749cc587a49a0ca13b1474 /windows | |
parent | 6dd05a013f66a9322f92f62fd2d46be9bfa82097 (diff) | |
download | ghostpdl-91e29d42a601689f13e9202fc6b582d53901fbc2.tar.gz |
Runtime safety of non threadsafe devices and rework globals.
Some devices within Ghostscript (currently the x11 devices,
uniprint and opvp/oprp) use non const static variables, so cannot
be run in multiple instances at a time.
We now maintain a core "count" of how many non-threadsafe devices are
being used at any time. This value can be atomically adjusted by calls
to gs_lib_ctx_nts_adjust.
Non threadsafe devices now call gx_init_non_threadsafe_device either
as or as part of their initialise_device proc. This function attempts
to increment the non-threadsafe count and fails to init if there is
already a non-threadsafe device running.
On success, the device finalize method is modified so that it will
decrement the count at the end.
The known non-threadsafe devices are updated to call this.
In order to have somewhere safe to store this count, we introduce
a gs_globals structure, shared between instances. Setting this up
without race conditions requires some new gp_ functions that can
make use of platform specific threading primitives. We have these
implemented for both windows and pthread based platforms. On other
platforms, we drop back to the old unsafe mechanism for counting
instances.
While we do this work, we take the opportunity to push the
gs_memory_t pointer used for non-threadsafe debug printing into thread
local storage.
This enables us to remove the remaining GS_THREADSAFE guarded
compilation from the source code. What is left is broadly down to
allowing debugging collection for statistics, and these are now
controlled by specific COLLECT_STATS_XXX defines. It is assumed
that anyone wanting to collect such stats is smart enough to not
try to do so while using Ghostscript in a multi-instance environment.
Diffstat (limited to 'windows')
-rw-r--r-- | windows/ghostscript.vcxproj | 3 | ||||
-rw-r--r-- | windows/ghostscript.vcxproj.filters | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/windows/ghostscript.vcxproj b/windows/ghostscript.vcxproj index 1f274cccf..ff37ab895 100644 --- a/windows/ghostscript.vcxproj +++ b/windows/ghostscript.vcxproj @@ -2706,6 +2706,7 @@ <ClInclude Include="..\base\gdevsclass.h" /> <ClInclude Include="..\base\gdevvec.h" /> <ClInclude Include="..\base\gen_ordered.h" /> + <ClInclude Include="..\base\globals.h" /> <ClInclude Include="..\base\gp.h" /> <ClInclude Include="..\base\gpcheck.h" /> <ClInclude Include="..\base\gpgetenv.h" /> @@ -3805,4 +3806,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> +</Project>
\ No newline at end of file diff --git a/windows/ghostscript.vcxproj.filters b/windows/ghostscript.vcxproj.filters index 9dfe05833..df775b198 100644 --- a/windows/ghostscript.vcxproj.filters +++ b/windows/ghostscript.vcxproj.filters @@ -2441,7 +2441,6 @@ <ClCompile Include="..\base\gdevdevn.c"> <Filter>base\color</Filter> </ClCompile> - <ClCompile Include="..\base\gscdevn.c"> <Filter>base\color</Filter> </ClCompile> @@ -6746,12 +6745,6 @@ <ClInclude Include="..\base\gs_mro_e.h"> <Filter>base %28.h%29</Filter> </ClInclude> - <ClInclude Include="..\devices\vector\gsagl.h"> - <Filter>base %28.h%29</Filter> - </ClInclude> - <ClInclude Include="..\base\a"> - <Filter>base %28.h%29</Filter> - </ClInclude> <ClInclude Include="..\base\gsargs.h"> <Filter>base %28.h%29</Filter> </ClInclude> @@ -10028,6 +10021,15 @@ <ClInclude Include="..\devices\vector\doc_common.h"> <Filter>devices\vector</Filter> </ClInclude> + <ClInclude Include="..\base\globals.h"> + <Filter>base %28.h%29</Filter> + </ClInclude> + <ClInclude Include="..\base\gsagl.h"> + <Filter>devices\vector</Filter> + </ClInclude> + <ClInclude Include="..\base\gsalloc.h"> + <Filter>base %28.h%29</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="..\base\gspmdrv.rc"> |