summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGary Lockyer <gary@catalyst.net.nz>2018-12-04 09:31:22 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-12-19 04:52:59 +0100
commitff9052c923d1f474696022527663b64f60195a05 (patch)
tree93d57a110c03c3355963add220bee292feb2cabd /source3/utils
parentb578fad88e3b5a62fa060474b52dbc7e59fd6a24 (diff)
downloadsamba-ff9052c923d1f474696022527663b64f60195a05.tar.gz
s3 smbcontrol: Add sleep command
Add a sleep command that pauses the target process for the specified number of seconds This command is only enabled on developer and self test builds. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbcontrol.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 8ba31c9f841..1d60f0eeef8 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -410,6 +410,43 @@ static bool do_inject_fault(struct tevent_context *ev_ctx,
#endif /* DEVELOPER || ENABLE_SELFTEST */
}
+static bool do_sleep(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct server_id pid,
+ const int argc, const char **argv)
+{
+ unsigned int seconds;
+ long input;
+ const long MAX_SLEEP = 60 * 60; /* One hour maximum sleep */
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: smbcontrol <dest> sleep seconds\n");
+ return False;
+ }
+
+#if !defined(DEVELOPER) && !defined(ENABLE_SELFTEST)
+ fprintf(stderr, "Sleep is only available in "
+ "developer and self test builds\n");
+ return False;
+#else /* DEVELOPER || ENABLE_SELFTEST */
+
+ input = atol(argv[1]);
+ if (input < 1 || input > MAX_SLEEP) {
+ fprintf(stderr,
+ "Invalid duration for sleep '%s'\n"
+ "It should be at least 1 second and no more than %ld\n",
+ argv[1],
+ MAX_SLEEP);
+ return False;
+ }
+ seconds = input;
+ return send_message(msg_ctx, pid,
+ MSG_SMB_SLEEP,
+ &seconds,
+ sizeof(unsigned int));
+#endif /* DEVELOPER || ENABLE_SELFTEST */
+}
+
/* Force a browser election */
static bool do_election(struct tevent_context *ev_ctx,
@@ -1421,6 +1458,7 @@ static const struct {
"Print number of smbd child processes" },
{ "msg-cleanup", do_msg_cleanup },
{ "noop", do_noop, "Do nothing" },
+ { "sleep", do_sleep, "Cause the target process to sleep" },
{ NULL }
};