s3: factor out messaging_send_to_children()
authorGregor Beck <gbeck@sernet.de>
Thu, 6 Oct 2011 12:38:20 +0000 (14:38 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 12 Oct 2011 20:45:53 +0000 (22:45 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/include/messages.h
source3/smbd/proto.h
source3/smbd/server.c

index 5ea27f3df17f598273a2608e179fd58a069e0b8c..083cd562562f7abc151e6f6e9a60441685001e86 100644 (file)
@@ -133,6 +133,7 @@ void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
 NTSTATUS messaging_send(struct messaging_context *msg_ctx,
                        struct server_id server, 
                        uint32_t msg_type, const DATA_BLOB *data);
+
 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
                            struct server_id server, uint32_t msg_type,
                            const uint8 *buf, size_t len);
index cf7c90450ad4dcbaf804f2f9a3c2c1f15f3dff48..40281804ccf2152075cd39ca6a6d2dc15aa440ba 100644 (file)
@@ -975,6 +975,8 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
 void exit_server(const char *const explanation);
 void exit_server_cleanly(const char *const explanation);
 void exit_server_fault(void);
+NTSTATUS messaging_send_to_children(struct messaging_context *msg_ctx,
+                                   uint32_t msg_type, DATA_BLOB* data);
 
 /* The following definitions come from smbd/service.c  */
 
index 668cafdb7b9ea1fc7a45bc03c2e9f5e22a5a821e..7771c8578491b60cb4da4e7636534265ff3d201f 100644 (file)
@@ -173,6 +173,22 @@ static void msg_inject_fault(struct messaging_context *msg,
 }
 #endif /* DEVELOPER */
 
+NTSTATUS messaging_send_to_children(struct messaging_context *msg_ctx,
+                                   uint32_t msg_type, DATA_BLOB* data)
+{
+       NTSTATUS status;
+       struct child_pid *child;
+
+       for (child = children; child != NULL; child = child->next) {
+               status = messaging_send(msg_ctx, pid_to_procid(child->pid),
+                                       msg_type, data);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+       }
+       return NT_STATUS_OK;
+}
+
 /*
  * Parent smbd process sets its own debug level first and then
  * sends a message to all the smbd children to adjust their debug
@@ -185,16 +201,9 @@ static void smbd_msg_debug(struct messaging_context *msg_ctx,
                           struct server_id server_id,
                           DATA_BLOB *data)
 {
-       struct child_pid *child;
-
        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);
-       }
+       messaging_send_to_children(msg_ctx, MSG_DEBUG, data);
 }
 
 static void add_child_pid(pid_t pid)