public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Christine Caulfield <chrissie@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE2 - cman: Use the new openais exit APIs
Date: Thu, 18 Jun 2009 07:11:00 -0000	[thread overview]
Message-ID: <20090618071111.C813C12036B@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a174a703e7ae078ddae98473c27ee71ebf44a547
Commit:        a174a703e7ae078ddae98473c27ee71ebf44a547
Parent:        a53fabd00c33987bb7247199d7f313d0ad2ada46
Author:        Christine Caulfield <ccaulfie@redhat.com>
AuthorDate:    Thu Jun 18 08:04:50 2009 +0100
Committer:     Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Thu Jun 18 08:10:16 2009 +0100

cman: Use the new openais exit APIs

When cman needs to shut down (eg killed by another node or cman_tool)
it now calls the openais exit APIs so that semaphores etc can be cleaned
up.

bz#505594

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
 cman/daemon/ais.c      |    7 +++++++
 cman/daemon/ais.h      |    5 +++++
 cman/daemon/commands.c |    8 ++++----
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c
index 03052a9..827815d 100644
--- a/cman/daemon/ais.c
+++ b/cman/daemon/ais.c
@@ -267,9 +267,16 @@ static int cman_exec_init_fn(struct objdb_iface_ver0 *objdb)
 	/* Open local sockets and initialise I/O queues */
 	cman_init();
 
+
+	/* Tell aisexec about reasons we will cause it to exit */
+	openais_shutdown_errorstring_register (CMAN_EXIT_AISEXEC_QUIT, "CMAN requested shutdown");
+	openais_shutdown_errorstring_register (CMAN_EXIT_AISEXEC_DISALLOWED, "CMAN joined disallowed cluster, exiting");
+	openais_shutdown_errorstring_register (CMAN_EXIT_AISEXEC_KILL, "CMAN kill requested, exiting");
+
 	/* Let cman_tool know we are running and our PID */
 	sprintf(pipe_msg,"SUCCESS: %d", getpid());
 	write_cman_pipe(pipe_msg);
+
 	close(startup_pipe);
 	startup_pipe = 0;
 
diff --git a/cman/daemon/ais.h b/cman/daemon/ais.h
index 212e9f1..a61bc40 100644
--- a/cman/daemon/ais.h
+++ b/cman/daemon/ais.h
@@ -15,3 +15,8 @@ extern struct totem_ip_address mcast_addr[MAX_INTERFACES];
 extern struct totem_ip_address ifaddrs[MAX_INTERFACES];
 extern int num_interfaces;
 extern int num_ais_nodes;
+
+/* Reasons we kill aisexec */
+#define CMAN_EXIT_AISEXEC_QUIT       64
+#define CMAN_EXIT_AISEXEC_DISALLOWED 65
+#define CMAN_EXIT_AISEXEC_KILL       66
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index cf2f47a..7e09fae 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -838,7 +838,7 @@ static int do_cmd_leave_cluster(char *cmdbuf, int *retlen)
 
 	/* No messaging available yet, just die */
 	if (!we_are_a_cluster_member)
-		exit(0);
+		openais_shutdown(CMAN_EXIT_AISEXEC_QUIT);
 
 	send_leave(leave_flags);
 	use_count = 0;
@@ -1719,7 +1719,7 @@ static void do_process_transition(int nodeid, char *data, int len)
 	if (msg->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
 		/* Must use syslog directly here or the message will never arrive */
 		syslog(LOG_CRIT, "CMAN: Joined a cluster with disallowed nodes. must die");
-		exit(2);
+		openais_shutdown(CMAN_EXIT_AISEXEC_DISALLOWED);
 	}
 	msg->flags &= ~NODE_FLAGS_SEESDISALLOWED;
 
@@ -1881,7 +1881,7 @@ static void process_internal_message(char *data, int len, int nodeid, int need_b
 			/* Must use syslog directly here or the message will never arrive */
 			syslog(LOG_CRIT, "cman killed by node %d because %s\n", nodeid,
 				killmsg_reason(killmsg->reason));
-			exit(1);
+			openais_shutdown(CMAN_EXIT_AISEXEC_KILL);
 		}
 		break;
 
@@ -1894,7 +1894,7 @@ static void process_internal_message(char *data, int len, int nodeid, int need_b
 			/* Tell whomever asked us to leave that we are now going down */
 			if (shutdown_con)
 				send_status_return(shutdown_con, CMAN_CMD_TRY_SHUTDOWN, 0);
-			exit(0);
+			openais_shutdown(CMAN_EXIT_AISEXEC_QUIT);
 		}
 
 		/* Someone else, make a note of the reason for leaving */


                 reply	other threads:[~2009-06-18  7:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090618071111.C813C12036B@lists.fedorahosted.org \
    --to=chrissie@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).