4614834.patch revision 688
341N/A###############################################################################
341N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
341N/A# Use subject to license terms.
341N/A#
341N/A# Permission is hereby granted, free of charge, to any person obtaining a
341N/A# copy of this software and associated documentation files (the
341N/A# "Software"), to deal in the Software without restriction, including
341N/A# without limitation the rights to use, copy, modify, merge, publish,
341N/A# distribute, and/or sell copies of the Software, and to permit persons
341N/A# to whom the Software is furnished to do so, provided that the above
341N/A# copyright notice(s) and this permission notice appear in all copies of
341N/A# the Software and that both the above copyright notice(s) and this
341N/A# permission notice appear in supporting documentation.
341N/A#
341N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
341N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
341N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
341N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
341N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
341N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
341N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
341N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
341N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
341N/A#
341N/A# Except as contained in this notice, the name of a copyright holder
341N/A# shall not be used in advertising or otherwise to promote the sale, use
341N/A# or other dealings in this Software without prior written authorization
341N/A# of the copyright holder.
341N/A#
341N/A
341N/A4614834: Xlib color functions are not MT-safe
341N/A
341N/AIn a multithreaded Xlib client:
341N/A
341N/A * concurrent access to XAllocNamedColor() make the client crash
341N/A * concurrent access to XLookupColor() make the client crash
341N/A
341N/AThe cause of the problem is that in multithread environment some data
341N/Ain XLookupColor() and XAllocNamedColor() can be accessed/modified at
341N/Asame time by multi threads. Adding some lock and unlock code to make
341N/Asure only one thread can access the data at one time fixed the
341N/Aproblem.
341N/A
341N/Adiff -urp -x '*~' -x '*.orig' src/GetColor.c src/GetColor.c
688N/A--- src/GetColor.c 2008-10-07 10:18:18.000000000 -0700
688N/A+++ src/GetColor.c 2009-04-08 00:17:54.349336000 -0700
688N/A@@ -58,12 +58,14 @@ XColor *exact_def) /* RETURN */
341N/A if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
341N/A const char *tmpName = colorname;
341N/A
341N/A+ LockDisplay(dpy);
341N/A switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
341N/A XcmsRGBFormat)) {
341N/A case XcmsSuccess:
341N/A case XcmsSuccessWithCompression:
341N/A _XcmsRGB_to_XColor(&cmsColor_exact, exact_def, 1);
341N/A memcpy((char *)hard_def, (char *)exact_def, sizeof(XColor));
341N/A+ UnlockDisplay(dpy);
341N/A ret = XAllocColor(dpy, cmap, hard_def);
341N/A exact_def->pixel = hard_def->pixel;
341N/A return(ret);
688N/A@@ -76,6 +78,7 @@ XColor *exact_def) /* RETURN */
341N/A */
341N/A break;
341N/A }
341N/A+ UnlockDisplay(dpy);
341N/A }
688N/A #endif
341N/A
341N/Adiff -urp -x '*~' -x '*.orig' src/LookupCol.c src/LookupCol.c
688N/A--- src/LookupCol.c 2008-10-07 10:18:18.000000000 -0700
688N/A+++ src/LookupCol.c 2009-04-08 00:17:54.349566000 -0700
688N/A@@ -56,6 +56,7 @@ XLookupColor (
341N/A if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
341N/A const char *tmpName = spec;
341N/A
341N/A+ LockDisplay(dpy);
341N/A switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
341N/A XcmsRGBFormat)) {
341N/A case XcmsSuccess:
688N/A@@ -63,6 +64,7 @@ XLookupColor (
341N/A _XcmsRGB_to_XColor(&cmsColor_exact, def, 1);
341N/A memcpy((char *)scr, (char *)def, sizeof(XColor));
341N/A _XUnresolveColor(ccc, scr);
341N/A+ UnlockDisplay(dpy);
341N/A return(1);
341N/A case XcmsFailure:
341N/A case _XCMS_NEWNAME:
688N/A@@ -73,6 +75,7 @@ XLookupColor (
341N/A */
341N/A break;
341N/A }
341N/A+ UnlockDisplay(dpy);
341N/A }
688N/A #endif
341N/A