about summary refs log tree commit diff
path: root/locale/newlocale.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-07-16 19:06:46 +0000
committerUlrich Drepper <drepper@redhat.com>2004-07-16 19:06:46 +0000
commit531b71dd4ddc4b15fe643b182d500e6bc7bde413 (patch)
treed56178080bf346c8b465e4f32761cfe72a60b87b /locale/newlocale.c
parent06eee9f5f6e6911d6ded34eab033373057cfe16e (diff)
downloadglibc-531b71dd4ddc4b15fe643b182d500e6bc7bde413.tar.gz
glibc-531b71dd4ddc4b15fe643b182d500e6bc7bde413.tar.xz
glibc-531b71dd4ddc4b15fe643b182d500e6bc7bde413.zip
Update.
2004-07-16  Jakub Jelinek  <jakub@redhat.com>

	* locale/newlocale.c: Include bits/libc-lock.h.
	(__libc_setlocale_lock): Extern decl.
	(__newlocale): Use it.
	Reported by Ulrich Weigand <Ulrich.Weigand@de.ibm.com>.
Diffstat (limited to 'locale/newlocale.c')
-rw-r--r--locale/newlocale.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/locale/newlocale.c b/locale/newlocale.c
index 1131f62c0b..b646ffeacd 100644
--- a/locale/newlocale.c
+++ b/locale/newlocale.c
@@ -1,5 +1,6 @@
 /* Return a reference to locale information record.
-   Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -19,6 +20,7 @@
    02111-1307 USA.  */
 
 #include <argz.h>
+#include <bits/libc-lock.h>
 #include <errno.h>
 #include <locale.h>
 #include <stdlib.h>
@@ -27,6 +29,10 @@
 #include "localeinfo.h"
 
 
+/* Lock for protecting global data.  */
+__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden)
+
+
 /* Use this when we come along an error.  */
 #define ERROR_RETURN							      \
   do {									      \
@@ -154,6 +160,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
 	ERROR_RETURN;
     }
 
+  /* Protect global data.  */
+  __libc_lock_lock (__libc_setlocale_lock);
+
   /* Now process all categories we are interested in.  */
   names_len = 0;
   for (cnt = 0; cnt < __LC_LAST; ++cnt)
@@ -171,6 +180,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
 		    && result.__locales[cnt]->usage_count != UNDELETABLE)
 		  /* We can remove the data.  */
 		  _nl_remove_locale (cnt, result.__locales[cnt]);
+
+              /* Critical section left.  */
+              __libc_lock_unlock (__libc_setlocale_lock);
 	      return NULL;
 	    }
 
@@ -249,6 +261,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
       free (base);
     }
 
+  /* Critical section left.  */
+  __libc_lock_unlock (__libc_setlocale_lock);
+
   /* Update the special members.  */
  update:
   {