On Thu, Apr 11, 2013 at 06:51:36AM +0000, Sørensen, Kenneth wrote:
> 
> From c34c95553ac7ebd278059fada06319aaf132c906 Mon Sep 17 00:00:00 2001
> From: Kenneth Soerensen <kenneth.soren...@spectralink.com>
> Date: Wed, 10 Apr 2013 16:52:52 +0200
> Subject: [PATCH 2/3] Make res_init() thread safe.
> 
> res_init() was not atomic, which could give undesired behaviour. Now
> res_init() is completely locked under one lock and the locking is
> removed from __res_vinit().
> 
> Signed-off-by: Kenneth Soerensen <kenneth.soren...@spectralink.com>
> ---
>  libc/inet/resolv.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
> index df6fefd..c230534 100644
> --- a/libc/inet/resolv.c
> +++ b/libc/inet/resolv.c
> @@ -3434,7 +3434,6 @@ __res_vinit(res_state rp, int preinit)
>       int m = 0;
>  #endif
>  
> -     __UCLIBC_MUTEX_LOCK(__resolv_lock);
>       __close_nameservers();
>       __open_nameservers();
>  
> @@ -3526,7 +3525,6 @@ __res_vinit(res_state rp, int preinit)
>  
>       rp->options |= RES_INIT;
>  
> -     __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
>       return 0;
>  }
>  
> @@ -3576,11 +3574,11 @@ res_init(void)
>       if (!_res.id)
>               _res.id = res_randomid();
>  
> -     __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
> -
>       __res_vinit(&_res, 1);
>       __res_sync = res_sync_func;
>  
> +     __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
> +
>       return 0;
>  }
>  libc_hidden_def(res_init)
> @@ -3679,7 +3677,9 @@ struct __res_state *__resp = &_res;
>  int
>  res_ninit(res_state statp)
>  {
> +     __UCLIBC_MUTEX_LOCK(__resolv_lock);
>       return __res_vinit(statp, 0);
> +     __UCLIBC_MUTEX_UNLOCK(__resolv_lock);

This hunk had the locking wrong as you can see. Applied with slight
adjustment.
Thanks,
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to