[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-40-g5a4d618

Steven Danneman sdanneman at samba.org
Tue Jun 23 02:10:13 GMT 2009


The branch, master has been updated
       via  5a4d61810961af199859dfb52981632bfe594e95 (commit)
      from  36a8abce4f737102b5a2acf3c0e221391079831d (commit)

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


- Log -----------------------------------------------------------------
commit 5a4d61810961af199859dfb52981632bfe594e95
Author: Aravind Srinivasan <aravind.srinivasan at isilon.com>
Date:   Tue Jun 16 15:11:32 2009 -0700

    s3: forward MSG_DEBUG from smbd parent to all children
    
    Before 3.3, an smbcontrol debug message sent to the target "smbd" would
    actually be sent to all running processes including nmbd and winbindd.
    This behavior was changed in 3.3 so that the "smbd" target would only
    send a message to the process found in smbd.pid, while the "all" target
    would send a message to all processes.
    
    The ability to set the debug level of all processes within a single
    daemon, without specifying each pid is quite useful.  This was implemented
    in winbindd in 065760ed.  This patch does the same thing for smbd.
    
    Upon receiving a MSG_DEBUG the parent smbd will rebroadcast it to all of
    its children.
    
    The printing process has been added to the list of smbd child processes,
    and we now always track the number of smbd children regardless of the
    "max smbd processes" setting.

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

Summary of changes:
 docs-xml/manpages-3/smbcontrol.1.xml |    5 +++-
 source3/include/smb.h                |    6 +++++
 source3/printing/printing.c          |   19 ++++++++++++++++
 source3/smbd/process.c               |    9 +++++++
 source3/smbd/server.c                |   39 +++++++++++++++++++++------------
 5 files changed, 63 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/smbcontrol.1.xml b/docs-xml/manpages-3/smbcontrol.1.xml
index bb0aa30..c41dadc 100644
--- a/docs-xml/manpages-3/smbcontrol.1.xml
+++ b/docs-xml/manpages-3/smbcontrol.1.xml
@@ -121,7 +121,10 @@
 	<varlistentry>
 	<term>debug</term>
 	<listitem><para>Set debug level to the value specified by the 
-	parameter. This can be sent to any of the destinations.</para>
+	parameter. This can be sent to any of the destinations. If this
+	message is sent to either the smbd or winbindd daemons, the parent
+	process will rebroadcast the message to all child processes changing
+	the debug level in each one.</para>
 	</listitem>
 	</varlistentry>
 
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 4eed68f..87fd2b0 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1927,4 +1927,10 @@ struct smb_filename {
 	SMB_STRUCT_STAT st;
 };
 
+/* struct for maintaining the child processes that get spawned from smbd */
+struct child_pid {
+	struct child_pid *prev, *next;
+	pid_t pid;
+};
+
 #endif /* _SMB_H */
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index e73669f..986176d 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1399,6 +1399,22 @@ static void printing_pause_fd_handler(struct tevent_context *ev,
 	exit_server_cleanly(NULL);
 }
 
+static void add_child_pid(pid_t pid)
+{
+	extern struct child_pid *children;
+	struct child_pid *child;
+	extern int num_children;
+
+        child = SMB_MALLOC_P(struct child_pid);
+        if (child == NULL) {
+                DEBUG(0, ("Could not add child struct -- malloc failed\n"));
+                return;
+        }
+        child->pid = pid;
+        DLIST_ADD(children, child);
+        num_children += 1;
+}
+
 static pid_t background_lpq_updater_pid = -1;
 
 /****************************************************************************
@@ -1426,6 +1442,9 @@ void start_background_queue(void)
 		exit(1);
 	}
 
+	/* Track the printing pid along with other smbd children */
+	add_child_pid(background_lpq_updater_pid);
+
 	if(background_lpq_updater_pid == 0) {
 		struct tevent_fd *fde;
 		int ret;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 0a3777a..b26bc15 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -2103,6 +2103,15 @@ void smbd_process(void)
 	messaging_register(smbd_messaging_context(), NULL,
 			   MSG_SMB_CLOSE_FILE, msg_close_file);
 
+	/*
+	 * Use the default MSG_DEBUG handler to avoid rebroadcasting
+	 * MSGs to all child processes
+	 */
+	messaging_deregister(smbd_messaging_context(),
+			     MSG_DEBUG, NULL);
+	messaging_register(smbd_messaging_context(), NULL,
+			   MSG_DEBUG, debug_message);
+
 	if ((lp_keepalive() != 0)
 	    && !(event_add_idle(smbd_event_context(), NULL,
 				timeval_set(lp_keepalive(), 0),
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 5b474d8..6951fac 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -180,19 +180,33 @@ static void msg_inject_fault(struct messaging_context *msg,
 }
 #endif /* DEVELOPER */
 
-struct child_pid {
-	struct child_pid *prev, *next;
-	pid_t pid;
-};
-
-static void add_child_pid(pid_t pid)
+/*
+ * Parent smbd process sets its own debug level first and then
+ * sends a message to all the smbd children to adjust their debug
+ * level to that of the parent.
+ */
+
+static void smbd_msg_debug(struct messaging_context *msg_ctx,
+			   void *private_data,
+			   uint32_t msg_type,
+			   struct server_id server_id,
+			   DATA_BLOB *data)
 {
 	struct child_pid *child;
 
-	if (lp_max_smbd_processes() == 0) {
-		/* Don't bother with the child list if we don't care anyway */
-		return;
+	debug_message(msg_ctx, private_data, MSG_DEBUG, server_id, data);
+
+	for (child = children; child != NULL; child = child->next) {
+		messaging_send_buf(msg_ctx, pid_to_procid(child->pid),
+				   MSG_DEBUG,
+				   data->data,
+				   strlen((char *) data->data) + 1);
 	}
+}
+
+static void add_child_pid(pid_t pid)
+{
+	struct child_pid *child;
 
 	child = SMB_MALLOC_P(struct child_pid);
 	if (child == NULL) {
@@ -219,11 +233,6 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown)
 				 MSG_SMB_UNLOCK, NULL, 0, NULL);
 	}
 
-	if (lp_max_smbd_processes() == 0) {
-		/* Don't bother with the child list if we don't care anyway */
-		return;
-	}
-
 	for (child = children; child != NULL; child = child->next) {
 		if (child->pid == pid) {
 			struct child_pid *tmp = child;
@@ -636,6 +645,8 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
 			   MSG_SMB_CONF_UPDATED, smb_conf_updated);
 	messaging_register(smbd_messaging_context(), NULL,
 			   MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete);
+	messaging_register(smbd_messaging_context(), NULL,
+			   MSG_DEBUG, smbd_msg_debug);
 	brl_register_msgs(smbd_messaging_context());
 
 #ifdef CLUSTER_SUPPORT


-- 
Samba Shared Repository


More information about the samba-cvs mailing list