summaryrefslogtreecommitdiff
path: root/ctdb/event
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-07-08 09:02:44 +1000
committerAmitay Isaacs <amitay@samba.org>2018-07-11 11:48:38 +0200
commit2546c439599565f33e4c905d1c73858026e37439 (patch)
treef26aa3c05e14efa68e05ca61e4607dcf5a8bd2f1 /ctdb/event
parent6742bf6cf65cf40b54910ee254a3e863be141e85 (diff)
downloadsamba-2546c439599565f33e4c905d1c73858026e37439.tar.gz
ctdb-event: Allow tool to enable/disable scripts without daemon
Only open the client socket when it is needed. Note that this only works for enabling/disabling event scripts via symlinks. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/event')
-rw-r--r--ctdb/event/event_tool.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c
index b83288ccc01..3a99de50ece 100644
--- a/ctdb/event/event_tool.c
+++ b/ctdb/event/event_tool.c
@@ -90,6 +90,12 @@ static int event_command_run(TALLOC_CTX *mem_ctx,
return 1;
}
+ ret = ctdb_event_init(ctx, ctx->ev, &ctx->eclient);
+ if (ret != 0) {
+ D_ERR("Failed to initialize event client, ret=%d\n", ret);
+ return ret;
+ }
+
timeout = atoi(argv[0]);
if (timeout < 0) {
timeout = 0;
@@ -242,6 +248,12 @@ static int event_command_status(TALLOC_CTX *mem_ctx,
return 1;
}
+ ret = ctdb_event_init(ctx, ctx->ev, &ctx->eclient);
+ if (ret != 0) {
+ D_ERR("Failed to initialize event client, ret=%d\n", ret);
+ return ret;
+ }
+
request_status.component = argv[0];
request_status.event = argv[1];
@@ -293,6 +305,12 @@ static int event_command_script(TALLOC_CTX *mem_ctx,
int ret = 0, result = 0;
bool ok;
+ ret = ctdb_event_init(ctx, ctx->ev, &ctx->eclient);
+ if (ret != 0) {
+ D_ERR("Failed to initialize event client, ret=%d\n", ret);
+ return ret;
+ }
+
request_script.component = component;
request_script.script = script;
request_script.action = action;
@@ -514,12 +532,6 @@ int event_tool_run(struct event_tool_context *ctx, int *result)
return ENOMEM;
}
- ret = ctdb_event_init(ctx, ctx->ev, &ctx->eclient);
- if (ret != 0) {
- D_ERR("Failed to initialize event client, ret=%d\n", ret);
- return ret;
- }
-
ret = cmdline_run(ctx->cmdline, ctx, result);
return ret;
}