Branch: Tag:

2000-09-07

2000-09-07 15:29:41 by Leif Stensson <leif@lysator.liu.se>

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

405:    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: Inside #if defined(__NT__) and #if constant(RegGetKeyNames)
   };    }   #endif -  +  return fallbackvalue;    }   #endif   
484:    string domain;      #if __NT__ -  domain=get_tcpip_param("Domain"); +  domain = get_tcpip_param("Domain");    if(!domain || !sizeof(domain)) -  domain=get_tcpip_param("DhcpDomain"); +  domain = get_tcpip_param("DhcpDomain");    -  nameservers = get_tcpip_param("NameServer") / " "; -  nameservers+= get_tcpip_param("DhcpNameServer") / " "; -  nameservers -= ({""}); +  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:    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:    }    };    } +  };    }    // Failure.    return 0;