[SCM] CTDB repository - branch master updated - 702ced6c2fe569c01fe96c60d0f35a7e61506a96

Ronnie Sahlberg sahlberg at samba.org
Tue Jul 8 07:46:29 GMT 2008


The branch, master has been updated
       via  702ced6c2fe569c01fe96c60d0f35a7e61506a96 (commit)
       via  2030e9ff2ca044181b72c3b87d513bf27057b5a2 (commit)
      from  b1f1e80d3ad50280a300f2ed021513cf0a6f3a76 (commit)

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


- Log -----------------------------------------------------------------
commit 702ced6c2fe569c01fe96c60d0f35a7e61506a96
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Jul 8 17:41:31 2008 +1000

    Revert "waitpid() can block if it takes a long time before the child terminates"
    
    This reverts commit bfba5c7249eff8a10a43b53c1b89dd44b625fd10.
    
    revert the waitpid changes.   we need to waitpid for some childredn so should
    refactor the approach completely

commit 2030e9ff2ca044181b72c3b87d513bf27057b5a2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Jul 8 17:40:53 2008 +1000

    Revert "set sigchild to SIG_IGN instead of SIG_DFL"
    
    This reverts commit b1f1e80d3ad50280a300f2ed021513cf0a6f3a76.

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

Summary of changes:
 server/ctdb_daemon.c     |    3 ---
 server/ctdb_freeze.c     |    1 +
 server/ctdb_lockwait.c   |    2 ++
 server/ctdb_persistent.c |    2 ++
 server/ctdb_recover.c    |    1 +
 server/ctdb_recoverd.c   |    8 +++++---
 server/ctdb_traverse.c   |    1 +
 server/eventscript.c     |   26 ++++++++------------------
 8 files changed, 20 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 83fcc0a..326ab60 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -731,9 +731,6 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	/* start the transport going */
 	ctdb_start_transport(ctdb);
 
-	/* we dont want any SIGCHLD */
-	signal(SIGCHLD, SIG_IGN);
-
 	/* go into a wait loop to allow other nodes to complete */
 	event_loop_wait(ctdb->ev);
 
diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index e39332e..8e75f61 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -87,6 +87,7 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
 	ctdb->freeze_handle = NULL;
 
 	kill(h->child, SIGKILL);
+	waitpid(h->child, NULL, 0);
 	return 0;
 }
 
diff --git a/server/ctdb_lockwait.c b/server/ctdb_lockwait.c
index 03a7eed..5b00198 100644
--- a/server/ctdb_lockwait.c
+++ b/server/ctdb_lockwait.c
@@ -72,6 +72,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
 	tdb_chainlock_unmark(tdb, key);
 
 	kill(child, SIGKILL);
+	waitpid(child, NULL, 0);
 	talloc_free(tmp_ctx);
 }
 
@@ -79,6 +80,7 @@ static int lockwait_destructor(struct lockwait_handle *h)
 {
 	h->ctdb->statistics.pending_lockwait_calls--;
 	kill(h->child, SIGKILL);
+	waitpid(h->child, NULL, 0);
 	return 0;
 }
 
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index 713950a..3ba961e 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -222,6 +222,7 @@ static int childwrite_destructor(struct childwrite_handle *h)
 {
 	h->ctdb->statistics.pending_childwrite_calls--;
 	kill(h->child, SIGKILL);
+	waitpid(h->child, NULL, 0);
 	return 0;
 }
 
@@ -259,6 +260,7 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
 	callback(c, p);
 
 	kill(child, SIGKILL);
+	waitpid(child, NULL, 0);
 	talloc_free(tmp_ctx);
 }
 
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index 7b8d28c..29673ea 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -459,6 +459,7 @@ static void ctdb_set_recmode_timeout(struct event_context *ev, struct timed_even
 static int set_recmode_destructor(struct ctdb_set_recmode_state *state)
 {
 	kill(state->child, SIGKILL);
+	waitpid(state->child, NULL, 0);
 	return 0;
 }
 
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index 9059b1c..80443bb 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -2933,6 +2933,11 @@ static void ctdb_check_recd(struct event_context *ev, struct timed_event *te,
 {
 	struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
 
+	/* make sure we harvest the child if signals are blocked for some
+	   reason
+	*/
+	waitpid(ctdb->recoverd_pid, 0, WNOHANG);
+
 	if (kill(ctdb->recoverd_pid, 0) != 0) {
 		DEBUG(DEBUG_ERR,("Recovery daemon (pid:%d) is no longer running. Shutting down main daemon\n", (int)ctdb->recoverd_pid));
 
@@ -3011,9 +3016,6 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 		exit(1);
 	}
 
-	/* we dont want any SIGCHLD */
-	signal(SIGCHLD, SIG_IGN);
-
 	monitor_cluster(ctdb);
 
 	DEBUG(DEBUG_ALERT,("ERROR: ctdb_recoverd finished!?\n"));
diff --git a/server/ctdb_traverse.c b/server/ctdb_traverse.c
index 10895ed..6c84d02 100644
--- a/server/ctdb_traverse.c
+++ b/server/ctdb_traverse.c
@@ -74,6 +74,7 @@ static void ctdb_traverse_local_handler(uint8_t *rawdata, size_t length, void *p
 static int traverse_local_destructor(struct ctdb_traverse_local_handle *h)
 {
 	kill(h->child, SIGKILL);
+	waitpid(h->child, NULL, 0);
 	return 0;
 }
 
diff --git a/server/eventscript.c b/server/eventscript.c
index 9002007..54d914b 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -210,20 +210,18 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 {
 	struct ctdb_event_script_state *state = 
 		talloc_get_type(p, struct ctdb_event_script_state);
+	int status = -1;
 	void (*callback)(struct ctdb_context *, int, void *) = state->callback;
 	void *private_data = state->private_data;
 	struct ctdb_context *ctdb = state->ctdb;
-	signed char rt = -1;
-	int ret;
 
-	ret = read(state->fd[0], &rt, sizeof(rt));
-	if (ret	!= sizeof(rt)) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to read from pipe to eventscript child.\n"));
+	waitpid(state->child, &status, 0);
+	if (status != -1) {
+		status = WEXITSTATUS(status);
 	}
-
 	talloc_set_destructor(state, NULL);
 	talloc_free(state);
-	callback(ctdb, rt, private_data);
+	callback(ctdb, status, private_data);
 
 	ctdb->event_script_timeouts = 0;
 }
@@ -295,6 +293,7 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
 {
 	DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child));
 	kill(state->child, SIGTERM);
+	waitpid(state->child, NULL, 0);
 	return 0;
 }
 
@@ -337,22 +336,13 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 	}
 
 	if (state->child == 0) {
-		signed char rt;
-
 		close(state->fd[0]);
 		if (ctdb->do_setsched) {
 			ctdb_restore_scheduler(ctdb);
 		}
 		set_close_on_exec(state->fd[1]);
-		rt = ctdb_event_script_v(ctdb, state->options);
-		do {
-			ret = write(state->fd[1], &rt, sizeof(rt));
-			if (ret != sizeof(rt)) {
-				DEBUG(DEBUG_ERR, (__location__ " Failed to write to pipe from eventscript child. Trying again in one second\n"));
-				sleep(1);
-			}
-		} while (ret != sizeof(rt));
-		_exit(rt);
+		ret = ctdb_event_script_v(ctdb, state->options);
+		_exit(ret);
 	}
 
 	talloc_set_destructor(state, event_script_destructor);


-- 
CTDB repository


More information about the samba-cvs mailing list