[SCM] CTDB repository - branch master updated - ctdb-1.0.114-10-g5ed7d67

Ronnie Sahlberg sahlberg at samba.org
Mon Mar 29 19:51:03 MDT 2010


The branch, master has been updated
       via  5ed7d6788b8f7bf71d7d66c3a620b1aec54dfd81 (commit)
       via  9dd25cb751919799af9d8a23a0725343a8400e58 (commit)
      from  2fb331d29f4756a7f45489a03cbd065d934f85bc (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5ed7d6788b8f7bf71d7d66c3a620b1aec54dfd81
Merge: 2fb331d29f4756a7f45489a03cbd065d934f85bc 9dd25cb751919799af9d8a23a0725343a8400e58
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 30 12:50:19 2010 +1100

    Merge root at 10.1.1.27:/shared/ctdb/ctdb-git

commit 9dd25cb751919799af9d8a23a0725343a8400e58
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 30 12:47:54 2010 +1100

    When we forcefully abort a running eventscript, dont log this as is
    the script timedout.
    
    Instead send a different signal (SIGABRT) to the child process to silently
    kill the process group for the script and its children without logging
    anything.
    
    We abort any running "monitor" script anytime any other event is generated
    either by ctdbd itself or by "ctdb eventscript ..."
    
    BZ61043

-----------------------------------------------------------------------

Summary of changes:
 server/eventscript.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/eventscript.c b/server/eventscript.c
index d1effbe..7409551 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -59,6 +59,17 @@ static void sigterm(int sig)
 	_exit(1);
 }
 
+/*
+  ctdbd sends us a SIGABRT when we should abort the current script.
+  we abort any active monitor script any time a different event is generated.
+ */
+static void sigabrt(int sig)
+{
+	/* all the child processes will be running in the same process group */
+	kill(-getpgrp(), SIGKILL);
+	_exit(1);
+}
+
 struct ctdb_event_script_state {
 	struct ctdb_context *ctdb;
 	pid_t child;
@@ -67,6 +78,7 @@ struct ctdb_event_script_state {
 	int fd[2];
 	void *private_data;
 	bool from_user;
+	bool aborted;
 	enum ctdb_eventscript_call call;
 	const char *options;
 	struct timeval timeout;
@@ -279,6 +291,7 @@ static int child_setup(struct ctdb_context *ctdb)
 	}
 
 	signal(SIGTERM, sigterm);
+	signal(SIGABRT, sigabrt);
 	return 0;
 }
 
@@ -548,10 +561,17 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
 	int status;
 
 	if (state->child) {
-		DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child));
+		if (state->aborted != True) {
+			DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child));
 
-		if (kill(state->child, SIGTERM) != 0) {
-			DEBUG(DEBUG_ERR,("Failed to kill child process for eventscript, errno %s(%d)\n", strerror(errno), errno));
+			if (kill(state->child, SIGTERM) != 0) {
+				DEBUG(DEBUG_ERR,("Failed to kill child process for eventscript, errno %s(%d)\n", strerror(errno), errno));
+			}
+		} else {
+			DEBUG(DEBUG_INFO,(__location__ " Sending SIGABRT to script child pid:%d\n", state->child));
+			if (kill(state->child, SIGABRT) != 0) {
+				DEBUG(DEBUG_ERR,("Failed to kill child process for eventscript, errno %s(%d)\n", strerror(errno), errno));
+			}
 		}
 	}
 
@@ -648,6 +668,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 	state->callback = callback;
 	state->private_data = private_data;
 	state->from_user = from_user;
+	state->aborted = False;
 	state->call = call;
 	state->options = talloc_vasprintf(state, fmt, ap);
 	state->timeout = timeval_set(ctdb->tunable.script_timeout, 0);
@@ -690,6 +711,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 	/* Kill off any running monitor events to run this event. */
 	if (ctdb->current_monitor) {
 		/* Discard script status so we don't save to last_status */
+		ctdb->current_monitor->aborted = True;
 		talloc_free(ctdb->current_monitor->scripts);
 		ctdb->current_monitor->scripts = NULL;
 		talloc_free(ctdb->current_monitor);


-- 
CTDB repository


More information about the samba-cvs mailing list