Method code for $dns.startup_dns()

[Turn off line numbering]
  1: var id, tmp, x;
  2: 
  3: if (starting)
  4:     return;
  5: started = 0;
  6: starting = 1;
  7: if (connection)
  8:     (| connection.close() |);
  9: id = tosym("dns_connection");
 10: while ((| lookup(id) |))
 11:     id = tosym("dns_connection_" + ++x);
 12: connection = $outbound_connection.new_with(id);
 13: if ((| connection.open_connection(@dnshost) |)) {
 14:     starting = 0;
 15:     started = 1;
 16:     return;
 17: }
 18: 
 19: // try to exec() it, then startup again
 20: (| $sys.startup_dnsserv() |);
 21: $scheduler.sleep(1);
 22: catch any {
 23:     connection.open_connection(@dnshost);
 24:     starting = 0;
 25: } with {
 26:     (| connection.close() |);
 27:     connection = 0;
 28:     starting = 0;
 29:     if (error() == ~refused)
 30:         throw(~refused, "Unable to open connection to " + dnshost.join(":"));
 31:     else
 32:         rethrow(error());
 33: }
 34: started = 1;

// Created 01-Jul-1997 as a part of ColdCore, see: @help Credit

Tlon