stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [PATCH] 22.locale.moneypunct.mt.cpp test
Date Fri, 28 Sep 2007 22:49:28 GMT
Travis Vitek wrote:
> The same problem exists for __rw_get_numpunct.

In that case we should probably make the same changes in both,
referencing the respective issues in each ChangeLog, i.e.,
(presumably) STDCXX-453 in the patch below and STDCXX-452 in
the one for __rw_get_numpunct.

Martin

> 
> Farid Zaripov wrote:
>>  The __rw_get_moneypunct () function in punct.cpp is not thread safe
>> for the same
>> facets. If this function is invoked with the same pfacet parameter in
>> dirrerent threads
>> simultaneously, then some one thread successfully create __rw_setlocale
>> object
>> but other threads will blocked by global mutex in __rw_setlocale ctor.
>> Then when
>> the mutex will be released after the updating pfacet->_C_data(), the
>> next thread will
>> do the same initialization as the first thread.
>>
>>
>>  ChangeLog:
>>  * punct.cpp (__rw_get_moneypunct): After creating __rw_setlocale
>> object check 
>>  if the locale data is initialized by another thread to prevent
>> multiple initialization\
>>  of the locale data in facet.
>>
>> ----------
>> Index: punct.cpp
>> ===================================================================
>> --- punct.cpp	(revision 580097)
>> +++ punct.cpp	(working copy)
>> @@ -308,6 +308,10 @@
>>     // set all categories -- need LC_NUMERIC and LC_CTYPE
>>     const __rw_setlocale clocale (locname, _RWSTD_LC_ALL);
>>
>> +    if (pfacet->_C_data ())
>> +        // call self recursively on already initialized in another
>> thread `impdata'
>> +        return __rw_get_moneypunct (pfacet, flags);
>> +
>>     // get the lconv data
>>     const lconv* const pconv = localeconv ();
>>     if (!pconv)
>> ----------
>>
>> Farid.
>>


Mime
View raw message