ctdb-takeover: Handle case where there are no RELEASE_IPs to send
authorMartin Schwenke <martin@meltin.net>
Wed, 11 Jan 2017 19:52:32 +0000 (06:52 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 12 Jan 2017 18:25:23 +0000 (19:25 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12511

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover_helper.c

index d96e6c8605bbc845ef4894839df5d97e1b4ec728..5f537c435614ed1d60ae01882137c85e5f158971 100644 (file)
@@ -295,6 +295,12 @@ static struct tevent_req *release_ip_send(TALLOC_CTX *mem_ctx,
                        }
                }
 
+               if (substate->count == 0) {
+                       /* No releases to send for this address... */
+                       TALLOC_FREE(substate);
+                       continue;
+               }
+
                ip.pnn = tmp_ip->pnn;
                ip.addr = tmp_ip->addr;
                ctdb_req_control_release_ip(&request, &ip);
@@ -311,6 +317,12 @@ static struct tevent_req *release_ip_send(TALLOC_CTX *mem_ctx,
                state->num_sent++;
        }
 
+       /* None sent, finished... */
+       if (state->num_sent == 0) {
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       }
+
        return req;
 }