diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2014-09-15 11:02:09 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2014-09-16 08:49:45 +0100 |
commit | 551d7dd426fe8ab7f2c0c9d90339784e2b643bad (patch) | |
tree | a37b8630cc3929f8075443eed09a9ce28d4cb180 | |
parent | 51b9c7dc2a471b9c3dfe6400c0a55d90db4fec16 (diff) | |
download | ghostpdl-551d7dd426fe8ab7f2c0c9d90339784e2b643bad.tar.gz |
Bug 695483: disable BGPrint before we shutdown interpreter
Before we start the process of shutting down the PS interpreter, disable BGPrint
(and set NumRenderingThreads to 0, just for safety). If we don't do this, the
"parent" rendering thread will continue preparations for the next page whilst
we shutdown the interpreter, and will thus attempt to access some objects
subject to garbage collection (such as the I/O device table).
Additionally, when a device switches from BGPrint enabled to disabled, make sure
we tear down the rendering thread(s) and get rid off the BGPrint related data.
No cluster differences.
-rw-r--r-- | gs/base/gdevprn.c | 5 | ||||
-rw-r--r-- | gs/psi/imain.c | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gs/base/gdevprn.c b/gs/base/gdevprn.c index 52636df52..28dd43011 100644 --- a/gs/base/gdevprn.c +++ b/gs/base/gdevprn.c @@ -863,6 +863,11 @@ gdev_prn_put_params(gx_device * pdev, gs_param_list * plist) ppdev->OpenOutputFile = oof; ppdev->ReopenPerPage = rpp; + + if (ppdev->bg_print_requested && !bg_print_requested) { + prn_finish_bg_print(ppdev); + } + ppdev->bg_print_requested = bg_print_requested; if (duplex_set >= 0) { ppdev->Duplex = duplex; diff --git a/gs/psi/imain.c b/gs/psi/imain.c index 0a0f5710d..b1cc5e2b4 100644 --- a/gs/psi/imain.c +++ b/gs/psi/imain.c @@ -872,6 +872,23 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code) * alloc_restore_all will close dynamically allocated devices. */ tempnames = gs_main_tempnames(minst); + +#ifndef PSI_INCLUDED + /* We have to disable BGPrint before we call interp_reclaim() to prevent the + * parent rendering thread initialising for the next page, whilst we are + * removing objects it may want to access - for example, the I/O device table. + * We also have to mess with the BeginPage/EndPage procs so that we don't + * trigger a spurious extra page to be emitted. + */ + gs_main_run_string(minst, + "/systemdict .systemexec /begin .systemexec \ + <</BeginPage {pop} /EndPage {pop pop //false } \ + /BGPrint false /NumRenderingThreads 0>> setpagedevice \ + serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse end \ + .systemvar exec", + 0 , &exit_code, &error_object); +#endif + /* * Close the "main" device, because it may need to write out * data before destruction. pdfwrite needs so. |