change the old ctdb_ctrl_getpnn() function with tiemout use the new
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 13 May 2010 02:16:00 +0000 (12:16 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 13 May 2010 02:16:00 +0000 (12:16 +1000)
libctdb functions instead of calling ctdb_control() directly.

client/ctdb_client.c

index 7b49931142643280b9d9812a976526b17b751ddb..a3349e0b4ad2b7ad33e9c066e687df2ed518acae 100644 (file)
@@ -1393,17 +1393,26 @@ int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t d
 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
 {
        int ret;
-       int32_t res;
+       uint32_t pnn;
+       ctdb_handle *handle;
 
-       ret = ctdb_control(ctdb, destnode, 0, 
-                          CTDB_CONTROL_GET_PNN, 0, tdb_null, 
-                          NULL, NULL, &res, &timeout, NULL);
+       handle = ctdb_getpnn_send(ctdb, destnode, NULL, NULL);
+       if (handle == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " Failed to send getpnn control\n"));
+               return -1;
+       }
+
+       if (!timeval_is_zero(&timeout)) {
+               event_add_timed(ctdb->ev, handle, timeout, ctdb_control_timeout_func, handle);
+       }
+
+       ret = ctdb_getpnn_recv(ctdb, handle, &pnn);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getpnn failed\n"));
                return -1;
        }
 
-       return res;
+       return pnn;
 }
 
 /*