[Sheepdog] [PATCH] sheep: stop logger process when failing to initialize sheepdog

Guangyi Yang polarisygy at gmail.com
Tue Aug 23 13:52:17 CEST 2011


From: Guangyi Yang <yangguangyi.pt at taobao.com>

When sheep fail to initialize itself, it will only exit the main process
and leave the logger process alone.This patch fixes it.

Signed-off-by: Guangyi Yang <yangguangyi.pt at taobao.com>
---
 sheep/sheep.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index da0cb7b..a64ca21 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -143,20 +143,20 @@ int main(int argc, char **argv)
 
 	ret = init_event(EPOLL_SIZE);
 	if (ret)
-		exit(1);
+		goto init_error;
 
 	ret = init_work_queue(NR_WORKER_THREAD);
 	if (ret)
-		exit(1);
+		goto init_error;
 
 	ret = create_listen_port(port, sys);
 	if (ret)
-		exit(1);
+		goto init_error;
 
 	ret = create_cluster(port, zone);
 	if (ret) {
 		eprintf("failed to create sheepdog cluster.\n");
-		exit(1);
+		goto init_error;
 	}
 
 	vprintf(SDOG_NOTICE "Sheepdog daemon (version %s) started\n", PACKAGE_VERSION);
@@ -169,4 +169,8 @@ int main(int argc, char **argv)
 	log_close();
 
 	return 0;
+
+init_error:
+	log_close();
+	exit(1);
 }
-- 
1.7.1




More information about the sheepdog mailing list