From ba8ea0e685dcb7881ba346775f12277e298dcec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sun, 7 May 2000 17:19:59 +0200 Subject: [PATCH] Improved handling of connection refused in do_sync_query(). Rev: lib/modules/Protocols.pmod/DNS.pmod:1.41 --- lib/modules/Protocols.pmod/DNS.pmod | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/modules/Protocols.pmod/DNS.pmod b/lib/modules/Protocols.pmod/DNS.pmod index 36d7e70e31..9295aa922a 100644 --- a/lib/modules/Protocols.pmod/DNS.pmod +++ b/lib/modules/Protocols.pmod/DNS.pmod @@ -563,13 +563,16 @@ class client udp->send(nameservers[i % sizeof(nameservers)], 53, s); while (udp->wait(RETRY_DELAY)) { - m = udp->read(); - if ((m->port == 53) && - (m->data[0..1] == s[0..1]) && - (search(nameservers, m->ip) != -1)) { - // Success. - return decode_res(m->data); - } + // udp->read() can throw an error on connection refused. + catch { + m = udp->read(); + if ((m->port == 53) && + (m->data[0..1] == s[0..1]) && + (search(nameservers, m->ip) != -1)) { + // Success. + return decode_res(m->data); + } + }; } } // Failure. -- GitLab