Branch: Tag:

2015-09-24

2015-09-24 11:56:22 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)].

1913:    }    }    -  send(nameservers[nsno],53,r->req); +     r->retry_co = call_out(retry, RETRY_DELAY, r, nsno+1); -  +  udp::send(nameservers[nsno], 53, r->req);    }       //! Enqueue a new raw DNS request.
1936:    string req=low_mkquery(lid,domain,cl,type);       object r = Request(domain, req, callback, args); -  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 r;    }    }