[sheepdog] [PATCH] sheep/request: fix potential incorrect cluster info refcnt

Hitoshi Mitake mitake.hitoshi at gmail.com
Thu Jul 10 13:36:11 CEST 2014


At Thu, 10 Jul 2014 14:29:39 +0800,
Ruoyu wrote:
> 
> For fear that req->data is not allocated successfully, move
> increament of cluster info refcnt after memory alloc is reasonable.
> 
> Signed-off-by: Ruoyu <liangry at ucweb.com>
> ---
>  sheep/request.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, with typo fix, thanks.
Hitoshi

> 
> diff --git a/sheep/request.c b/sheep/request.c
> index f2ccff6..eb72b00 100644
> --- a/sheep/request.c
> +++ b/sheep/request.c
> @@ -687,8 +687,6 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
>  	if (!req)
>  		return NULL;
>  
> -	req->ci = ci;
> -	refcount_inc(&ci->refcnt);
>  	if (data_length) {
>  		req->data_length = data_length;
>  		req->data = valloc(data_length);
> @@ -698,6 +696,9 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
>  		}
>  	}
>  
> +	req->ci = ci;
> +	refcount_inc(&ci->refcnt);
> +
>  	refcount_set(&req->refcnt, 1);
>  
>  	uatomic_inc(&sys->nr_outstanding_reqs);
> -- 
> 1.8.3.2
> 
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list