[SCM] CTDB repository - branch master updated - 77458b2b6b51b2970c12b0e5b097088d3fb9d358

Ronnie Sahlberg sahlberg at samba.org
Wed Jul 9 04:09:09 GMT 2008


The branch, master has been updated
       via  77458b2b6b51b2970c12b0e5b097088d3fb9d358 (commit)
       via  02ed800f3c09e2a3d56de5ae226708d0953dd4a1 (commit)
       via  cb67382603ffabda7f7f958b494c79b4a3c5ebe2 (commit)
       via  a77850d8baebcf0b216d7c1391da9cce1c43ce2e (commit)
       via  8814997c1b9623397058088dd0e1775cecfe371b (commit)
       via  bd7b254b81dda4d9d62516abf32f93f2503eb9bb (commit)
       via  36be210bbc5e0af75c5fd6e57863272bfa0e942e (commit)
       via  becce6a9a759730d0c675a56516bb0a32a54c9f3 (commit)
      from  8f6cd88e74de24af8dde2b6cabb2348c4f914b99 (commit)

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


- Log -----------------------------------------------------------------
commit 77458b2b6b51b2970c12b0e5b097088d3fb9d358
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 14:02:54 2008 +1000

    proper waitpid() fix.
    remove all waitpid() calls and use the event system to trap sigchld

commit 02ed800f3c09e2a3d56de5ae226708d0953dd4a1
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 13:14:47 2008 +1000

    Revert "pull the development files out into their own package"
    
    This reverts commit 36be210bbc5e0af75c5fd6e57863272bfa0e942e.

commit cb67382603ffabda7f7f958b494c79b4a3c5ebe2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 13:14:34 2008 +1000

    Revert "add spec file for development rpm"
    
    This reverts commit bd7b254b81dda4d9d62516abf32f93f2503eb9bb.

commit a77850d8baebcf0b216d7c1391da9cce1c43ce2e
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 13:14:07 2008 +1000

    Revert "copy ctdb-dev to the spec directory"
    
    This reverts commit 8814997c1b9623397058088dd0e1775cecfe371b.

commit 8814997c1b9623397058088dd0e1775cecfe371b
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 13:07:17 2008 +1000

    copy ctdb-dev to the spec directory

commit bd7b254b81dda4d9d62516abf32f93f2503eb9bb
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 11:37:02 2008 +1000

    add spec file for development rpm

commit 36be210bbc5e0af75c5fd6e57863272bfa0e942e
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 11:32:19 2008 +1000

    pull the development files out into their own package

commit becce6a9a759730d0c675a56516bb0a32a54c9f3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jul 9 11:08:44 2008 +1000

    install the readme in /usr/share/doc/ctdb/ instead of under /etc

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

Summary of changes:
 Makefile.in              |    5 ++++-
 packaging/RPM/ctdb.spec  |    2 +-
 server/ctdb_daemon.c     |   32 ++++++++++++++++++++++++++++++++
 server/ctdb_freeze.c     |    1 -
 server/ctdb_lockwait.c   |    2 --
 server/ctdb_persistent.c |    2 --
 server/ctdb_recover.c    |    1 -
 server/ctdb_recoverd.c   |   37 ++++++++++++++++++++++++++++++++-----
 server/ctdb_traverse.c   |    1 -
 server/eventscript.c     |   20 +++++++++++---------
 10 files changed, 80 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index f85770f..a8fa197 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,10 +1,12 @@
 #!gmake
 
+
 CC = @CC@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 datarootdir = @datarootdir@
 includedir = @includedir@
+docdir = /usr/share/doc
 libdir = @libdir@
 bindir = @bindir@
 sbindir = @sbindir@
@@ -170,6 +172,7 @@ install: all
 	mkdir -p $(DESTDIR)$(includedir)
 	mkdir -p $(DESTDIR)$(etcdir)/ctdb
 	mkdir -p $(DESTDIR)$(etcdir)/ctdb/events.d
+	mkdir -p $(DESTDIR)$(docdir)/ctdb
 	${INSTALLCMD} -m 755 bin/ctdb $(DESTDIR)$(bindir)
 	${INSTALLCMD} -m 755 bin/ctdb_ipmux $(DESTDIR)$(bindir)
 	${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir)
