[gs-cvs] rev 8589 - branches/mtrender/src

ray at ghostscript.com ray at ghostscript.com
Wed Mar 5 20:19:28 PST 2008


Author: ray
Date: 2008-03-05 20:19:27 -0800 (Wed, 05 Mar 2008)
New Revision: 8589

Modified:
   branches/mtrender/src/gdevprn.c
   branches/mtrender/src/gxclist.c
   branches/mtrender/src/gxclthrd1.c
Log:
Fix SEGV when the 'big pattern' clist logic is used.

DETAILS:

The previous code set the clist procs in the 'clist_open' call, but this
wasn't compatible with the pattern-clist checking (spread throughout several
modules) that relied on the 'open_device' procedure equal to the
pattern_clist_open_device function.

IMHO, this is a hackish way to detect a particular device. The 'stype' seems
like a better thing to check, but this also doesn't work with interposed
compositors. I recommend that this check (currently in 6 places) be replaced
with a macro so that the code points that depend on this specific device can
be more readily identified.


Modified: branches/mtrender/src/gdevprn.c
===================================================================
--- branches/mtrender/src/gdevprn.c	2008-03-05 23:35:50 UTC (rev 8588)
+++ branches/mtrender/src/gdevprn.c	2008-03-06 04:19:27 UTC (rev 8589)
@@ -355,6 +355,9 @@
 						  !bufferSpace_is_default);
 	    if (ecode == 0)
 		ecode = code;
+
+	    if ( code >= 0 || (reallocate && pass > 1) )
+		ppdev->procs = gs_clist_device_procs;
 	} else {
 	    /* Render entirely in memory. */
 	    gx_device *bdev = (gx_device *)pmemdev;
@@ -692,6 +695,12 @@
     }
     ppdev->space_params = sp;
     ppdev->num_render_threads_requested = nthreads;
+    /* 
+     * We enable multi-threaded rendering here. It will remain
+     * enabled, but that doesn't really cause any problems.
+     */
+    if (nthreads > 0)
+	clist_enable_multi_thread_render(pdev);
 
     /* If necessary, free and reallocate the printer memory. */
     /* Formerly, would not reallocate if device is not open: */

Modified: branches/mtrender/src/gxclist.c
===================================================================
--- branches/mtrender/src/gxclist.c	2008-03-05 23:35:50 UTC (rev 8588)
+++ branches/mtrender/src/gxclist.c	2008-03-06 04:19:27 UTC (rev 8589)
@@ -625,12 +625,8 @@
     if (code < 0)
 	return code;
     code = clist_open_output_file(dev);
-    if ( code >= 0) {
+    if ( code >= 0)
 	code = clist_emit_page_header(dev);
-	dev->procs = gs_clist_device_procs;	/* Must be before enabling multi-threading */
-						/* which may change get_bits_rectangle */
-    }
-    clist_enable_multi_thread_render(dev);	/* if this fails, single thread will be used */
     return code;
 }
 

Modified: branches/mtrender/src/gxclthrd1.c
===================================================================
--- branches/mtrender/src/gxclthrd1.c	2008-03-05 23:35:50 UTC (rev 8588)
+++ branches/mtrender/src/gxclthrd1.c	2008-03-06 04:19:27 UTC (rev 8589)
@@ -511,21 +511,16 @@
 int 
 clist_enable_multi_thread_render(gx_device *dev)
 {   
-    gx_device_printer *pdev = (gx_device_printer *)dev;
-    int code;
+    gx_device_clist_common *cdev = (gx_device_clist_common *)dev;
+    int code = -1;
 
     /* We need to test gp_create_thread since we may be on a platform */
     /* built without working threads, i.e., using gp_nsync.c dummy    */
     /* routines. The nosync gp_create_thread returns a -ve error code */
-    if ((code = gp_create_thread(test_threads, NULL)) < 0) {
-	if (gs_debug[':'] != 0)
-	    dprintf("Using single threaded rendering\n");
-	pdev->num_render_threads_requested = 0;
+    if ((code = gp_create_thread(test_threads, NULL)) < 0 ) {
+        /* TODO: Check for memory based clist files (or fix the memfile) */
 	return code;	/* Threads don't work */
     }
-
-    if (gs_debug[':'] != 0)
-	dprintf("Multi threaded rendering enabled.\n");
     set_dev_proc(dev, get_bits_rectangle, clist_get_bits_rect_mt);
 
     return 1;



More information about the gs-cvs mailing list