This is the mail archive of the libc-alpha@sourceware.org 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]

[RFC PATCH] GETADDRINFO: Make RFC 3484 sorting thread safe.


Hello.

Currently getaddrinfo() is not thread safe due to RFC 3484
sorting.  Try making it thread safe by introducing a lock.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

--- glibc-2.6.1/sysdeps/posix/getaddrinfo.c	2007-04-29 01:09:07.000000000 +0900
+++ glibc-2.6.1-ipv6fix/sysdeps/posix/getaddrinfo.c	2007-10-17 22:05:11.000000000 +0900
@@ -1926,6 +1926,10 @@
 
   if (naddrs > 1)
     {
+      /* Obtain the lock for RFC 3484 sorting. */
+      __libc_lock_define_initialized (static, lock);
+      __libc_lock_lock (lock);
+
       /* Read the config file.  */
       __libc_once_define (static, once);
       __typeof (once) old_once = once;
@@ -2017,6 +2021,9 @@
 	 the information.  */
       qsort (results, nresults, sizeof (results[0]), rfc3484_sort);
 
+      /* Release lock for sorting. */
+      __libc_lock_unlock (lock);
+
       /* Queue the results up as they come out of sorting.  */
       q = p = results[0].dest_addr;
       for (i = 1; i < nresults; ++i)

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA


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