This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC PATCH] GETADDRINFO: Make RFC 3484 sorting thread safe.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji at linux-ipv6 dot org>
- Cc: drepper at redhat dot com, libc-alpha at sources dot redhat dot com, usagi-core at linux-ipv6 dot org
- Date: Wed, 17 Oct 2007 15:40:34 +0200
- Subject: Re: [RFC PATCH] GETADDRINFO: Make RFC 3484 sorting thread safe.
- References: <20071017.221353.77648074.yoshfuji@linux-ipv6.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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