From da85f5a43ea427ce49f9eb5abc1aef3c3491b059 Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Thu, 6 Oct 2011 14:38:20 +0200 Subject: s3: factor out messaging_send_to_children() Signed-off-by: Michael Adam --- source3/smbd/proto.h | 2 ++ source3/smbd/server.c | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index cf7c90450a..40281804cc 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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 */ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 668cafdb7b..7771c85784 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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) -- cgit