cluster: RHEL56 - rgmanager: Allow exit while waiting for cman

Lon Hohberger lon at fedoraproject.org
Thu Jul 29 17:57:54 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=fbc82625c84ca9dfd99f7d8e3e051c53a63bf523
Commit:        fbc82625c84ca9dfd99f7d8e3e051c53a63bf523
Parent:        a8d21b2f0ccb2b9b50f4e729e070fec0fcfd8fee
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Mon Mar 30 17:01:45 2009 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Thu Jul 29 13:57:38 2010 -0400

rgmanager: Allow exit while waiting for cman

If cman isn't running, you can now kill rgmanager
with SIGINT (e.g. ctrl-C) or SIGTERM to make it
quit before initialization is complete.

Signed-off-by: Lon Hohberger <lhh at redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
 rgmanager/src/daemons/main.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 93ecff3..64c32a3 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -934,8 +934,8 @@ configure_rgmanager(int ccsfd, int dbg, int *token_secs)
 }
 
 
-void
-clu_initialize(cman_handle_t *ch)
+int
+cman_connect(cman_handle_t *ch)
 {
 	if (!ch)
 		exit(1);
@@ -946,6 +946,8 @@ clu_initialize(cman_handle_t *ch)
 
 		while (!(*ch = cman_init(NULL))) {
 			sleep(1);
+			if (shutdown_pending)
+				return 1;
 		}
 	}
 
@@ -960,10 +962,13 @@ clu_initialize(cman_handle_t *ch)
 
 		while (cman_is_quorate(*ch) == 0) {
 			sleep(1);
+			if (shutdown_pending)
+				return 1;
 		}
 		clulog(LOG_NOTICE, "Quorum formed\n");
 	}
 
+	return 0;
 }
 
 
@@ -1070,7 +1075,9 @@ main(int argc, char **argv)
 		unblock_signal(SIGSEGV);
 	}
 
-	clu_initialize(&clu);
+	if (cman_connect(&clu) != 0)
+		goto out;	/* Clean exit if sigint/sigterm here */
+
 	if (cman_init_subsys(clu) < 0) {
 		perror("cman_init_subsys");
 		return -1;
@@ -1173,8 +1180,10 @@ main(int argc, char **argv)
 		cleanup(cluster_ctx);
 
 out_cleanup:
-	clulog(LOG_NOTICE, "Shutdown complete, exiting\n");
 	clu_lock_finished(rgmanager_lsname);
+
+out:
+	clulog(LOG_NOTICE, "Shutdown complete, exiting\n");
 	cman_finish(clu);
 	
 	/*malloc_dump_table(); */ /* Only works if alloc.c us used */


More information about the cluster-commits mailing list