From ead091449b0fec481bf361dfc8fbf68f9d6df7be Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 May 2007 12:55:24 +1000 Subject: [PATCH] call the event script on recovery too (This used to be ctdb commit 8c43a91cbd6e502c93bd6cc51df1272eae426709) --- ctdb/common/ctdb_recover.c | 1 + ctdb/include/ctdb_private.h | 2 +- ctdb/takeover/ctdb_takeover.c | 20 -------------------- ctdb/takeover/system.c | 25 +++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ctdb/common/ctdb_recover.c b/ctdb/common/ctdb_recover.c index 604ba1fa2da..847d9e5abc5 100644 --- a/ctdb/common/ctdb_recover.c +++ b/ctdb/common/ctdb_recover.c @@ -447,6 +447,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, TDB_DATA indata, return -1; } ctdb->recovery_mode = recmode; + ctdb_event_script(ctdb, "recovered"); return 0; } diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index a5f98b3d3f8..f5d93b5301e 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -945,6 +945,6 @@ int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata); int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn); void ctdb_takeover_client_destructor_hook(struct ctdb_client *client); - +int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...); #endif diff --git a/ctdb/takeover/ctdb_takeover.c b/ctdb/takeover/ctdb_takeover.c index aa358c5fd39..02e2825e6bb 100644 --- a/ctdb/takeover/ctdb_takeover.c +++ b/ctdb/takeover/ctdb_takeover.c @@ -92,26 +92,6 @@ static void ctdb_control_send_arp(struct event_context *ev, struct timed_event * } -/* - run the event script - */ -static int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) -{ - va_list ap; - char *cmdstr; - int ret; - - va_start(ap, fmt); - cmdstr = talloc_vasprintf(ctdb, fmt, ap); - va_end(ap); - CTDB_NO_MEMORY(ctdb, cmdstr); - - ret = system(cmdstr); - talloc_free(cmdstr); - - return ret; -} - /* take over an ip address */ diff --git a/ctdb/takeover/system.c b/ctdb/takeover/system.c index db55f2c2099..493eddefa73 100644 --- a/ctdb/takeover/system.c +++ b/ctdb/takeover/system.c @@ -257,3 +257,28 @@ bool ctdb_sys_have_ip(const char *ip) return ret == 0; } +/* + run the event script + */ +int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) +{ + va_list ap; + char *options, *cmdstr; + int ret; + + va_start(ap, fmt); + options = talloc_vasprintf(ctdb, fmt, ap); + va_end(ap); + CTDB_NO_MEMORY(ctdb, options); + + cmdstr = talloc_asprintf(ctdb, "%s %s", ctdb->takeover.event_script, options); + CTDB_NO_MEMORY(ctdb, cmdstr); + + ret = system(cmdstr); + + talloc_free(cmdstr); + talloc_free(options); + + return ret; +} +