[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r6594 - in /fsf/trunk/libc: ChangeLog locale/setlocale.c



Author: eglibc
Date: Mon Jul 21 00:04:45 2008
New Revision: 6594

Log:
Import glibc-mainline for 2008-07-21

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/locale/setlocale.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Mon Jul 21 00:04:45 2008
@@ -1,3 +1,10 @@
+2008-07-20  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* locale/setlocale.c (setname): Remove inline to avoid compiler
+	warning.
+
+	* locale/setlocale.c (setlocale): Take the setlocale lock earlier.
+
 2008-07-15  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* stdio-common/vfprintf.c (_IO_helper_overflow): In case _IO_sputn

Modified: fsf/trunk/libc/locale/setlocale.c
==============================================================================
--- fsf/trunk/libc/locale/setlocale.c (original)
+++ fsf/trunk/libc/locale/setlocale.c Mon Jul 21 00:04:45 2008
@@ -193,7 +193,7 @@
 
 
 /* Put NAME in _nl_global_locale.__names.  */
-static inline void
+static void
 setname (int category, const char *name)
 {
   if (_nl_global_locale.__names[category] == name)
@@ -234,9 +234,16 @@
   if (locale == NULL)
     return (char *) _nl_global_locale.__names[category];
 
+  /* Protect global data.  */
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
+
   if (strcmp (locale, _nl_global_locale.__names[category]) == 0)
-    /* Changing to the same thing.  */
-    return (char *) _nl_global_locale.__names[category];
+    {
+      /* Changing to the same thing.  */
+      __libc_rwlock_unlock (__libc_setlocale_lock);
+
+      return (char *) _nl_global_locale.__names[category];
+    }
 
   /* We perhaps really have to load some data.  So we determine the
      path in which to look for the data now.  The environment variable
@@ -250,12 +257,13 @@
   if (locpath_var != NULL && locpath_var[0] != '\0')
     {
       if (__argz_create_sep (locpath_var, ':',
-			     &locale_path, &locale_path_len) != 0)
-	return NULL;
-
-      if (__argz_add_sep (&locale_path, &locale_path_len,
-			  _nl_default_locale_path, ':') != 0)
-	return NULL;
+			     &locale_path, &locale_path_len) != 0
+	  || __argz_add_sep (&locale_path, &locale_path_len,
+			     _nl_default_locale_path, ':') != 0)
+	{
+	  __libc_rwlock_unlock (__libc_setlocale_lock);
+	  return NULL;
+	}
     }
 
   if (category == LC_ALL)
@@ -290,8 +298,13 @@
 		  break;
 
 	      if (cnt == __LC_LAST)
-		/* Bogus category name.  */
-		ERROR_RETURN;
+		{
+		error_return:
+		  __libc_rwlock_unlock (__libc_setlocale_lock);
+
+		  /* Bogus category name.  */
+		  ERROR_RETURN;
+		}
 
 	      /* Found the category this clause sets.  */
 	      newnames[cnt] = ++cp;
@@ -310,11 +323,8 @@
 	  for (cnt = 0; cnt < __LC_LAST; ++cnt)
 	    if (cnt != LC_ALL && newnames[cnt] == locale)
 	      /* The composite name did not specify all categories.  */
-	      ERROR_RETURN;
-	}
-
-      /* Protect global data.  */
-      __libc_rwlock_wrlock (__libc_setlocale_lock);
+	      goto error_return;
+	}
 
       /* Load the new data for each category.  */
       while (category-- > 0)
@@ -393,9 +403,6 @@
       struct locale_data *newdata = NULL;
       const char *newname[1] = { locale };
 
-      /* Protect global data.  */
-      __libc_rwlock_wrlock (__libc_setlocale_lock);
-
       if (CATEGORY_USED (category))
 	{
 	  /* Only actually load the data if anything will use it.  */