summaryrefslogtreecommitdiff
path: root/source3/utils/smbcontrol.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-05-06 11:23:03 +0200
committerChristof Schmitt <cs@samba.org>2014-01-06 13:27:05 -0700
commit84d8b2b01324433f7d0861042c53ffcb57dc3ccf (patch)
treea6c9ff34459776b61e9585529766bd5db273e0a9 /source3/utils/smbcontrol.c
parent168db8b9d29ebf7e59377204ea0886b7ff281f27 (diff)
downloadsamba-84d8b2b01324433f7d0861042c53ffcb57dc3ccf.tar.gz
smbd: Make "num_children" available by smbcontrol
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmit <cs@samba.org>
Diffstat (limited to 'source3/utils/smbcontrol.c')
-rw-r--r--source3/utils/smbcontrol.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index ea1f60951f8..579aa1027df 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -921,6 +921,53 @@ static bool do_dmalloc_changed(struct tevent_context *ev_ctx,
NULL, 0);
}
+static void print_uint32_cb(struct messaging_context *msg, void *private_data,
+ uint32_t msg_type, struct server_id pid,
+ DATA_BLOB *data)
+{
+ uint32_t num_children;
+
+ if (data->length != sizeof(uint32_t)) {
+ printf("Invalid response: %d bytes long\n",
+ (int)data->length);
+ goto done;
+ }
+ num_children = IVAL(data->data, 0);
+ printf("%u children\n", (unsigned)num_children);
+done:
+ num_replies++;
+}
+
+static bool do_num_children(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct server_id pid,
+ const int argc, const char **argv)
+{
+ if (argc != 1) {
+ fprintf(stderr, "Usage: smbcontrol <dest> num-children\n");
+ return False;
+ }
+
+ messaging_register(msg_ctx, NULL, MSG_SMB_NUM_CHILDREN,
+ print_uint32_cb);
+
+ /* Send a message and register our interest in a reply */
+
+ if (!send_message(msg_ctx, pid, MSG_SMB_TELL_NUM_CHILDREN, NULL, 0))
+ return false;
+
+ wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
+
+ /* No replies were received within the timeout period */
+
+ if (num_replies == 0)
+ printf("No replies received\n");
+
+ messaging_deregister(msg_ctx, MSG_SMB_TELL_NUM_CHILDREN, NULL);
+
+ return num_replies;
+}
+
/* Shutdown a server process */
static bool do_shutdown(struct tevent_context *ev_ctx,
@@ -1329,6 +1376,8 @@ static const struct {
"Validate winbind's credential cache" },
{ "dump-domain-list", do_winbind_dump_domain_list, "Dump winbind domain list"},
{ "notify-cleanup", do_notify_cleanup },
+ { "num-children", do_num_children,
+ "Print number of smbd child processes" },
{ "noop", do_noop, "Do nothing" },
{ NULL }
};