1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

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>
This commit is contained in:
Martin Schwenke 2018-07-08 09:02:44 +10:00 committed by Amitay Isaacs
parent 6742bf6cf6
commit 2546c43959

View File

@ -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;
}