-/*
- called when a CTDB_REPLY_REDIRECT packet comes in
-
- This packet arrives when we have sent a CTDB_REQ_CALL request and
- the node that received it is not the dmaster for the given key. We
- are given a hint as to what node to try next.
-*/
-void ctdb_reply_redirect(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
-{
- struct ctdb_reply_redirect *c = (struct ctdb_reply_redirect *)hdr;
- struct ctdb_call_state *state;
-
- state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
- if (state == NULL) {
- return;
- }
-
- if (hdr->reqid != state->reqid) {
- /* we found a record but it was the wrong one */
- DEBUG(0, ("Dropped orphaned dmaster reply with reqid:%d\n",hdr->reqid));
- return;
- }
-
- /* don't allow for too many redirects */
- if ((++state->redirect_count) % CTDB_MAX_REDIRECT == 0) {
- c->dmaster = ctdb_lmaster(ctdb, &state->call.key);
- if (state->redirect_count > ctdb->status.max_redirect_count) {
- ctdb->status.max_redirect_count = state->redirect_count;
- }
- }
-
- /* send it off again */
- state->node = ctdb->nodes[c->dmaster];
- state->c->hdr.destnode = c->dmaster;
-
- ctdb_queue_packet(ctdb, &state->c->hdr);
-}
-