[sheepdog] [PATCH 1/2] sockfd cache: fix a wrong type of read/write lock

Liu Yuan namei.unix at gmail.com
Tue Dec 4 03:39:36 CET 2012


On 12/03/2012 03:36 PM, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> We should use write lock for sockfd_cache_add() because it changes the
> node red-black tree state.
> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  sheep/sockfd_cache.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
> index 137bbe4..33e780b 100644
> --- a/sheep/sockfd_cache.c
> +++ b/sheep/sockfd_cache.c
> @@ -265,7 +265,7 @@ void sockfd_cache_add(const struct node_id *nid)
>  	char name[INET6_ADDRSTRLEN];
>  	int n, i;
>  
> -	pthread_rwlock_rdlock(&sockfd_cache.lock);
> +	pthread_rwlock_wrlock(&sockfd_cache.lock);
>  	new = xmalloc(sizeof(*new));
>  	new->fds = xzalloc(sizeof(struct sockfd_cache_fd) * fds_count);
>  	for (i = 0; i < fds_count; i++)
> 

Applied these two.

Thanks,
Yuan



More information about the sheepdog mailing list