Index: gd.c =================================================================== RCS file: /home/cvs/php4.2/ext/gd/gd.c,v retrieving revision 1.1.1.4 retrieving revision 1.3 diff -u -r1.1.1.4 -r1.3 --- gd.c 7 Sep 2002 01:39:58 -0000 1.1.1.4 +++ gd.c 14 Sep 2002 07:26:01 -0000 1.3 @@ -100,6 +100,10 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type); static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold); +#if defined(ZTS) +static MUTEX_T font_mutex = NULL; +#endif + /* {{{ gd_functions[] */ function_entry gd_functions[] = { @@ -238,7 +242,7 @@ "gd", gd_functions, PHP_MINIT(gd), - NULL, + PHP_MSHUTDOWN(gd), NULL, NULL, PHP_MINFO(gd), @@ -306,10 +310,22 @@ REGISTER_LONG_CONSTANT("IMG_ARC_NOFILL", gdNoFill, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMG_ARC_EDGED", gdEdged, CONST_CS | CONST_PERSISTENT); #endif +#ifdef ZTS + font_mutex = tsrm_mutex_alloc(); +#endif return SUCCESS; } /* }}} */ +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(gd) +{ +#ifdef ZTS + tsrm_mutex_free(font_mutex); +#endif +} + /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(gd) @@ -2813,6 +2829,9 @@ fontname = (unsigned char*)Z_STRVAL_PP(FONTNAME); #endif +#ifdef ZTS + tsrm_mutex_lock(font_mutex); +#endif #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX @@ -2832,6 +2851,9 @@ error = gdttf(im, brect, col, fontname, ptsize, angle, x, y, str); #endif +#ifdef ZTS + tsrm_mutex_unlock(font_mutex); +#endif if (error) { php_error(E_WARNING, "%s", error);