(1) How about we put the original nameserver back after the call to res_send()? In this case, this will only need to be done once, instead of before every return statement.
Also, note that not only we have to reestablish the old servers back, but also _res.retrans and _res.retry.
Finally, I think we could also work in case _res.nscount equals 0. For instance, if DNS server is specified in the item.
Nameserver information is now restored after the final use of the _res structure. `retrans' and `retry' variables are also saved and restored before and after NS entry manipulation.
_res.nscount should NEVER equal 0 unless res_init() hasn't been called (or any of the query functions, which call res_init() internall, if they detect that it hasn't been done previously). A 0 value for nscount indicates a broken implementation of `resolv' on the system or severe system failure. Handling such a case varies from implementation to implementation, but it should be noted that a 0 value nscount does not indicate error and does not result in the setting of the `_res.res_h_errno' variable responsible for reporting error status. It is safe to assume that in the case of an nscount of 0 further calls to resolver functions also fail. The case will not be handled directly. RESOLVED.
Aleksandrs Saveljevs Yesterday we discussed that we should check for res_init() being successful. It was not done, however. Could you please look into it? REOPENED.
Juris Miščenko Failure check added to resolver structure initialization routine. RESOLVED.
Aleksandrs Saveljevs Looks good. Please see r41722 before merging. RESOLVED.
Juris Miščenko Looks good! CLOSED.