[SCM] CTDB repository - branch master updated - ctdb-1.0.109-3-g843a2ed

Ronnie Sahlberg sahlberg at samba.org
Thu Dec 17 18:32:05 MST 2009


The branch, master has been updated
       via  843a2ed5ef85f628788b0caf7417c6b61b5c6d3f (commit)
       via  7101ae80bf4e530f48e31e4c58707aa45a9fd3d5 (commit)
       via  140070dd81b39545fe2d56f70e9b9c96bfdae07f (commit)
      from  99894a70fe2ebfe43daae7e88ff0fc9cab33e0fb (commit)

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


- Log -----------------------------------------------------------------
commit 843a2ed5ef85f628788b0caf7417c6b61b5c6d3f
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Fri Dec 18 11:54:24 2009 +1030

    eventscript: fix cleanup path when setting up script list
    
    We shouldn't set ctdb->current_monitor until we set destructor: that's
    what cleans it up.
    
    Also, free state->scripts on no-scripts exit path: it's not a child of
    state because we need it in the destructor.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 7101ae80bf4e530f48e31e4c58707aa45a9fd3d5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 17 13:04:27 2009 +0100

    server: add set_close_on_exec() on more fds
    
    metze

commit 140070dd81b39545fe2d56f70e9b9c96bfdae07f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Dec 17 13:03:42 2009 +0100

    server: fix fd leaks in the new logging code
    
    metze

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

Summary of changes:
 server/ctdb_logging.c |   10 ++++++++--
 server/eventscript.c  |    9 +++++----
 2 files changed, 13 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
index de25865..22baea4 100644
--- a/server/ctdb_logging.c
+++ b/server/ctdb_logging.c
@@ -121,6 +121,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 	syslog(LOG_ERR, "Starting SYSLOG daemon with pid:%d", (int)getpid());
 
 	close(state->fd[0]);
+	set_close_on_exec(state->fd[1]);
 	event_add_fd(ctdb->ev, state, state->fd[1], EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
 		     ctdb_syslog_terminate_handler, state);
 
@@ -130,6 +131,8 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 		return -1;
 	}
 
+	set_close_on_exec(state->syslog_fd);
+
 	syslog_sin.sin_family = AF_INET;
 	syslog_sin.sin_port   = htons(CTDB_PORT);
 	syslog_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);	
@@ -479,8 +482,10 @@ struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
 	}
 
 	log->pfd = p[0];
+	set_close_on_exec(log->pfd);
 	talloc_set_destructor(log, log_context_destructor);
-	event_add_fd(ctdb->ev, log, log->pfd, EVENT_FD_READ,
+	event_add_fd(ctdb->ev, log, log->pfd,
+		     EVENT_FD_READ | EVENT_FD_AUTOCLOSE,
 		     ctdb_log_handler, log);
 	return log;
 
@@ -511,7 +516,8 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
 		return -1;
 	}
 
-	event_add_fd(ctdb->ev, ctdb->log, p[0], EVENT_FD_READ, 
+	event_add_fd(ctdb->ev, ctdb->log, p[0],
+		     EVENT_FD_READ | EVENT_FD_AUTOCLOSE,
 		     ctdb_log_handler, ctdb->log);
 	set_close_on_exec(p[0]);
 	ctdb->log->pfd = p[0];
diff --git a/server/eventscript.c b/server/eventscript.c
index 803ac1d..b022407 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -638,10 +638,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 		ctdb->current_monitor = NULL;
 	}
 
-	if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
-		ctdb->current_monitor = state;
-	}
-
 	DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s %s\n",
 			  ctdb_eventscript_call_names[state->call],
 			  state->options));
@@ -657,6 +653,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 	/* Nothing to do? */
 	if (state->scripts->num_scripts == 0) {
 		ctdb->event_script_timeouts = 0;
+		talloc_free(state->scripts);
 		talloc_free(state);
 		return 0;
 	}
@@ -668,6 +665,10 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 		return -1;
 	}
 
+	if (!from_user && (call == CTDB_EVENT_MONITOR || call == CTDB_EVENT_STATUS)) {
+		ctdb->current_monitor = state;
+	}
+
 	talloc_set_destructor(state, event_script_destructor);
 	if (!timeval_is_zero(&state->timeout)) {
 		event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);


-- 
CTDB repository


More information about the samba-cvs mailing list