[Sheepdog] [PATCH 1/2] sheep: check return value for cpg_* function

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed Sep 28 20:46:16 CEST 2011


At Wed, 28 Sep 2011 18:11:55 +0800,
zituan at taobao.com wrote:
> 
> From: Yibin Shen <zituan at taobao.com>
> 
> 
> Signed-off-by: Yibin Shen <zituan at taobao.com>
> ---
>  sheep/group.c |   26 +++++++++++++++++++++-----
>  1 files changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/sheep/group.c b/sheep/group.c
> index e71cfdf..0f4d0fe 100644
> --- a/sheep/group.c
> +++ b/sheep/group.c
> @@ -400,13 +400,21 @@ forward:
>  
>  static void group_handler(int listen_fd, int events, void *data)
>  {
> +	int ret;
>  	if (events & EPOLLHUP) {
>  		eprintf("Receive EPOLLHUP event. Is corosync stopped running?\n");
> -		log_close();
> -		exit(1);
> +		goto out;
>  	}
>  
> -	cpg_dispatch(sys->handle, CPG_DISPATCH_ALL);
> +	ret = cpg_dispatch(sys->handle, CPG_DISPATCH_ALL);
> +
> +	if (ret == CPG_OK) 

Trailing whitespace.

Other than this, looks good to me.  I've applied two patches after
fixing this, thanks!

Kazutaka

> +		return;
> +	else
> +		eprintf("oops...some error occured inside corosync\n");
> +out:
> +	log_close();
> +	exit(1);
>  }
>  
>  static struct node *find_node(struct list_head *node_list, uint32_t nodeid, uint32_t pid)
> @@ -2035,8 +2043,16 @@ join_retry:
>  
>  	INIT_LIST_HEAD(&sys->cpg_event_siblings);
>  
> -	cpg_fd_get(cpg_handle, &fd);
> -	register_event(fd, group_handler, NULL);
> +	ret = cpg_fd_get(cpg_handle, &fd);
> +	if (ret != CPG_OK) {
> +		eprintf("Failed to retrieve cpg file descriptor, %d\n", ret);
> +		return 1;
> +	}
> +	ret = register_event(fd, group_handler, NULL);
> +	if (ret) {
> +		eprintf("Failed to register epoll events, %d\n", ret);
> +		return 1;
> +	}
>  	return 0;
>  }
>  
> -- 
> 1.7.6.3
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list