banning: If node is already banned, do not run ctdb_local_node_got_banned()
authorAmitay Isaacs <amitay@gmail.com>
Mon, 27 Jul 2015 06:51:08 +0000 (16:51 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 31 Jul 2015 03:35:01 +0000 (13:35 +1000)
This calls release_all_ips() only once on the first ban.  If the node gets
banned again due to event script timeout while running release_all_ips(),
then avoid calling release_all_ips() in re-entrant fashion.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(Imported from commit 8eb04d09b119e234c88150e1dc35fc5057f9c926)

server/ctdb_banning.c

index a9d18910a06934a3790a7d0690383ac97f84e935..d8f7ab1b6ff09751459255da7057da8a04f3fbf2 100644 (file)
@@ -80,6 +80,7 @@ void ctdb_local_node_got_banned(struct ctdb_context *ctdb)
 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
 {
        struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)indata.dptr;
+       bool already_banned;
 
        DEBUG(DEBUG_INFO,("SET BAN STATE\n"));
 
@@ -107,9 +108,11 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
                return 0;
        }
 
+       already_banned = false;
        if (ctdb->banning_ctx != NULL) {
                talloc_free(ctdb->banning_ctx);
                ctdb->banning_ctx = NULL;
+               already_banned = true;
        }
 
        if (bantime->time == 0) {
@@ -136,7 +139,9 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
 
        event_add_timed(ctdb->ev, ctdb->banning_ctx, timeval_current_ofs(bantime->time,0), ctdb_ban_node_event, ctdb);
 
-       ctdb_local_node_got_banned(ctdb);
+       if (!already_banned) {
+               ctdb_local_node_got_banned(ctdb);
+       }
        return 0;
 }