summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-30 15:08:40 +0200
committerJeremy Allison <jra@samba.org>2019-09-18 21:27:30 +0000
commitbc4e8b1abaf8431d1f507107cf60e57da75c0bef (patch)
tree28ce394908e696be8988dba8ef9108bf7da8d629 /source3/utils
parent23bee5da95026d161159da74a032780a713c820a (diff)
downloadsamba-bc4e8b1abaf8431d1f507107cf60e57da75c0bef.tar.gz
messaging: Do POOL_USAGE via a socket
This makes debugging run-away processes much more efficient and even possible at all: If the pool-usage output is more than 256MB, the previous code could not realloc it and threw it away. Also, it is not helpful for an already huge process to allocate even more. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Sep 18 21:27:30 UTC 2019 on sn-devel-184
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbcontrol.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 1435cc57d0a..35cb7d39a02 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -125,18 +125,6 @@ static void print_pid_string_cb(struct messaging_context *msg,
num_replies++;
}
-/* Message handler callback that displays a string on stdout */
-
-static void print_string_cb(struct messaging_context *msg,
- void *private_data,
- uint32_t msg_type,
- struct server_id pid,
- DATA_BLOB *data)
-{
- printf("%*s", (int)data->length, (const char *)data->data);
- num_replies++;
-}
-
/* Send no message. Useful for testing. */
static bool do_noop(struct tevent_context *ev_ctx,
@@ -861,31 +849,32 @@ static bool do_ip_dropped(struct tevent_context *ev_ctx,
static bool do_poolusage(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- const struct server_id pid,
+ const struct server_id dst,
const int argc, const char **argv)
{
+ pid_t pid = procid_to_pid(&dst);
+ int stdout_fd = 1;
+
if (argc != 1) {
fprintf(stderr, "Usage: smbcontrol <dest> pool-usage\n");
return False;
}
- messaging_register(msg_ctx, NULL, MSG_POOL_USAGE, print_string_cb);
-
- /* Send a message and register our interest in a reply */
-
- if (!send_message(msg_ctx, pid, MSG_REQ_POOL_USAGE, 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");
+ if (pid == 0) {
+ fprintf(stderr, "Can only send to a specific PID\n");
+ return false;
+ }
- messaging_deregister(msg_ctx, MSG_POOL_USAGE, NULL);
+ messaging_send_iov(
+ msg_ctx,
+ dst,
+ MSG_REQ_POOL_USAGE,
+ NULL,
+ 0,
+ &stdout_fd,
+ 1);
- return num_replies;
+ return true;
}
/* Fetch and print the ringbuf log */