[RFC PATCH] GETADDRINFO: Make RFC 3484 sorting thread safe.
Jakub Jelinek
jakub@redhat.com
Wed Oct 17 13:37:00 GMT 2007
On Wed, Oct 17, 2007 at 10:13:53PM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> Currently getaddrinfo() is not thread safe due to RFC 3484
> sorting. Try making it thread safe by introducing a lock.
Only if gai.conf is present and contains reload yes, right?
If so, the locking should be only done in that case IMNSHO.
> --- 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)
Jakub
More information about the Libc-alpha
mailing list