*/
static int ctdb_call_destructor(struct ctdb_call_state *state)
{
+ DLIST_REMOVE(state->ctdb_db->ctdb->pending_calls, state);
ctdb_reqid_remove(state->ctdb_db->ctdb, state->reqid);
return 0;
}
/*
- called when a ctdb_call times out
+ called when a ctdb_call needs to be resent after a reconfigure event
*/
-static void ctdb_call_timeout(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private_data)
+static void ctdb_call_resend(struct ctdb_call_state *state)
{
- struct ctdb_call_state *state = talloc_get_type(private_data, struct ctdb_call_state);
struct ctdb_context *ctdb = state->ctdb_db->ctdb;
- ctdb->status.timeouts.call++;
-
- event_add_timed(ctdb->ev, state, timeval_current_ofs(CTDB_CALL_TIMEOUT, 0),
- ctdb_call_timeout, state);
-
- if (++state->resend_count < 10 &&
- (ctdb->vnn_map->generation == state->generation ||
- ctdb->recovery_mode != CTDB_RECOVERY_NORMAL)) {
- /* the call is just being slow, or we are curently
- recovering, give it more time */
- return;
- }
-
- /* the generation count changed or we're timing out too much -
- the call must be re-issued */
state->generation = ctdb->vnn_map->generation;
- state->resend_count = 0;
/* use a new reqid, in case the old reply does eventually come in */
ctdb_reqid_remove(ctdb, state->reqid);
state->c->hdr.destnode = ctdb->vnn;
ctdb_queue_packet(ctdb, &state->c->hdr);
- DEBUG(0,("requeued ctdb_call after timeout\n"));
+ DEBUG(0,("resent ctdb_call\n"));
+}
+
+/*
+ resend all pending calls on recovery
+ */
+void ctdb_call_resend_all(struct ctdb_context *ctdb)
+{
+ struct ctdb_call_state *state, *next;
+ for (state=ctdb->pending_calls;state;state=next) {
+ next = state->next;
+ ctdb_call_resend(state);
+ }
}
/*
state->state = CTDB_CALL_WAIT;
state->generation = ctdb->vnn_map->generation;
+ DLIST_ADD(ctdb->pending_calls, state);
+
ctdb_queue_packet(ctdb, &state->c->hdr);
- event_add_timed(ctdb->ev, state, timeval_current_ofs(CTDB_CALL_TIMEOUT, 0),
- ctdb_call_timeout, state);
return state;
}
uint32_t num_clients;
uint32_t seqnum_frequency;
uint32_t recovery_master;
+ struct ctdb_call_state *pending_calls;
};
struct ctdb_db_context {
ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
}} while (0)
-/* timeout for ctdb call operations. When this timeout expires we
- check if the generation count has changed, and if it has then
- re-issue the call */
-#define CTDB_CALL_TIMEOUT 2
-
/* maximum timeout for ctdb control calls */
#define CTDB_CONTROL_TIMEOUT 60
state of a in-progress ctdb call
*/
struct ctdb_call_state {
+ struct ctdb_call_state *next, *prev;
enum call_state state;
uint32_t reqid;
struct ctdb_req_call *c;
const char *errmsg;
struct ctdb_call call;
uint32_t generation;
- uint32_t resend_count;
struct {
void (*fn)(struct ctdb_call_state *);
void *private_data;
void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
+void ctdb_call_resend_all(struct ctdb_context *ctdb);
#endif