1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

eventscript: put timeout inside ctdb_event_script_callback_v

Everyone uses the same timeout value, so just remove it from the API.
If we ever need variable timeouts, that might as well be central too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>


(This used to be ctdb commit fe8027309c1f7b987cd368fa98f9b28741baa786)
This commit is contained in:
Rusty Russell 2009-11-24 11:09:46 +10:30
parent 1d68bb35b2
commit 5dee5769d3
5 changed files with 7 additions and 23 deletions

View File

@ -1328,11 +1328,10 @@ int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA ind
void ctdb_takeover_client_destructor_hook(struct ctdb_client *client); void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
int ctdb_event_script_callback(struct ctdb_context *ctdb, int ctdb_event_script_callback(struct ctdb_context *ctdb,
struct timeval timeout,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
void (*callback)(struct ctdb_context *, int, void *), void (*callback)(struct ctdb_context *, int, void *),
void *private_data, void *private_data,
const char *fmt, ...) PRINTF_ATTRIBUTE(6,7); const char *fmt, ...) PRINTF_ATTRIBUTE(5,6);
void ctdb_release_all_ips(struct ctdb_context *ctdb); void ctdb_release_all_ips(struct ctdb_context *ctdb);
void set_nonblocking(int fd); void set_nonblocking(int fd);

View File

@ -223,7 +223,6 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
if (!ctdb->done_startup) { if (!ctdb->done_startup) {
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
ctdb->monitor->monitor_context, ctdb_startup_callback, ctdb->monitor->monitor_context, ctdb_startup_callback,
ctdb, "startup"); ctdb, "startup");
} else { } else {
@ -248,7 +247,6 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
return; return;
} else { } else {
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
ctdb->monitor->monitor_context, ctdb_health_callback, ctdb->monitor->monitor_context, ctdb_health_callback,
ctdb, "monitor"); ctdb, "monitor");
} }

View File

@ -962,9 +962,7 @@ int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
ctdb_disable_monitoring(ctdb); ctdb_disable_monitoring(ctdb);
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb, state,
timeval_set(ctdb->tunable.script_timeout, 0),
state,
ctdb_end_recovery_callback, ctdb_end_recovery_callback,
state, "recovered"); state, "recovered");
@ -1016,9 +1014,7 @@ int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
ctdb_disable_monitoring(ctdb); ctdb_disable_monitoring(ctdb);
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb, state,
timeval_set(ctdb->tunable.script_timeout, 0),
state,
ctdb_start_recovery_callback, ctdb_start_recovery_callback,
state, "startrecovery"); state, "startrecovery");
@ -1230,9 +1226,7 @@ int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_contro
ctdb_disable_monitoring(ctdb); ctdb_disable_monitoring(ctdb);
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb, state,
timeval_set(ctdb->tunable.script_timeout, 0),
state,
ctdb_stop_node_callback, ctdb_stop_node_callback,
state, "stopped"); state, "stopped");

View File

@ -235,7 +235,6 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
vnn->iface)); vnn->iface));
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
state, takeover_ip_callback, state, state, takeover_ip_callback, state,
"takeip %s %s %u", "takeip %s %s %u",
vnn->iface, vnn->iface,
@ -391,7 +390,6 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
state->vnn = vnn; state->vnn = vnn;
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
state, release_ip_callback, state, state, release_ip_callback, state,
"releaseip %s %s %u", "releaseip %s %s %u",
vnn->iface, vnn->iface,
@ -2094,7 +2092,6 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
DLIST_REMOVE(ctdb->vnn, vnn); DLIST_REMOVE(ctdb->vnn, vnn);
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
mem_ctx, delete_ip_callback, mem_ctx, mem_ctx, delete_ip_callback, mem_ctx,
"releaseip %s %s %u", "releaseip %s %s %u",
vnn->iface, vnn->iface,

View File

@ -735,7 +735,6 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
finished finished
*/ */
static int ctdb_event_script_callback_v(struct ctdb_context *ctdb, static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
struct timeval timeout,
void (*callback)(struct ctdb_context *, int, void *), void (*callback)(struct ctdb_context *, int, void *),
void *private_data, void *private_data,
const char *fmt, va_list ap) const char *fmt, va_list ap)
@ -784,7 +783,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
state->callback = callback; state->callback = callback;
state->private_data = private_data; state->private_data = private_data;
state->options = talloc_vasprintf(state, fmt, ap); state->options = talloc_vasprintf(state, fmt, ap);
state->timeout = timeout; state->timeout = timeval_set(ctdb->tunable.script_timeout, 0);
if (state->options == NULL) { if (state->options == NULL) {
DEBUG(DEBUG_ERR, (__location__ " could not allocate state->options\n")); DEBUG(DEBUG_ERR, (__location__ " could not allocate state->options\n"));
talloc_free(state); talloc_free(state);
@ -846,7 +845,6 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
finished finished
*/ */
int ctdb_event_script_callback(struct ctdb_context *ctdb, int ctdb_event_script_callback(struct ctdb_context *ctdb,
struct timeval timeout,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
void (*callback)(struct ctdb_context *, int, void *), void (*callback)(struct ctdb_context *, int, void *),
void *private_data, void *private_data,
@ -856,7 +854,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = ctdb_event_script_callback_v(ctdb, timeout, callback, private_data, fmt, ap); ret = ctdb_event_script_callback_v(ctdb, callback, private_data, fmt, ap);
va_end(ap); va_end(ap);
return ret; return ret;
@ -890,7 +888,6 @@ int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
ret = ctdb_event_script_callback_v(ctdb, ret = ctdb_event_script_callback_v(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
event_script_callback, &status, fmt, ap); event_script_callback, &status, fmt, ap);
va_end(ap); va_end(ap);
@ -957,8 +954,7 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
ctdb_disable_monitoring(ctdb); ctdb_disable_monitoring(ctdb);
ret = ctdb_event_script_callback(ctdb, ret = ctdb_event_script_callback(ctdb,
timeval_set(ctdb->tunable.script_timeout, 0),
state, run_eventscripts_callback, state, state, run_eventscripts_callback, state,
"%s", (const char *)indata.dptr); "%s", (const char *)indata.dptr);