1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

when we are in recovery mode and we get a REQ_CALL from a client,

defer it for one second and try again   

(This used to be ctdb commit 606fb6414b97d1813056982cda7c0fe84d746e67)
This commit is contained in:
Ronnie Sahlberg 2007-05-09 14:06:47 +10:00
parent 6929739b7f
commit c938c1b5de

View File

@ -428,6 +428,26 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
}
struct ctdb_client_retry {
void *p;
uint8_t *data;
uint32_t nread;
};
/*
triggered after a one second delay, retrying a client packet
that was deferred because of the daemon being in recovery mode
*/
static void retry_client_packet(struct event_context *ev, struct timed_event *te, struct timeval t, void *private_data)
{
struct ctdb_client_retry *retry = talloc_get_type(private_data, struct ctdb_client_retry);
daemon_incoming_packet(retry->p, retry->data, retry->nread);
talloc_free(retry);
}
static void daemon_request_control_from_client(struct ctdb_client *client,
struct ctdb_req_control *c);
@ -458,6 +478,27 @@ static void daemon_incoming_packet(void *p, uint8_t *data, uint32_t nread)
switch (hdr->operation) {
case CTDB_REQ_CALL:
if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
struct ctdb_client_retry *retry;
DEBUG(0,(__location__ " ctdb request %d"
" length %d from client"
" while we are in recovery mode. Deferring it\n",
hdr->reqid, hdr->length));
/* hang the event and the structure off client */
retry = talloc(client, struct ctdb_client_retry);
retry->p = p;
retry->data = data;
retry->nread = nread;
/* cant let the mem_ctx free hdr below */
talloc_steal(retry, hdr);
event_add_timed(ctdb->ev, hdr, timeval_current_ofs(1,0), retry_client_packet, retry);
break;
}
ctdb->status.client.req_call++;
daemon_request_call_from_client(client, (struct ctdb_req_call *)hdr);
break;