ICU-2067 Make ucnv_shareConverterData thread safe

X-SVN-Rev: 9584
This commit is contained in:
George Rhoten 2002-08-05 23:00:20 +00:00
parent 57d169db3a
commit 7887d067b3

View File

@ -226,11 +226,19 @@ ucnv_shareConverterData(UConverterSharedData * data)
/*Lazy evaluates the Hashtable itself */
/*void *sanity = NULL;*/
if (SHARED_DATA_HASHTABLE == NULL)
{
SHARED_DATA_HASHTABLE = uhash_openSize (uhash_hashIChars, uhash_compareIChars,
if (SHARED_DATA_HASHTABLE == NULL) {
UHashtable *myTable = uhash_openSize(uhash_hashIChars, uhash_compareIChars,
ucnv_io_countAvailableAliases(&err),
&err);
umtx_lock(&cnvCacheMutex);
if (U_SUCCESS(err) && SHARED_DATA_HASHTABLE == NULL) {
SHARED_DATA_HASHTABLE = myTable;
myTable = NULL;
}
umtx_unlock(&cnvCacheMutex);
if (myTable != NULL) {
uhash_close(myTable);
}
if (U_FAILURE(err))
return;
}