public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix BZ #5443 fallout
Date: Fri, 11 Apr 2008 08:01:00 -0000	[thread overview]
Message-ID: <20080411081044.GB3726@sunsite.mff.cuni.cz> (raw)

Hi!

Mixing __libc_lock_{,un}lock and __libc_rwlock_{rd,wr,un}lock
on a rwlock can't be a good thing...

2008-04-11  Jakub Jelinek  <jakub@redhat.com>

	[BZ #5443]
	* time/era.c: Transform __libc_setlocale_lock into rwlock.
	* time/alt_digit.c: Likewise.
	* wcsmbs/wcsmbsload.c: Likewise.

--- libc/time/era.c.jj	2002-08-29 01:10:59.000000000 +0200
+++ libc/time/era.c	2008-04-11 09:30:09.000000000 +0200
@@ -1,5 +1,5 @@
 /* Helper functions used by strftime/strptime to handle locale-specific "eras".
-   Copyright (C) 1995-2001,02 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
 #include <string.h>
 
 /* Some of the functions here must not be used while setlocale is called.  */
-__libc_lock_define (extern, __libc_setlocale_lock attribute_hidden)
+__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
 
 #define CURRENT(item)		(current->values[_NL_ITEM_INDEX (item)].string)
 #define CURRENT_WORD(item)	(current->values[_NL_ITEM_INDEX (item)].word)
@@ -45,7 +45,7 @@ _nl_init_era_entries (struct locale_data
   if (CURRENT_WORD (_NL_TIME_ERA_NUM_ENTRIES) == 0)
     return;
 
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   if (current->private.time == NULL)
     {
@@ -135,7 +135,7 @@ _nl_init_era_entries (struct locale_data
     }
 
  out:
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 }
 
 struct era_entry *
--- libc/time/alt_digit.c.jj	2002-08-29 01:10:59.000000000 +0200
+++ libc/time/alt_digit.c	2008-04-11 09:29:36.000000000 +0200
@@ -1,5 +1,5 @@
 /* Helper functions used by strftime/strptime to handle alternate digits.
-   Copyright (C) 1995-2001,02 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
 #include <string.h>
 
 /* Some of the functions here must not be used while setlocale is called.  */
-__libc_lock_define (extern, __libc_setlocale_lock attribute_hidden)
+__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
 
 #define CURRENT(item) (current->values[_NL_ITEM_INDEX (item)].string)
 #define CURRENT_WSTR(item) \
@@ -77,7 +77,7 @@ _nl_get_alt_digit (unsigned int number, 
   if (number >= 100 || CURRENT (ALT_DIGITS)[0] == '\0')
     return NULL;
 
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   if (current->private.time == NULL
       || ! current->private.time->alt_digits_initialized)
@@ -88,7 +88,7 @@ _nl_get_alt_digit (unsigned int number, 
 	    ? current->private.time->alt_digits[number]
 	    : NULL);
 
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 
   return result;
 }
@@ -104,7 +104,7 @@ _nl_get_walt_digit (unsigned int number,
   if (number >= 100 || CURRENT_WSTR (_NL_WALT_DIGITS)[0] == L'\0')
     return NULL;
 
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   if (current->private.time == NULL)
     {
@@ -141,7 +141,7 @@ _nl_get_walt_digit (unsigned int number,
     result = data->walt_digits[number];
 
  out:
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 
   return (wchar_t *) result;
 }
@@ -159,7 +159,7 @@ _nl_parse_alt_digit (const char **strp, 
   if (CURRENT_WSTR (_NL_WALT_DIGITS)[0] == L'\0')
     return result;
 
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   if (current->private.time == NULL
       || ! current->private.time->alt_digits_initialized)
@@ -184,7 +184,7 @@ _nl_parse_alt_digit (const char **strp, 
 	  }
       }
 
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 
   if (result != -1)
     *strp += maxlen;
--- libc/wcsmbs/wcsmbsload.c.jj	2005-12-19 01:24:49.000000000 +0100
+++ libc/wcsmbs/wcsmbsload.c	2008-04-11 09:31:41.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2002,2004,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2002,2004,2005,2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -145,7 +145,7 @@ __wcsmbs_getfct (const char *to, const c
 
 
 /* Some of the functions here must not be used while setlocale is called.  */
-__libc_lock_define (extern, __libc_setlocale_lock attribute_hidden)
+__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
 
 /* Load conversion functions for the currently selected locale.  */
 void
@@ -153,7 +153,7 @@ internal_function
 __wcsmbs_load_conv (struct locale_data *new_category)
 {
   /* Acquire the lock.  */
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   /* We should repeat the test since while we waited some other thread
      might have run this function.  */
@@ -211,7 +211,7 @@ __wcsmbs_load_conv (struct locale_data *
 	}
     }
 
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 }
 
 

	Jakub

                 reply	other threads:[~2008-04-11  8:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080411081044.GB3726@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).