This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e5cc0c0302e744694ef981290fb33b97ae635371
Commit:        e5cc0c0302e744694ef981290fb33b97ae635371
Parent:        9939c15093f85e20f902cd0f6a285a838ab2c421
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Mon Mar 30 17:01:45 2009 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Tue Mar 31 11:29:49 2009 -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@redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto@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 7fc322c..9823111 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -894,8 +894,8 @@ configure_rgmanager(int ccsfd, int dbg)
 }
 
 
-void
-clu_initialize(cman_handle_t *ch)
+int
+cman_connect(cman_handle_t *ch)
 {
 	if (!ch)
 		exit(1);
@@ -906,6 +906,8 @@ clu_initialize(cman_handle_t *ch)
 
 		while (!(*ch = cman_init(NULL))) {
 			sleep(1);
+			if (shutdown_pending)
+				return 1;
 		}
 	}
 
@@ -920,10 +922,13 @@ clu_initialize(cman_handle_t *ch)
 
 		while (cman_is_quorate(*ch) == 0) {
 			sleep(1);
+			if (shutdown_pending)
+				return 1;
 		}
 		logt_print(LOG_NOTICE, "Quorum formed\n");
 	}
 
+	return 0;
 }
 
 
@@ -1022,7 +1027,9 @@ main(int argc, char **argv)
 	}
 
 	init_logging(NULL, foreground, (debug? LOG_DEBUG : SYSLOGLEVEL));
-	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;
@@ -1118,8 +1125,10 @@ main(int argc, char **argv)
 
 	if (rg_initialized())
 		cleanup(cluster_ctx);
-	logt_print(LOG_NOTICE, "Shutdown complete, exiting\n");
 	clu_lock_finished(rgmanager_lsname);
+
+out:
+	logt_print(LOG_NOTICE, "Shutdown complete, exiting\n");
 	cman_finish(clu);
 	
 	close_logging();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]