Commit 216b9cb0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Lock global locale in _get_current_locale.

parent df2b13fa
...@@ -1117,6 +1117,22 @@ void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo) ...@@ -1117,6 +1117,22 @@ void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo)
MSVCRT_free(mbcinfo); MSVCRT_free(mbcinfo);
} }
/*********************************************************************
* _lock_locales (UCRTBASE.@)
*/
void CDECL _lock_locales(void)
{
_mlock(_SETLOCALE_LOCK);
}
/*********************************************************************
* _unlock_locales (UCRTBASE.@)
*/
void CDECL _unlock_locales(void)
{
_munlock(_SETLOCALE_LOCK);
}
MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale) MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
{ {
thread_data_t *data = msvcrt_get_thread_data(); thread_data_t *data = msvcrt_get_thread_data();
...@@ -1124,6 +1140,7 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale) ...@@ -1124,6 +1140,7 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
if(!data || !data->have_locale) if(!data || !data->have_locale)
{ {
_lock_locales();
*locale = *MSVCRT_locale; *locale = *MSVCRT_locale;
} }
else else
...@@ -1144,6 +1161,8 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale) ...@@ -1144,6 +1161,8 @@ MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale)
if(locale->locinfo->ctype1_refcount) if(locale->locinfo->ctype1_refcount)
InterlockedIncrement(locale->locinfo->ctype1_refcount); InterlockedIncrement(locale->locinfo->ctype1_refcount);
InterlockedIncrement(&locale->locinfo->lc_time_curr->refcount); InterlockedIncrement(&locale->locinfo->lc_time_curr->refcount);
if(locale->locinfo == MSVCRT_locale->locinfo)
_unlock_locales();
InterlockedIncrement(&locale->mbcinfo->refcount); InterlockedIncrement(&locale->mbcinfo->refcount);
return locale; return locale;
...@@ -1931,22 +1950,6 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, ...@@ -1931,22 +1950,6 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category,
} }
/********************************************************************* /*********************************************************************
* _lock_locales (UCRTBASE.@)
*/
void CDECL _lock_locales(void)
{
_mlock(_SETLOCALE_LOCK);
}
/*********************************************************************
* _unlock_locales (UCRTBASE.@)
*/
void CDECL _unlock_locales(void)
{
_munlock(_SETLOCALE_LOCK);
}
/*********************************************************************
* _create_locale (MSVCRT.@) * _create_locale (MSVCRT.@)
*/ */
MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale) MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment