[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-995-g2e1b913

Stefan Metzmacher metze at samba.org
Sat Apr 19 00:14:56 GMT 2008


The branch, v3-2-test has been updated
       via  2e1b9130635235efdbf49d0b92a43b342114246c (commit)
       via  8e9fdef792e612e414444e7714a2fd4513892248 (commit)
       via  056ff094ad2c59992cfdb8b29696c08dab4113d7 (commit)
       via  f68829ff14c457bfa98cb2ef9e8ec2e1a0b1d64d (commit)
       via  9adb675a86e81c90e2bddfe984b5ac8f201fec75 (commit)
       via  658d8475336c4397e0dad341f216baf9e1eb6aaf (commit)
       via  425b3513a45cf98b53235470a3536be86d56d1c2 (commit)
       via  6b5c76bf1e880ec60d6b044c58115940549049e5 (commit)
       via  5f6c3a4f6db68c985884cbe9401a4dbe515f756b (commit)
       via  16d295d466eb18e3bccce6fb26d53012d5f2c3e8 (commit)
       via  6f67c4ddf8101b1d06889055e3767a6ce0db360c (commit)
       via  259786980a3a65fa67a4de12a65d33095fa53ce2 (commit)
      from  e1abff301449ad528194206fd953670057eaa12d (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 2e1b9130635235efdbf49d0b92a43b342114246c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:57:16 2008 +0200

    winbindd: create the messaging conntext earlier
    
    metze

commit 8e9fdef792e612e414444e7714a2fd4513892248
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:02:42 2008 +0200

    winbindd: call reinit_after_fork() in the child processes
    
    metze

commit 056ff094ad2c59992cfdb8b29696c08dab4113d7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:50:27 2008 +0200

    nmbd: create the messaging conntext earlier
    
    metze

commit f68829ff14c457bfa98cb2ef9e8ec2e1a0b1d64d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:38:21 2008 +0200

    nmbd: call reinit_after_fork() in all needed cases
    
    metze

commit 9adb675a86e81c90e2bddfe984b5ac8f201fec75
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:48:44 2008 +0200

    printing: call reinit_after_fork() in the backgroundqueue process
    
    metze

commit 658d8475336c4397e0dad341f216baf9e1eb6aaf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:57:45 2008 +0200

    smbd: create the messaging conntext earlier
    
    metze

commit 425b3513a45cf98b53235470a3536be86d56d1c2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:01:59 2008 +0200

    smbd: call reinit_after_fork() in the needed places
    
    metze

commit 6b5c76bf1e880ec60d6b044c58115940549049e5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Apr 18 10:20:01 2008 +0200

    loadparm: make it possible to just load the config without following "include =" statements
    
    metze

commit 5f6c3a4f6db68c985884cbe9401a4dbe515f756b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:36:15 2008 +0200

    util: add reinit_after_fork() function
    
    metze

commit 16d295d466eb18e3bccce6fb26d53012d5f2c3e8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:50:13 2008 +0200

    smbd: merge "smbd:backgroundqueue=no" option from the v3-0-ctdb tree
    
    metze

commit 6f67c4ddf8101b1d06889055e3767a6ce0db360c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:18:50 2008 +0200

    messages_ctdbd: autocreate a ctdb connection, this will fix segfaults in the client tools
    
    metze

commit 259786980a3a65fa67a4de12a65d33095fa53ce2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:18:06 2008 +0200

    messages_ctdbd: make sure a ctdbd connection is only used in the process that created it
    
    metze

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

Summary of changes:
 source/lib/messages_ctdbd.c     |   30 +++++++++++++++++++++-
 source/lib/util.c               |   30 ++++++++++++++++++++++
 source/nmbd/asyncdns.c          |    5 +++
 source/nmbd/nmbd.c              |   20 ++++++++++++--
 source/param/loadparm.c         |   53 +++++++++++++++++++++++++++++++-------
 source/printing/printing.c      |    5 +++
 source/smbd/server.c            |   49 +++++++++++++++++-------------------
 source/winbindd/winbindd.c      |   24 ++++++++++++-----
 source/winbindd/winbindd_cm.c   |    5 +--
 source/winbindd/winbindd_dual.c |    5 +--
 10 files changed, 173 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/messages_ctdbd.c b/source/lib/messages_ctdbd.c
index f1a02e6..a01c5e0 100644
--- a/source/lib/messages_ctdbd.c
+++ b/source/lib/messages_ctdbd.c
@@ -35,10 +35,36 @@ struct messaging_ctdbd_context {
  * This is a Samba3 hack/optimization. Routines like process_exists need to
  * talk to ctdbd, and they don't get handed a messaging context.
  */
-struct ctdbd_connection *global_ctdbd_connection;
+static struct ctdbd_connection *global_ctdbd_connection;
+static int global_ctdb_connection_pid;
 
 struct ctdbd_connection *messaging_ctdbd_connection(void)
 {
+	if (global_ctdb_connection_pid == 0 &&
+	    global_ctdbd_connection == NULL) {
+		struct event_context *ev;
+		struct messaging_context *msg;
+
+		ev = event_context_init(NULL);
+		if (!msg) {
+			DEBUG(0,("event_context_init failed\n"));
+		}
+
+		msg = messaging_init(NULL, procid_self(), ev);
+		if (!msg) {
+			DEBUG(0,("messaging_init failed\n"));
+		}
+
+		db_tdb2_setup_messaging(msg, false);
+	}
+
+	if (global_ctdb_connection_pid != getpid()) {
+		DEBUG(0,("messaging_ctdbd_connection():"
+			 "valid for pid[%d] but it's [%d]\n",
+			 global_ctdb_connection_pid, getpid()));
+		smb_panic("messaging_ctdbd_connection() invalid process\n");
+	}
+
 	return global_ctdbd_connection;
 }
 
@@ -66,6 +92,7 @@ static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
 	/*
 	 * The global connection just went away
 	 */
+	global_ctdb_connection_pid = 0;
 	global_ctdbd_connection = NULL;
 	return 0;
 }
@@ -107,6 +134,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
 		return status;
 	}
 
+	global_ctdb_connection_pid = getpid();
 	global_ctdbd_connection = ctx->conn;
 	talloc_set_destructor(ctx, messaging_ctdbd_destructor);
 
diff --git a/source/lib/util.c b/source/lib/util.c
index b52cc69..db0da54 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -990,6 +990,36 @@ void become_daemon(bool Fork, bool no_process_group)
 				  attach it to the logfile */
 }
 
+bool reinit_after_fork(struct messaging_context *msg_ctx)
+{
+	NTSTATUS status;
+
+	/* Reset the state of the random
+	 * number generation system, so
+	 * children do not get the same random
+	 * numbers as each other */
+	set_need_random_reseed();
+
+	/* tdb needs special fork handling */
+	if (tdb_reopen_all(1) == -1) {
+		DEBUG(0,("tdb_reopen_all failed.\n"));
+		return false;
+	}
+
+	/*
+	 * For clustering, we need to re-init our ctdbd connection after the
+	 * fork
+	 */
+	status = messaging_reinit(msg_ctx);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0,("messaging_reinit() failed: %s\n",
+			 nt_errstr(status)));
+		return false;
+	}
+
+	return true;
+}
+
 /****************************************************************************
  Put up a yes/no prompt.
 ****************************************************************************/
diff --git a/source/nmbd/asyncdns.c b/source/nmbd/asyncdns.c
index 5e55659..0329491 100644
--- a/source/nmbd/asyncdns.c
+++ b/source/nmbd/asyncdns.c
@@ -164,6 +164,11 @@ void start_async_dns(void)
 	CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, SIGNAL_CAST sig_term );
 
+	if (!reinit_after_fork(nmbd_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
+		smb_panic("reinit_after_fork() failed");
+	}
+
 	asyncdns_process();
 }
 
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index 01fdbbc..9396219 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -762,6 +762,8 @@ static bool open_sockets(bool isdaemon, int port)
 	};
 	TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
 
