struct ctdb_reply_redirect *c = (struct ctdb_reply_redirect *)hdr;
struct ctdb_call_state *state;
- state = idr_find_type(ctdb->idr, hdr->reqid, struct ctdb_call_state);
- if (state == NULL) return;
+ 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) {
+ 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 */