@@ -178,7 +181,7 @@ install: all
 	${INSTALLCMD} -m 644 include/ctdb_private.h $(DESTDIR)$(includedir) # for samba3
 	${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
 	${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
-	${INSTALLCMD} -m 644 config/events.d/README $(DESTDIR)$(etcdir)/ctdb/events.d
+	${INSTALLCMD} -m 644 config/events.d/README $(DESTDIR)/$(docdir)/ctdb/README.eventscripts
 	${INSTALLCMD} -m 755 config/events.d/00.ctdb $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/40.vsftpd $(DESTDIR)$(etcdir)/ctdb/events.d
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index b62e5ad..34e27c7 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -93,7 +93,7 @@ fi
 %config(noreplace) %{_sysconfdir}/ctdb/functions
 %attr(755,root,root) %{initdir}/ctdb
 
-%{_sysconfdir}/ctdb/events.d/README
+%{_docdir}/ctdb/README.eventscripts
 %{_sysconfdir}/ctdb/events.d/00.ctdb
 %{_sysconfdir}/ctdb/events.d/10.interface
 %{_sysconfdir}/ctdb/events.d/40.vsftpd
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 326ab60..c153a97 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -628,6 +628,27 @@ static int unlink_destructor(const char *name)
 	return 0;
 }
 
+static void sig_child_handler(struct event_context *ev,
+	struct signal_event *se, int signum, int count,
+	void *dont_care, 
+	void *private_data)
+{
+//	struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
+	int status;
+	pid_t pid = -1;
+
+	while (pid != 0) {
+		pid = waitpid(-1, &status, WNOHANG);
+		if (pid == -1) {
+			DEBUG(DEBUG_ERR, (__location__ " waitpid() returned error. errno:%d\n", errno));
+			return;
+		}
+		if (pid > 0) {
+			DEBUG(DEBUG_DEBUG, ("SIGCHLD from %d\n", (int)pid));
+		}
+	}
+}
+
 /*
   start the protocol going as a daemon
 */
@@ -636,6 +657,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	int res, ret = -1;
 	struct fd_event *fde;
 	const char *domain_socket_name;
+	struct signal_event *se;
 
 	/* get rid of any old sockets */
 	unlink(ctdb->daemon.name);
@@ -731,6 +753,16 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	/* start the transport going */
 	ctdb_start_transport(ctdb);
 
+	/* set up a handler to pick up sigchld */
+	se = event_add_signal(ctdb->ev, ctdb,
+				     SIGCHLD, 0,
+				     sig_child_handler,
+				     ctdb);
+	if (se == NULL) {
+		DEBUG(DEBUG_CRIT,("Failed to set up signal handler for SIGCHLD\n"));
+		exit(1);
+	}
+	  
 	/* 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 8e75f61..e39332e 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -87,7 +87,6 @@ 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 5b00198..03a7eed 100644
--- a/server/ctdb_lockwait.c
+++ b/server/ctdb_lockwait.c
@@ -72,7 +72,6 @@ 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);
 }
 
@@ -80,7 +79,6 @@ 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 3ba961e..713950a 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -222,7 +222,6 @@ 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;
 }
 
@@ -260,7 +259,6 @@ 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 29673ea..7b8d28c 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -459,7 +459,6 @@ 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 80443bb..69d867a 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -2933,11 +2933,6 @@ 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));
 
@@ -2958,6 +2953,27 @@ static void ctdb_check_recd(struct event_context *ev, struct timed_event *te,
 			ctdb_check_recd, ctdb);
 }
 
+static void recd_sig_child_handler(struct event_context *ev,
+	struct signal_event *se, int signum, int count,
+	void *dont_care, 
+	void *private_data)
+{
+//	struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
+	int status;
+	pid_t pid = -1;
+
+	while (pid != 0) {
+		pid = waitpid(-1, &status, WNOHANG);
+		if (pid == -1) {
+			DEBUG(DEBUG_ERR, (__location__ " waitpid() returned error. errno:%d\n", errno));
+			return;
+		}
+		if (pid > 0) {
+			DEBUG(DEBUG_DEBUG, ("RECD SIGCHLD from %d\n", (int)pid));
+		}
+	}
+}
+
 /*
   startup the recovery daemon as a child of the main ctdb daemon
  */
@@ -2965,6 +2981,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 {
 	int ret;
 	int fd[2];
+	struct signal_event *se;
 
 	if (pipe(fd) != 0) {
 		return -1;
@@ -3016,6 +3033,16 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 		exit(1);
 	}
 
+	/* set up a handler to pick up sigchld */
+	se = event_add_signal(ctdb->ev, ctdb,
+				     SIGCHLD, 0,
+				     recd_sig_child_handler,
+				     ctdb);
+	if (se == NULL) {
+		DEBUG(DEBUG_CRIT,("Failed to set up signal handler for SIGCHLD in recovery daemon\n"));
+		exit(1);
+	}
+
 	monitor_cluster(ctdb);
 
 	DEBUG(DEBUG_ALERT,("ERROR: ctdb_recoverd finished!?\n"));
diff --git a/server/ctdb_traverse.c b/server/ctdb_traverse.c
index 6c84d02..10895ed 100644
--- a/server/ctdb_traverse.c
+++ b/server/ctdb_traverse.c
@@ -74,7 +74,6 @@ 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 54d914b..1d42b2b 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -210,18 +210,16 @@ 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;
+
+	read(state->fd[0], &rt, sizeof(rt));
 
-	waitpid(state->child, &status, 0);
-	if (status != -1) {
-		status = WEXITSTATUS(status);
-	}
 	talloc_set_destructor(state, NULL);
 	talloc_free(state);
-	callback(ctdb, status, private_data);
+	callback(ctdb, rt, private_data);
 
 	ctdb->event_script_timeouts = 0;
 }
@@ -293,7 +291,6 @@ 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;
 }
 
@@ -336,13 +333,18 @@ 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]);
-		ret = ctdb_event_script_v(ctdb, state->options);
-		_exit(ret);
+		rt = ctdb_event_script_v(ctdb, state->options);
+		while ((ret = write(state->fd[1], &rt, sizeof(rt))) != sizeof(rt)) {
+			sleep(1);
+		}
+		_exit(rt);
 	}
 
 	talloc_set_destructor(state, event_script_destructor);


-- 
CTDB repository


More information about the samba-cvs mailing list