[Sheepdog] [PATCH 1/2] sheep: check return value for cpg_* function
zituan at taobao.com
zituan at taobao.com
Wed Sep 28 12:11:55 CEST 2011
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)
+ 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
More information about the sheepdog
mailing list