From: Ronnie Sahlberg Date: Wed, 9 May 2007 04:06:47 +0000 (+1000) Subject: when we are in recovery mode and we get a REQ_CALL from a client, X-Git-Tag: tevent-0.9.20~348^2~2765^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c938c1b5dee3807bfd8d003600244744234b03f1;p=thirdparty%2Fsamba.git 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) --- diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index ce5cc73eaa6..43f09a80210 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -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;