Skip to content
Snippets Groups Projects
Commit d692ea1f authored by Leif Stensson's avatar Leif Stensson
Browse files

Two avoid-backtraces fixes. One to catch errors from udp->wait(),

and one to handle some cases of get_tcpip_param() returning 0.

Rev: lib/modules/Protocols.pmod/DNS.pmod:1.48
parent d1cac51a
Branches
Tags
No related merge requests found
......@@ -405,7 +405,7 @@ class client
static private mapping etc_hosts;
#ifdef __NT__
string get_tcpip_param(string val)
string get_tcpip_param(string val, void|string fallbackvalue)
{
foreach(({
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
......@@ -430,7 +430,7 @@ class client
};
}
#endif
return fallbackvalue;
}
#endif
......@@ -488,11 +488,11 @@ class client
if(!domain || !sizeof(domain))
domain = get_tcpip_param("DhcpDomain");
nameservers = get_tcpip_param("NameServer") / " ";
nameservers+= get_tcpip_param("DhcpNameServer") / " ";
nameservers += get_tcpip_param("NameServer", "") / " ";
nameservers += get_tcpip_param("DhcpNameServer", "") / " ";
nameservers -= ({ "" });
domains=get_tcpip_param("SearchList") / " "- ({""});
domains += (get_tcpip_param("SearchList", "") / " ") - ({ "" });
#else
string resolv_conf;
foreach(({"/etc/resolv.conf", "/amitcp/db/resolv.conf"}), string resolv_loc)
......@@ -583,7 +583,11 @@ class client
for (i=0; i < RETRIES; i++) {
udp->send(nameservers[i % sizeof(nameservers)], 53, s);
while (udp->wait(RETRY_DELAY)) {
// upd->wait() can throw an error sometimes.
catch
{
while (udp->wait(RETRY_DELAY))
{
// udp->read() can throw an error on connection refused.
catch {
m = udp->read();
......@@ -595,6 +599,7 @@ class client
}
};
}
};
}
// Failure.
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment