2008-03-30  Ulrich Drepper  <drepper@redhat.com>
	[BZ #5443]
	* intl/dcigettext.c (__dcigettext): Get reader lock for locale data
	before looking for translation.
	* locale/duplocale.c: Transform __libc_setlocale_lock into rwlock.
	* locale/freelocale.c: Likewise.
	* locale/newlocale.c: Likewise.
	* locale/setlocale.c: Likewise.
	Based partially on a patch by ryo@np.css.fujitsu.com.
This commit is contained in:
Ulrich Drepper 2008-03-31 00:38:06 +00:00
parent 2ecc7d93b8
commit 9a69db292a
7 changed files with 48 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2008-03-30 Ulrich Drepper <drepper@redhat.com>
[BZ #5443]
* intl/dcigettext.c (__dcigettext): Get reader lock for locale data
before looking for translation.
* locale/duplocale.c: Transform __libc_setlocale_lock into rwlock.
* locale/freelocale.c: Likewise.
* locale/newlocale.c: Likewise.
* locale/setlocale.c: Likewise.
Based partially on a patch by ryo@np.css.fujitsu.com.
2008-03-30 Jakub Jelinek <jakub@redhat.com> 2008-03-30 Jakub Jelinek <jakub@redhat.com>
* intl/dcigettext.c (_nl_find_msg): Reread nconversions after * intl/dcigettext.c (_nl_find_msg): Reread nconversions after

View File

@ -1,5 +1,6 @@
/* Implementation of the internal dcigettext function. /* Implementation of the internal dcigettext function.
Copyright (C) 1995-2005, 2006, 2007 Free Software Foundation, Inc. Copyright (C) 1995-2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -449,6 +450,11 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
: n == 1 ? (char *) msgid1 : (char *) msgid2); : n == 1 ? (char *) msgid1 : (char *) msgid2);
#endif #endif
#ifdef _LIBC
__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
__libc_rwlock_rdlock (__libc_setlocale_lock);
#endif
__libc_rwlock_rdlock (_nl_state_lock); __libc_rwlock_rdlock (_nl_state_lock);
/* If DOMAINNAME is NULL, we are interested in the default domain. If /* If DOMAINNAME is NULL, we are interested in the default domain. If
@ -466,7 +472,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
search.category = category; search.category = category;
# ifdef HAVE_PER_THREAD_LOCALE # ifdef HAVE_PER_THREAD_LOCALE
# ifdef _LIBC # ifdef _LIBC
localename = __current_locale_name (category); localename = strdupa (__current_locale_name (category));
# endif # endif
search.localename = localename; search.localename = localename;
# endif # endif
@ -489,6 +495,9 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
else else
retval = (char *) (*foundp)->translation; retval = (char *) (*foundp)->translation;
# ifdef _LIBC
__libc_rwlock_unlock (__libc_setlocale_lock);
# endif
__libc_rwlock_unlock (_nl_state_lock); __libc_rwlock_unlock (_nl_state_lock);
return retval; return retval;
} }
@ -548,6 +557,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
/* We cannot get the current working directory. Don't signal an /* We cannot get the current working directory. Don't signal an
error but simply return the default string. */ error but simply return the default string. */
FREE_BLOCKS (block_list); FREE_BLOCKS (block_list);
__libc_rwlock_unlock (__libc_setlocale_lock);
__libc_rwlock_unlock (_nl_state_lock); __libc_rwlock_unlock (_nl_state_lock);
__set_errno (saved_errno); __set_errno (saved_errno);
return (plural == 0 return (plural == 0
@ -614,6 +624,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
{ {
no_translation: no_translation:
FREE_BLOCKS (block_list); FREE_BLOCKS (block_list);
__libc_rwlock_unlock (__libc_setlocale_lock);
__libc_rwlock_unlock (_nl_state_lock); __libc_rwlock_unlock (_nl_state_lock);
__set_errno (saved_errno); __set_errno (saved_errno);
return (plural == 0 return (plural == 0
@ -727,6 +738,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
if (plural) if (plural)
retval = plural_lookup (domain, n, retval, retlen); retval = plural_lookup (domain, n, retval, retlen);
__libc_rwlock_unlock (__libc_setlocale_lock);
__libc_rwlock_unlock (_nl_state_lock); __libc_rwlock_unlock (_nl_state_lock);
return retval; return retval;
} }

View File

@ -1,5 +1,5 @@
/* Duplicate handle for selection of locales. /* Duplicate handle for selection of locales.
Copyright (C) 1997, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. Copyright (C) 1997,2000,2001,2002,2005,2008 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -27,7 +27,7 @@
/* Lock for protecting global data. */ /* Lock for protecting global data. */
__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden) __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
__locale_t __locale_t
@ -54,7 +54,7 @@ __duplocale (__locale_t dataset)
char *namep = (char *) (result + 1); char *namep = (char *) (result + 1);
/* We modify global data (the usage counts). */ /* We modify global data (the usage counts). */
__libc_lock_lock (__libc_setlocale_lock); __libc_rwlock_wrlock (__libc_setlocale_lock);
for (cnt = 0; cnt < __LC_LAST; ++cnt) for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL) if (cnt != LC_ALL)
@ -78,7 +78,7 @@ __duplocale (__locale_t dataset)
result->__ctype_toupper = dataset->__ctype_toupper; result->__ctype_toupper = dataset->__ctype_toupper;
/* It's done. */ /* It's done. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
} }
return result; return result;

View File

@ -1,5 +1,5 @@
/* Free data allocated by a call to setlocale_r /* Free data allocated by a call to setlocale_r
Copyright (C) 1996, 1997, 2000, 2002, 2005 Free Software Foundation, Inc. Copyright (C) 1996,1997,2000,2002,2005,2008 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -26,7 +26,7 @@
/* Lock for protecting global data. */ /* Lock for protecting global data. */
__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden) __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
void void
@ -39,7 +39,7 @@ __freelocale (__locale_t dataset)
return; return;
/* We modify global data (the usage counts). */ /* We modify global data (the usage counts). */
__libc_lock_lock (__libc_setlocale_lock); __libc_rwlock_wrlock (__libc_setlocale_lock);
for (cnt = 0; cnt < __LC_LAST; ++cnt) for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL && dataset->__locales[cnt]->usage_count != UNDELETABLE) if (cnt != LC_ALL && dataset->__locales[cnt]->usage_count != UNDELETABLE)
@ -47,7 +47,7 @@ __freelocale (__locale_t dataset)
_nl_remove_locale (cnt, dataset->__locales[cnt]); _nl_remove_locale (cnt, dataset->__locales[cnt]);
/* It's done. */ /* It's done. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
/* Free the locale_t handle itself. */ /* Free the locale_t handle itself. */
free (dataset); free (dataset);

View File

@ -1,5 +1,5 @@
/* Return a reference to locale information record. /* Return a reference to locale information record.
Copyright (C) 1996, 1997, 1999, 2000-2002, 2004, 2005, 2006 Copyright (C) 1996, 1997, 1999, 2000-2002, 2004, 2005, 2006, 2008
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -30,7 +30,7 @@
/* Lock for protecting global data. */ /* Lock for protecting global data. */
__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden) __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
/* Use this when we come along an error. */ /* Use this when we come along an error. */
@ -162,7 +162,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
} }
/* Protect global data. */ /* Protect global data. */
__libc_lock_lock (__libc_setlocale_lock); __libc_rwlock_wrlock (__libc_setlocale_lock);
/* Now process all categories we are interested in. */ /* Now process all categories we are interested in. */
names_len = 0; names_len = 0;
@ -183,7 +183,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
_nl_remove_locale (cnt, result.__locales[cnt]); _nl_remove_locale (cnt, result.__locales[cnt]);
/* Critical section left. */ /* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
return NULL; return NULL;
} }
@ -263,7 +263,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
} }
/* Critical section left. */ /* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
/* Update the special members. */ /* Update the special members. */
update: update:

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004, 2006 /* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004, 2006, 2008
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -123,7 +123,7 @@ static void (*const _nl_category_postload[]) (void) =
/* Lock for protecting global data. */ /* Lock for protecting global data. */
__libc_lock_define_initialized (, __libc_setlocale_lock attribute_hidden) __libc_rwlock_define_initialized (, __libc_setlocale_lock attribute_hidden)
/* Defined in loadmsgcat.c. */ /* Defined in loadmsgcat.c. */
extern int _nl_msg_cat_cntr; extern int _nl_msg_cat_cntr;
@ -314,7 +314,7 @@ setlocale (int category, const char *locale)
} }
/* Protect global data. */ /* Protect global data. */
__libc_lock_lock (__libc_setlocale_lock); __libc_rwlock_wrlock (__libc_setlocale_lock);
/* Load the new data for each category. */ /* Load the new data for each category. */
while (category-- > 0) while (category-- > 0)
@ -381,7 +381,7 @@ setlocale (int category, const char *locale)
free ((char *) newnames[category]); free ((char *) newnames[category]);
/* Critical section left. */ /* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
/* Free the resources (the locale path variable). */ /* Free the resources (the locale path variable). */
free (locale_path); free (locale_path);
@ -394,7 +394,7 @@ setlocale (int category, const char *locale)
const char *newname[1] = { locale }; const char *newname[1] = { locale };
/* Protect global data. */ /* Protect global data. */
__libc_lock_lock (__libc_setlocale_lock); __libc_rwlock_wrlock (__libc_setlocale_lock);
if (CATEGORY_USED (category)) if (CATEGORY_USED (category))
{ {
@ -446,7 +446,7 @@ setlocale (int category, const char *locale)
} }
/* Critical section left. */ /* Critical section left. */
__libc_lock_unlock (__libc_setlocale_lock); __libc_rwlock_unlock (__libc_setlocale_lock);
/* Free the resources (the locale path variable. */ /* Free the resources (the locale path variable. */
free (locale_path); free (locale_path);

View File

@ -1,3 +1,7 @@
2008-03-30 Jakub Jelinek <jakub@redhat.com>
* Makefile (LOCALES): Add ja_JP.UTF-8.
2008-03-23 Ulrich Drepper <drepper@redhat.com> 2008-03-23 Ulrich Drepper <drepper@redhat.com>
* locales/iso14651_t1_common: Add support for Devanagari script. * locales/iso14651_t1_common: Add support for Devanagari script.