[SCM] Samba Shared Repository - branch master updated - d1f7a3717406de855169e88ebc5a9da2318c99ef

Jeremy Allison jra at samba.org
Wed Jan 7 01:36:33 GMT 2009


The branch, master has been updated
       via  d1f7a3717406de855169e88ebc5a9da2318c99ef (commit)
      from  e13983870f00f83420cca554a541165214dc4e06 (commit)

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


- Log -----------------------------------------------------------------
commit d1f7a3717406de855169e88ebc5a9da2318c99ef
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jan 6 17:34:06 2009 -0800

    Make winbindd_cm.c use winbindd_reinit_after_fork().
    Jeremy.

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

Summary of changes:
 source3/winbindd/winbindd.c       |    5 ++++
 source3/winbindd/winbindd_cm.c    |   24 +++++++++-------------
 source3/winbindd/winbindd_dual.c  |   38 ++++++++++++++++++++----------------
 source3/winbindd/winbindd_proto.h |    1 +
 4 files changed, 37 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index cf1dbf6..8f94f8a 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1200,6 +1200,11 @@ int main(int argc, char **argv, char **envp)
 
 	TimeInit();
 
+	/* Don't use winbindd_reinit_after_fork here as
+	 * we're just starting up and haven't created any
+	 * winbindd-specific resources we must free yet. JRA.
+	 */
+
 	if (!reinit_after_fork(winbind_messaging_context(),
 			       winbind_event_context(), false)) {
 		DEBUG(0,("reinit_after_fork() failed\n"));
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index e5e3565..4e5659d 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -172,6 +172,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
 	int num_dcs = 0;
 	TALLOC_CTX *mem_ctx = NULL;
 	pid_t parent_pid = sys_getpid();
+	char *lfile = NULL;
 
 	/* Stop zombies */
 	CatchChild();
@@ -212,9 +213,14 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
 
 	/* Leave messages blocked - we will never process one. */
 
-	if (!reinit_after_fork(winbind_messaging_context(),
-			       winbind_event_context(), true)) {
-		DEBUG(0,("reinit_after_fork() failed\n"));
+	if (!override_logfile) {
+		if (asprintf(&lfile, "%s/log.winbindd-dc-connect", get_dyn_LOGFILEBASE()) == -1) {
+			DEBUG(0, ("fork_child_dc_connect: out of memory.\n"));
+			return false;
+		}
+	}
+
+	if (!winbindd_reinit_after_fork(lfile)) {
 		messaging_send_buf(winbind_messaging_context(),
 				   pid_to_procid(parent_pid),
 				   MSG_WINBIND_FAILED_TO_GO_ONLINE,
@@ -222,17 +228,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
 				   strlen(domain->name)+1);
 		_exit(0);
 	}
-
-	close_conns_after_fork();
-
-	if (!override_logfile) {
-		char *lfile;
-		if (asprintf(&lfile, "%s/log.winbindd-dc-connect", get_dyn_LOGFILEBASE()) > 0) {
-			lp_set_logfile(lfile);
-			SAFE_FREE(lfile);
-			reopen_logs();
-		}
-	}
+	SAFE_FREE(lfile);
 
 	mem_ctx = talloc_init("fork_child_dc_connect");
 	if (!mem_ctx) {
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index d2c085a..c1b1efb 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1142,7 +1142,7 @@ static void child_msg_dump_event_list(struct messaging_context *msg,
 	dump_event_list(winbind_event_context());
 }
 
-static void winbindd_reinit_after_fork(struct winbindd_child *child)
+bool winbindd_reinit_after_fork(const char *logfilename)
 {
 	struct winbindd_domain *domain;
 	struct winbindd_child *cl;
@@ -1150,13 +1150,13 @@ static void winbindd_reinit_after_fork(struct winbindd_child *child)
 	if (!reinit_after_fork(winbind_messaging_context(),
 			       winbind_event_context(), true)) {
 		DEBUG(0,("reinit_after_fork() failed\n"));
-		_exit(0);
+		return false;
 	}
 
 	close_conns_after_fork();
 
-	if (!override_logfile) {
-		lp_set_logfile(child->logfilename);
+	if (!override_logfile && logfilename) {
+		lp_set_logfile(logfilename);
 		reopen_logs();
 	}
 
@@ -1178,18 +1178,6 @@ static void winbindd_reinit_after_fork(struct winbindd_child *child)
 	messaging_deregister(winbind_messaging_context(),
 			     MSG_DEBUG, NULL);
 
-	/* Handle online/offline messages. */
-	messaging_register(winbind_messaging_context(), NULL,
-			   MSG_WINBIND_OFFLINE, child_msg_offline);
-	messaging_register(winbind_messaging_context(), NULL,
-			   MSG_WINBIND_ONLINE, child_msg_online);
-	messaging_register(winbind_messaging_context(), NULL,
-			   MSG_WINBIND_ONLINESTATUS, child_msg_onlinestatus);
-	messaging_register(winbind_messaging_context(), NULL,
-			   MSG_DUMP_EVENT_LIST, child_msg_dump_event_list);
-	messaging_register(winbind_messaging_context(), NULL,
-			   MSG_DEBUG, debug_message);
-
 	/* We have destroyed all events in the winbindd_event_context
 	 * in reinit_after_fork(), so clean out all possible pending
 	 * event pointers. */
@@ -1215,6 +1203,8 @@ static void winbindd_reinit_after_fork(struct winbindd_child *child)
 		TALLOC_FREE(cl->lockout_policy_event);
 		TALLOC_FREE(cl->machine_password_change_event);
         }
+
+	return true;
 }
 
 static bool fork_domain_child(struct winbindd_child *child)
@@ -1268,7 +1258,21 @@ static bool fork_domain_child(struct winbindd_child *child)
 	state.sock = fdpair[0];
 	close(fdpair[1]);
 
-	winbindd_reinit_after_fork(child);
+	if (!winbindd_reinit_after_fork(child->logfilename)) {
+		_exit(0);
+	}
+
+	/* Handle online/offline messages. */
+	messaging_register(winbind_messaging_context(), NULL,
+			   MSG_WINBIND_OFFLINE, child_msg_offline);
+	messaging_register(winbind_messaging_context(), NULL,
+			   MSG_WINBIND_ONLINE, child_msg_online);
+	messaging_register(winbind_messaging_context(), NULL,
+			   MSG_WINBIND_ONLINESTATUS, child_msg_onlinestatus);
+	messaging_register(winbind_messaging_context(), NULL,
+			   MSG_DUMP_EVENT_LIST, child_msg_dump_event_list);
+	messaging_register(winbind_messaging_context(), NULL,
+			   MSG_DEBUG, debug_message);
 
 	primary_domain = find_our_domain();
 
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 32f057a..594f8be 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -350,6 +350,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
 				  uint32_t msg_type,
 				  struct server_id server_id,
 				  DATA_BLOB *data);
+bool winbindd_reinit_after_fork(const char *logfilename);
 
 /* The following definitions come from winbindd/winbindd_group.c  */
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list