From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21570 invoked by alias); 18 Jun 2009 17:47:45 -0000 Received: (qmail 21564 invoked by alias); 18 Jun 2009 17:47:44 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: RHEL54 - cman: Use the new openais exit APIs To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL54 X-Git-Reftype: branch X-Git-Oldrev: a82e8590b5b96f0147ef8b3e4f0bb7f4be16f2f4 X-Git-Newrev: 2660846721573a2a2a3bef3318df96bae4ce5f32 From: Chris Feist Message-Id: <20090618160133.6FF11120194@lists.fedorahosted.org> Date: Thu, 18 Jun 2009 17:47:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00560.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2660846721573a2a2a3bef3318df96bae4ce5f32 Commit: 2660846721573a2a2a3bef3318df96bae4ce5f32 Parent: a82e8590b5b96f0147ef8b3e4f0bb7f4be16f2f4 Author: Christine Caulfield AuthorDate: Thu Jun 18 08:04:50 2009 +0100 Committer: Chris Feist CommitterDate: Thu Jun 18 11:01:04 2009 -0500 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 --- cman/daemon/ais.c | 5 +++++ cman/daemon/ais.h | 5 +++++ cman/daemon/commands.c | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c index 817ce42..9a874a8 100644 --- a/cman/daemon/ais.c +++ b/cman/daemon/ais.c @@ -272,6 +272,11 @@ 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 */ close(startup_pipe); startup_pipe = 0; diff --git a/cman/daemon/ais.h b/cman/daemon/ais.h index db3bbd6..a5795bc 100644 --- a/cman/daemon/ais.h +++ b/cman/daemon/ais.h @@ -26,3 +26,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 a97d244..03c7426 100644 --- a/cman/daemon/commands.c +++ b/cman/daemon/commands.c @@ -851,7 +851,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; @@ -1723,7 +1723,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; @@ -1878,7 +1878,7 @@ static void process_internal_message(char *data, int len, int nodeid, int need_b if (killmsg->nodeid == wanted_nodeid) { log_msg(LOG_INFO, "cman killed by node %d because %s\n", nodeid, killmsg_reason(killmsg->reason)); - exit(1); + openais_shutdown(CMAN_EXIT_AISEXEC_KILL); } break; @@ -1891,7 +1891,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 */