This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

The __gconv_release_step() must be called on the exclusive conditions


Hi,

In glibc-2.3.2, I think that __gconv_release_step() should access
exclusively, when a _IO_new_fclose() calls a __gconv_release_step().

The _IO_new_fclose() calls _gconv_release_step(),
the __gconv_release_step() is also called by other external functions
but __gconv_close_transform() use a lock.(File name iconv/gconv_db.c)

--------------- start --------------
diff -Nur glibc-2.3.2.org/iconv/gconv_db.c glibc-2.3.2/iconv/gconv_db.c
--- glibc-2.3.2.org/iconv/gconv_db.c	2002-12-03 06:26:09.000000000 +0900
+++ glibc-2.3.2/iconv/gconv_db.c	2004-02-24 21:38:58.000000000 +0900
@@ -38,7 +38,7 @@
 struct gconv_module *__gconv_modules_db;
 
 /* We modify global data.   */
-__libc_lock_define_initialized (static, lock)
+__libc_lock_define_initialized (, __gconv_lock)
 
 
 /* Provide access to module database.  */
@@ -684,20 +684,20 @@
   __libc_once (once, __gconv_read_conf);
 
   /* Acquire the lock.  */
-  __libc_lock_lock (lock);
+  __libc_lock_lock (__gconv_lock);
 
   result = __gconv_lookup_cache (toset, fromset, handle, nsteps, flags);
   if (result != __GCONV_NODB)
     {
       /* We have a cache and could resolve the request, successful or not.  */
-      __libc_lock_unlock (lock);
+      __libc_lock_unlock (__gconv_lock);
       return result;
     }
 
   /* If we don't have a module database return with an error.  */
   if (__gconv_modules_db == NULL)
     {
-      __libc_lock_unlock (lock);
+      __libc_lock_unlock (__gconv_lock);
       return __GCONV_NOCONV;
     }
 
@@ -716,7 +716,7 @@
 		      && strcmp (toset_expand, fromset_expand) == 0)))))
     {
       /* Both character sets are the same.  */
-      __libc_lock_unlock (lock);
+      __libc_lock_unlock (__gconv_lock);
       return __GCONV_NOCONV;
     }
 
@@ -724,7 +724,7 @@
 			    handle, nsteps);
 
   /* Release the lock.  */
-  __libc_lock_unlock (lock);
+  __libc_lock_unlock (__gconv_lock);
 
   /* The following code is necessary since `find_derivation' will return
      GCONV_OK even when no derivation was found but the same request
@@ -744,7 +744,7 @@
   size_t cnt;
 
   /* Acquire the lock.  */
-  __libc_lock_lock (lock);
+  __libc_lock_lock (__gconv_lock);
 
 #ifndef STATIC_GCONV
   cnt = nsteps;
@@ -758,7 +758,7 @@
   __gconv_release_cache (steps, nsteps);
 
   /* Release the lock.  */
-  __libc_lock_unlock (lock);
+  __libc_lock_unlock (__gconv_lock);
 
   return result;
 }
diff -Nur glibc-2.3.2.org/iconv/gconv_int.h glibc-2.3.2/iconv/gconv_int.h
--- glibc-2.3.2.org/iconv/gconv_int.h	2002-12-03 06:26:09.000000000 +0900
+++ glibc-2.3.2/iconv/gconv_int.h	2004-02-24 21:34:22.000000000 +0900
@@ -22,6 +22,7 @@
 
 #include "gconv.h"
 #include <stdlib.h>		/* For alloca used in macro below.  */
+#include <bits/libc-lock.h>
 
 __BEGIN_DECLS
 
@@ -294,6 +295,8 @@
 
 #endif
 
+__libc_lock_define(extern, __gconv_lock);
+
 __END_DECLS
 
 #endif /* gconv_int.h */
diff -Nur glibc-2.3.2.org/libio/iofclose.c glibc-2.3.2/libio/iofclose.c
--- glibc-2.3.2.org/libio/iofclose.c	2002-04-03 12:00:56.000000000 +0900
+++ glibc-2.3.2/libio/iofclose.c	2004-02-24 21:30:53.000000000 +0900
@@ -73,8 +73,10 @@
 	 the conversion functions.  */
       struct _IO_codecvt *cc = fp->_codecvt;
 
+      __libc_lock_lock (__gconv_lock);
       __gconv_release_step (cc->__cd_in.__cd.__steps);
       __gconv_release_step (cc->__cd_out.__cd.__steps);
+      __libc_lock_unlock (__gconv_lock);
 #endif
     }
   else

--------------- end   --------------

Best Regards,
Shunichi Sagawa


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]