Add verification that we called the correct *_recv() function for the handle from...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 18 May 2010 06:07:42 +0000 (16:07 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 18 May 2010 06:07:42 +0000 (16:07 +1000)
libctdb/libctdb.c

index 9fe55a9b50602b8650f435150af333657fecc527..c9cc4d8fbeab021a209b16a448d39b97d195afdf 100644 (file)
@@ -51,7 +51,7 @@ ctdb_control_cb(struct ctdb_client_control_state *state)
        state->async.fn = NULL;
 
        if (state->state != CTDB_CONTROL_DONE) {
-               DEBUG(DEBUG_ERR, (__location__ " ctdb_getpnn_recv_cb failed with state:%d\n", state->state));
+               DEBUG(DEBUG_ERR, (__location__ " ctdb_control_cb failed with state:%d\n", state->state));
                callback(-1, NULL, NULL, cb_data->private_data);
                return;
        }
@@ -268,6 +268,10 @@ int ctdb_getpnn_recv(struct ctdb_context *ctdb, ctdb_handle *handle, uint32_t *p
        struct ctdb_client_control_state *state = talloc_get_type(handle, struct ctdb_client_control_state);
        int ret;
 
+       if (state->c->opcode != CTDB_CONTROL_GET_PNN) {
+               DEBUG(DEBUG_ERR, (__location__ " Unexpected opcode for control_recv. Expected %d but got %d\n", CTDB_CONTROL_GET_PNN, state->c->opcode));
+               return -1;
+       }
        ret = ctdb_control_recv(ctdb, state, state, NULL, NULL, NULL);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,(__location__ " ctdb_getpnn_recv failed\n"));
@@ -328,6 +332,11 @@ int ctdb_getrecmaster_recv(struct ctdb_context *ctdb, ctdb_handle *handle, uint3
        struct ctdb_client_control_state *state = talloc_get_type(handle, struct ctdb_client_control_state);
        int ret;
 
+       if (state->c->opcode != CTDB_CONTROL_GET_RECMASTER) {
+               DEBUG(DEBUG_ERR, (__location__ " Unexpected opcode for control_recv. Expected %d but got %d\n", CTDB_CONTROL_GET_RECMASTER, state->c->opcode));
+               return -1;
+       }
+
        ret = ctdb_control_recv(ctdb, state, state, NULL, NULL, NULL);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,(__location__ " ctdb_getrecmaster_recv failed\n"));