change the controls to return a struct ctdb_client_control_state* instead of a handle
[sahlberg/ctdb.git] / libctdb / tst.c
index abedd20470d5810057f0c9294296f33ee525fbd9..c66d4d51aca36753264fb47e0b4753f4db1f793d 100644 (file)
@@ -15,7 +15,7 @@ void msg_h(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data, void *priva
 }
 
 
-void pnn_cb(int32_t status, struct ctdb_context *ctdb, ctdb_handle *handle, void *private_data)
+void pnn_cb(int32_t status, struct ctdb_context *ctdb, struct ctdb_client_control_state *state, void *private_data)
 {
        uint32_t pnn;
        int ret;
@@ -25,7 +25,7 @@ void pnn_cb(int32_t status, struct ctdb_context *ctdb, ctdb_handle *handle, void
                return;
        }
 
-       ret = ctdb_getpnn_recv(ctdb, handle, &pnn);
+       ret = ctdb_getpnn_recv(ctdb, state, &pnn);
        if (ret != 0) {
                printf("Failed to read getpnn reply\n");
                return;
@@ -34,7 +34,7 @@ void pnn_cb(int32_t status, struct ctdb_context *ctdb, ctdb_handle *handle, void
        printf("status:%d pnn:%d\n", status, pnn);
 }
 
-void rm_cb(int32_t status, struct ctdb_context *ctdb, ctdb_handle *handle, void *private_data)
+void rm_cb(int32_t status, struct ctdb_context *ctdb, struct ctdb_client_control_state *state, void *private_data)
 {
        uint32_t rm;
        int ret;
@@ -44,7 +44,7 @@ void rm_cb(int32_t status, struct ctdb_context *ctdb, ctdb_handle *handle, void
                return;
        }
 
-       ret = ctdb_getrecmaster_recv(ctdb, handle, &rm);
+       ret = ctdb_getrecmaster_recv(ctdb, state, &rm);
        if (ret != 0) {
                printf("Failed to read getpnn reply\n");
                return;
@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
 {
        struct ctdb_context *ctdb;
        struct ctdb_db_context *ctdb_db_context;
+       struct ctdb_client_control_state *control_state;
        ctdb_handle *handle;
        struct pollfd pfd;
        int ret;
@@ -146,8 +147,8 @@ int main(int argc, char *argv[])
         * ASYNC call with callback to read the recmaster
         * this is the preferred way to use libctdb
         */
-       handle = ctdb_getrecmaster_send(ctdb, CTDB_CURRENT_NODE, rm_cb, NULL);
-       if (handle == NULL) {
+       control_state = ctdb_getrecmaster_send(ctdb, CTDB_CURRENT_NODE, rm_cb, NULL);
+       if (control_state == NULL) {
                printf("Failed to send get_recmaster control\n");
                exit(10);
        }
@@ -157,15 +158,14 @@ int main(int argc, char *argv[])
         * calls the blocking *_recv() function.
         * Avoid this mode for performance critical tasks
         */
-       handle = ctdb_getrecmaster_send(ctdb, CTDB_CURRENT_NODE, NULL, NULL);
-       if (handle == NULL) {
+       control_state = ctdb_getrecmaster_send(ctdb, CTDB_CURRENT_NODE, NULL, NULL);
+       if (control_state == NULL) {
                printf("Failed to send get_recmaster control\n");
                exit(10);
        }
-       ret = ctdb_getrecmaster_recv(ctdb, handle, &recmaster);
+       ret = ctdb_getrecmaster_recv(ctdb, control_state, &recmaster);
        if (ret != 0) {
                printf("Failed to receive response to getrecmaster\n");
-               ctdb_free(handle);
                exit(10);
        }
        printf("GETRECMASTER SEMI-SYNC: status:%d recmaster:%d\n", ret, recmaster);