+	db_tdb2_setup_messaging(NULL, false);
+
 	load_case_tables();
 
 	global_nmb_port = NMB_PORT;
@@ -847,7 +849,16 @@ static bool open_sockets(bool isdaemon, int port)
 	DEBUG(0,("nmbd version %s started.\n", SAMBA_VERSION_STRING));
 	DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
-	db_tdb2_setup_messaging(NULL, false);
+	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+		DEBUG(0, ("error opening config file\n"));
+		exit(1);
+	}
+
+	if (nmbd_messaging_context() == NULL) {
+		return 1;
+	}
+
+	db_tdb2_setup_messaging(nmbd_messaging_context(), true);
 
 	if ( !reload_nmbd_services(False) )
 		return(-1);
@@ -901,6 +912,11 @@ static bool open_sockets(bool isdaemon, int port)
 
 	pidfile_create("nmbd");
 
+	if (!reinit_after_fork(nmbd_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
+		exit(1);
+	}
+
 	/* get broadcast messages */
 	claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
 
@@ -918,8 +934,6 @@ static bool open_sockets(bool isdaemon, int port)
 	messaging_register(nmbd_messaging_context(), NULL,
 			   MSG_SEND_PACKET, msg_nmbd_send_packet);
 
-	db_tdb2_setup_messaging(nmbd_messaging_context(), true);
-
 	TimeInit();
 
 	DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 9595ebd..84e8c1a 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -6727,11 +6727,16 @@ static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **pt
 /***************************************************************************
  Handle the include operation.
 ***************************************************************************/
+static bool bNoIncludes = false;
 
 static bool handle_include(int snum, const char *pszParmValue, char **ptr)
 {
 	char *fname;
 
+	if (bNoIncludes) {
+		return true;
+	}
+
 	if (strequal(pszParmValue, INCLUDE_REGISTRY_NAME)) {
 		if (bInGlobalSection) {
 			return process_registry_globals();
@@ -8651,11 +8656,12 @@ bool lp_is_in_client(void)
  False on failure.
 ***************************************************************************/
 
-bool lp_load(const char *pszFname,
-             bool global_only,
-             bool save_defaults,
-	     bool add_ipc,
-             bool initialize_globals)
+bool lp_load_ex(const char *pszFname,
+		bool global_only,
+		bool save_defaults,
+		bool add_ipc,
+		bool initialize_globals,
+		bool no_includes)
 {
 	char *n2 = NULL;
 	bool bRetval;
@@ -8663,10 +8669,11 @@ bool lp_load(const char *pszFname,
 
 	bRetval = False;
 
-	DEBUG(3, ("lp_load: refreshing parameters\n"));
+	DEBUG(3, ("lp_load_ex: refreshing parameters\n"));
 
 	bInGlobalSection = True;
 	bGlobalOnly = global_only;
+	bNoIncludes = no_includes;
 
 	init_globals(! initialize_globals);
 	debug_init();
@@ -8694,7 +8701,7 @@ bool lp_load(const char *pszFname,
 					current_user_info.domain,
 					pszFname);
 		if (!n2) {
-			smb_panic("lp_load: out of memory");
+			smb_panic("lp_load_ex: out of memory");
 		}
 
 		add_to_file_list(pszFname, n2);
@@ -8722,12 +8729,12 @@ bool lp_load(const char *pszFname,
 			 */
 			config_backend = CONFIG_BACKEND_REGISTRY;
 			/* start over */
-			DEBUG(1, ("lp_load: changing to config backend "
+			DEBUG(1, ("lp_load_ex: changing to config backend "
 				  "registry\n"));
 			init_globals(false);
 			lp_kill_all_services();
-			return lp_load(pszFname, global_only, save_defaults,
-				       add_ipc, initialize_globals);
+			return lp_load_ex(pszFname, global_only, save_defaults,
+				          add_ipc, initialize_globals, no_includes);
 		}
 	} else if (lp_config_backend_is_registry()) {
 		bRetval = process_registry_globals();
@@ -8762,9 +8769,35 @@ bool lp_load(const char *pszFname,
 
 	init_iconv();
 
+	bNoIncludes = false;
+
 	return (bRetval);
 }
 
+bool lp_load(const char *pszFname,
+	     bool global_only,
+	     bool save_defaults,
+	     bool add_ipc,
+	     bool initialize_globals)
+{
+	return lp_load_ex(pszFname,
+			  global_only,
+			  save_defaults,
+			  add_ipc,
+			  initialize_globals,
+			  false);
+}
+
+bool lp_load_initial_only(const char *pszFname)
+{
+	return lp_load_ex(pszFname,
+			  true,
+			  false,
+			  false,
+			  true,
+			  true);
+}
+
 /***************************************************************************
  Reset the max number of services.
 ***************************************************************************/
diff --git a/source/printing/printing.c b/source/printing/printing.c
index eb304e7..fdf5e6c 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -1406,6 +1406,11 @@ void start_background_queue(void)
 		/* Child. */
 		DEBUG(5,("start_background_queue: background LPQ thread started\n"));
 
+		if (!reinit_after_fork(smbd_messaging_context())) {
+			DEBUG(0,("reinit_after_fork() failed\n"));
+			smb_panic("reinit_after_fork() failed");
+		}
+
 		claim_connection( NULL, "smbd lpq backend",
 			FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
 
diff --git a/source/smbd/server.c b/source/smbd/server.c
index b71d627..59bbfdb 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -575,8 +575,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
 			   MSG_SMB_INJECT_FAULT, msg_inject_fault);
 #endif
 
-	db_tdb2_setup_messaging(smbd_messaging_context(), true);
-
 	/* now accept incoming connections - forking a new process
 	   for each incoming connection */
 	DEBUG(2,("waiting for a connection\n"));
@@ -741,17 +739,9 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
 								sizeof(remaddr)),
 								false);
 
-				/* Reset the state of the random
-				 * number generation system, so
-				 * children do not get the same random
-				 * numbers as each other */
-
-				set_need_random_reseed();
-				/* tdb needs special fork handling - remove
-				 * CLEAR_IF_FIRST flags */
-				if (tdb_reopen_all(1) == -1) {
-					DEBUG(0,("tdb_reopen_all failed.\n"));
-					smb_panic("tdb_reopen_all failed");
+				if (!reinit_after_fork(smbd_messaging_context())) {
+					DEBUG(0,("reinit_after_fork() failed\n"));
+					smb_panic("reinit_after_fork() failed");
 				}
 
 				return True;
@@ -1103,6 +1093,8 @@ extern void build_options(bool screen);
 
 	TimeInit();
 
+	db_tdb2_setup_messaging(NULL, false);
+
 #ifdef HAVE_SET_AUTH_PARAMETERS
 	set_auth_parameters(argc,argv);
 #endif
@@ -1226,10 +1218,18 @@ extern void build_options(bool screen);
 		exit(1);
 	}
 
+	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+		DEBUG(0, ("error opening config file\n"));
+		exit(1);
+	}
+
+	if (smbd_messaging_context() == NULL)
+		exit(1);
+
 	/*
 	 * Do this before reload_services.
 	 */
-	db_tdb2_setup_messaging(NULL, false);
+	db_tdb2_setup_messaging(smbd_messaging_context(), true);
 
 	if (!reload_services(False))
 		return(-1);	
@@ -1285,10 +1285,12 @@ extern void build_options(bool screen);
 	if (is_daemon)
 		pidfile_create("smbd");
 
-	/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
-
-	if (smbd_messaging_context() == NULL)
+	if (!reinit_after_fork(smbd_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
 		exit(1);
+	}
+
+	/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */
 
 	if (smbd_memcache() == NULL) {
 		exit(1);
@@ -1344,8 +1346,10 @@ extern void build_options(bool screen);
 	   smbd is launched via inetd and we fork a copy of 
 	   ourselves here */
 
-	if ( is_daemon && !interactive )
-		start_background_queue(); 
+	if (is_daemon && !interactive
+	    && lp_parm_bool(-1, "smbd", "backgroundqueue", true)) {
+		start_background_queue();
+	}
 
 	if (!open_sockets_smbd(is_daemon, interactive, ports))
 		exit(1);
@@ -1382,13 +1386,6 @@ extern void build_options(bool screen);
 	/* Setup aio signal handler. */
 	initialize_async_io_handler();
 
-	/*
-	 * For clustering, we need to re-init our ctdbd connection after the
-	 * fork
-	 */
-	if (!NT_STATUS_IS_OK(messaging_reinit(smbd_messaging_context())))
-		exit(1);
-
 	/* register our message handlers */
 	messaging_register(smbd_messaging_context(), NULL,
 			   MSG_SMB_FORCE_TDIS, msg_force_tdis);
diff --git a/source/winbindd/winbindd.c b/source/winbindd/winbindd.c
index ff9bbf1..64674b8 100644
--- a/source/winbindd/winbindd.c
+++ b/source/winbindd/winbindd.c
@@ -1023,6 +1023,8 @@ int main(int argc, char **argv, char **envp)
 
 	load_case_tables();
 
+	db_tdb2_setup_messaging(NULL, false);
+
 	/* Initialise for running in non-root mode */
 
 	sec_init();
@@ -1102,7 +1104,19 @@ int main(int argc, char **argv, char **envp)
 	DEBUG(0,("winbindd version %s started.\n", SAMBA_VERSION_STRING));
 	DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
-	db_tdb2_setup_messaging(NULL, false);
+	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+		DEBUG(0, ("error opening config file\n"));
+		exit(1);
+	}
+
+	/* Initialise messaging system */
+
+	if (winbind_messaging_context() == NULL) {
+		DEBUG(0, ("unable to initialize messaging system\n"));
+		exit(1);
+	}
+
+	db_tdb2_setup_messaging(winbind_messaging_context(), true);
 
 	if (!reload_services_file()) {
 		DEBUG(0, ("error opening config file\n"));
@@ -1175,10 +1189,8 @@ int main(int argc, char **argv, char **envp)
 
 	TimeInit();
 
-	/* Initialise messaging system */
-
-	if (winbind_messaging_context() == NULL) {
-		DEBUG(0, ("unable to initialize messaging system\n"));
+	if (!reinit_after_fork(winbind_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
 		exit(1);
 	}
 
@@ -1219,8 +1231,6 @@ int main(int argc, char **argv, char **envp)
 			   MSG_WINBIND_DUMP_DOMAIN_LIST,
 			   winbind_msg_dump_domain_list);
 
-	db_tdb2_setup_messaging(winbind_messaging_context(), true);
-
 	netsamlogon_cache_init(); /* Non-critical */
 	
 	/* clear the cached list of trusted domains */
diff --git a/source/winbindd/winbindd_cm.c b/source/winbindd/winbindd_cm.c
index adb631b..fc1a9ca 100644
--- a/source/winbindd/winbindd_cm.c
+++ b/source/winbindd/winbindd_cm.c
@@ -199,9 +199,8 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
 
 	/* Leave messages blocked - we will never process one. */
 
-	/* tdb needs special fork handling */
-	if (tdb_reopen_all(1) == -1) {
-		DEBUG(0,("tdb_reopen_all failed.\n"));
+	if (!reinit_after_fork(winbind_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
 		_exit(0);
 	}
 
diff --git a/source/winbindd/winbindd_dual.c b/source/winbindd/winbindd_dual.c
index 3c342e5..77fbe3c 100644
--- a/source/winbindd/winbindd_dual.c
+++ b/source/winbindd/winbindd_dual.c
@@ -1005,9 +1005,8 @@ static bool fork_domain_child(struct winbindd_child *child)
 	state.sock = fdpair[0];
 	close(fdpair[1]);
 
-	/* tdb needs special fork handling */
-	if (tdb_reopen_all(1) == -1) {
-		DEBUG(0,("tdb_reopen_all failed.\n"));
+	if (!reinit_after_fork(winbind_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
 		_exit(0);
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list