diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-05-06 15:42:59 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-05-06 15:42:59 +1000 |
commit | 92b61cd7d53321d2fbe3eab7f0290e233e47ee9f (patch) | |
tree | ae19da87e3072ab9b8f12d0466fe4ae820fe8d05 /ctdb/client | |
parent | 2c23959616ef1db2ae07172eba72ef313ccba0ed (diff) | |
download | samba-92b61cd7d53321d2fbe3eab7f0290e233e47ee9f.tar.gz samba-92b61cd7d53321d2fbe3eab7f0290e233e47ee9f.tar.xz samba-92b61cd7d53321d2fbe3eab7f0290e233e47ee9f.zip |
Expand the client async framework so that it can take a callback function.
This allows us to use the async framework also for controls that return
outdata.
Add a "capabilities" field to the ctdb_node structure. This field is
only initialized and kept valid inside the recovery daemon context and not
inside the main ctdb daemon.
change the GET_CAPABILITIES control to return the capabilities in outdata instead of in the res return variable.
When performing a recovery inside the recovery daemon, read the capabilities from all connected nodes and update the ctdb->nodes list of nodes.
when building the new vnnmap after the database rebuild in recovery, do not include any nodes which lack the LMASTER capability in the new vnnmap.
Unless there are no available connected node that sports the LMASTER capability in which case we let the local node (recmaster) take on the lmaster role temporarily (i.e. become a member of the vnnmap list)
(This used to be ctdb commit 0f1883c69c689b28b0c04148774840b2c4081df6)
Diffstat (limited to 'ctdb/client')
-rw-r--r-- | ctdb/client/ctdb_client.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 4f3a0d582f..921392c844 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -2671,8 +2671,11 @@ int ctdb_ctrl_end_recovery(struct ctdb_context *ctdb, struct timeval timeout, ui static void async_callback(struct ctdb_client_control_state *state) { struct client_async_data *data = talloc_get_type(state->async.private_data, struct client_async_data); + struct ctdb_context *ctdb = talloc_get_type(state->ctdb, struct ctdb_context); int ret; + TDB_DATA outdata; int32_t res; + uint32_t destnode = state->c->hdr.destnode; /* one more node has responded with recmode data */ data->count--; @@ -2690,13 +2693,16 @@ static void async_callback(struct ctdb_client_control_state *state) state->async.fn = NULL; - ret = ctdb_control_recv(state->ctdb, state, data, NULL, &res, NULL); + ret = ctdb_control_recv(ctdb, state, data, &outdata, &res, NULL); if ((ret != 0) || (res != 0)) { if ( !data->dont_log_errors) { DEBUG(DEBUG_ERR,("Async operation failed with ret=%d res=%d\n", ret, (int)res)); } data->fail_count++; } + if ((ret == 0) && (data->callback != NULL)) { + data->callback(ctdb, destnode, res, outdata); + } } @@ -2739,15 +2745,17 @@ int ctdb_client_async_control(struct ctdb_context *ctdb, uint32_t *nodes, struct timeval timeout, bool dont_log_errors, - TDB_DATA data) + TDB_DATA data, + client_async_callback client_callback) { struct client_async_data *async_data; struct ctdb_client_control_state *state; int j, num_nodes; - + async_data = talloc_zero(ctdb, struct client_async_data); CTDB_NO_MEMORY_FATAL(ctdb, async_data); async_data->dont_log_errors = dont_log_errors; + async_data->callback = client_callback; num_nodes = talloc_get_size(nodes) / sizeof(uint32_t); @@ -2886,15 +2894,16 @@ int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ct { int ret; int32_t res; + TDB_DATA outdata; - ret = ctdb_control_recv(ctdb, state, mem_ctx, NULL, &res, NULL); - if (ret != 0) { + ret = ctdb_control_recv(ctdb, state, mem_ctx, &outdata, &res, NULL); + if ( (ret != 0) || (res != 0) ) { DEBUG(DEBUG_ERR,(__location__ " ctdb_ctrl_getcapabilities_recv failed\n")); return -1; } if (capabilities) { - *capabilities = (uint32_t)res; + *capabilities = *((uint32_t *)outdata.dptr); } return 0; |