Branch: Tag:

2015-09-24

2015-09-24 12:03:55 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Protocols.DNS: Reduce race-condition window in do_query().

When executing do_query() in another thread than the backend thread,
there was a risk that the answer would be received and handled by
the backend thread before the retry call_out was installed. This
could cause do_query() to fail with "Lookup in destructed object."

Potential fix for [bug 7460 (#7460)].

1534:    }    }    -  send(nameservers[nsno],53,r->req); +     r->retry_co = call_out(retry, RETRY_DELAY, r, nsno+1); -  +  udp::send(nameservers[nsno], 53, r->req);    }       void do_query(string domain, int cl, int type,
1555:    r->callback=callback;    r->args=args;    r->timestamp=time(); -  requests[lid]=r; -  udp::send(nameservers[0],53,r->req); +     r->retry_co = call_out(retry, RETRY_DELAY, r, 1); -  +  requests[lid] = r; +  udp::send(nameservers[0], 53, req);    return;    }    }