ctdb-daemon: Move VNN lookup out of ctdb_remove_tcp_connection()
authorMartin Schwenke <martin@meltin.net>
Thu, 21 May 2015 12:42:13 +0000 (22:42 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 4 Dec 2015 08:17:17 +0000 (09:17 +0100)
In a subsequent commit ctdb_takeover_client_destructor_hook() needs to
know the VNN.  So just have both callers of
ctdb_remove_tcp_connection() do the lookup and pass in the VNN.

This should cause no change in behaviour.

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

index 13679d4ea5e65a5f959ef32fb5fda907b4051e6b..9816d6a48cbf336773c15f84b7544f2b20b8977e 100644 (file)
@@ -3061,19 +3061,11 @@ int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tc
 }
 
 
-/*
-  called by a daemon to inform us of a TCP connection that one of its
-  clients managing that should tickled with an ACK when IP takeover is
-  done
- */
-static void ctdb_remove_connection(struct ctdb_context *ctdb, struct ctdb_connection *conn)
+static void ctdb_remove_connection(struct ctdb_vnn *vnn, struct ctdb_connection *conn)
 {
        struct ctdb_connection *tcpp;
-       struct ctdb_vnn *vnn = find_public_ip_vnn(ctdb, &conn->dst);
 
        if (vnn == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " unable to find public address %s\n",
-                       ctdb_addr_to_str(&conn->dst)));
                return;
        }
 
@@ -3130,6 +3122,7 @@ static void ctdb_remove_connection(struct ctdb_context *ctdb, struct ctdb_connec
  */
 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata)
 {
+       struct ctdb_vnn *vnn;
        struct ctdb_connection *conn = (struct ctdb_connection *)indata.dptr;
 
        /* If we don't have public IPs, tickles are useless */
@@ -3137,7 +3130,15 @@ int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata)
                return 0;
        }
 
-       ctdb_remove_connection(ctdb, conn);
+       vnn = find_public_ip_vnn(ctdb, &conn->dst);
+       if (vnn == NULL) {
+               DEBUG(DEBUG_ERR,
+                     (__location__ " unable to find public address %s\n",
+                      ctdb_addr_to_str(&conn->dst)));
+               return 0;
+       }
+
+       ctdb_remove_connection(vnn, conn);
 
        return 0;
 }
@@ -3172,9 +3173,22 @@ int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t pnn)
 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client)
 {
        while (client->tcp_list) {
+               struct ctdb_vnn *vnn;
                struct ctdb_tcp_list *tcp = client->tcp_list;
+               struct ctdb_connection *conn = &tcp->connection;
+
                DLIST_REMOVE(client->tcp_list, tcp);
-               ctdb_remove_connection(client->ctdb, &tcp->connection);
+
+               vnn = find_public_ip_vnn(client->ctdb,
+                                        &conn->dst);
+               if (vnn == NULL) {
+                       DEBUG(DEBUG_ERR,
+                             (__location__ " unable to find public address %s\n",
+                              ctdb_addr_to_str(&conn->dst)));
+                       continue;
+               }
+
+               ctdb_remove_connection(vnn, conn);
        }
 }