summaryrefslogtreecommitdiff
path: root/base/gscspace.c
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2018-02-16 13:51:04 -0800
committerRay Johnston <ray.johnston@artifex.com>2018-03-28 22:08:40 -0700
commit9ff6b34e461fcbd4ef27fbb6c5c8a15071fe1370 (patch)
tree6996747ec44f0f2946bdb880369d942c70920652 /base/gscspace.c
parent33701ac07115cb2f634a40ab73a5c127ca870ad8 (diff)
downloadghostpdl-9ff6b34e461fcbd4ef27fbb6c5c8a15071fe1370.tar.gz
Make ICC profile management thread safe.
The change to ref_count of profiles needs to be protected by a lock if the profile ref_count could be changed by another thread. Also when decrementing the ref_count to 0, we cannot free the lock until after the profile has been unlocked. New routine gsicc_adjust_profile_rc replaces old (not threadsafe) function gsicc_profile_reference. Also add tracing "cname" to the RC_ADJUST_ macro to aid in debugging with -Z^ debug flag. Testing had revealed race conditions which are now fixed (eliminate use of semaphores). This also changes the gsicc_lcms2art.c interface functions to keep a list of transforms configured to have differing buffer formats that include alpha, planar IN/OUT, big_endian IN/OUT, bytes_per_component IN/OUT which are cloned as needed by threads. Change gscms_is_threadsafe to return "true" in gsicc_lcms2art.c TBD: If a link fails to build a thread may hang waiting for the link profile to become valid if it was not the thread that was building it. Not a new condition, but exposed when gscms_is_threadsafe returns true. TBD: Fix error handling / clean-up when links fail to build. Also not new, but is needed to prevent leaks, and possibly hang conditions.
Diffstat (limited to 'base/gscspace.c')
-rw-r--r--base/gscspace.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/base/gscspace.c b/base/gscspace.c
index aaf730da8..ebc2850b9 100644
--- a/base/gscspace.c
+++ b/base/gscspace.c
@@ -200,7 +200,7 @@ gs_cspace_new_ICC(gs_memory_t *pmem, gs_gstate * pgs, int components)
case 4: pcspace->cmm_icc_profile_data = icc_manage->default_cmyk; break;
default: rc_decrement(pcspace,"gs_cspace_new_ICC"); return NULL;
}
- rc_increment(pcspace->cmm_icc_profile_data);
+ gsicc_adjust_profile_rc(pcspace->cmm_icc_profile_data, 1, "gs_cspace_new_ICC");
return pcspace;
}
@@ -278,7 +278,7 @@ gx_install_DeviceGray(gs_color_space * pcs, gs_gstate * pgs)
/* pcs takes a reference to the default_gray profile data */
pcs->cmm_icc_profile_data = pgs->icc_manager->default_gray;
- rc_increment(pgs->icc_manager->default_gray);
+ gsicc_adjust_profile_rc(pgs->icc_manager->default_gray, 1, "gx_install_DeviceGray");
pcs->type = &gs_color_space_type_ICC;
return 0;
}
@@ -382,7 +382,7 @@ gx_install_DeviceRGB(gs_color_space * pcs, gs_gstate * pgs)
/* pcs takes a reference to default_rgb */
pcs->cmm_icc_profile_data = pgs->icc_manager->default_rgb;
- rc_increment(pcs->cmm_icc_profile_data);
+ gsicc_adjust_profile_rc(pcs->cmm_icc_profile_data, 1, "gx_install_DeviceRGB");
pcs->type = &gs_color_space_type_ICC;
return 0;
}
@@ -401,7 +401,7 @@ gx_install_DeviceCMYK(gs_color_space * pcs, gs_gstate * pgs)
/* pcs takes a reference to default_cmyk */
pcs->cmm_icc_profile_data = pgs->icc_manager->default_cmyk;
- rc_increment(pcs->cmm_icc_profile_data);
+ gsicc_adjust_profile_rc(pcs->cmm_icc_profile_data, 1, "gx_install_DeviceCMYK");
pcs->type = &gs_color_space_type_ICC;
return 0;
}