diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-07-05 12:09:50 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-07-05 12:09:50 +0100 |
commit | d2b5e885a827c7f91c1216c2603b89831bf498d0 (patch) | |
tree | 68a5d145b40ff7727f89612723717fc491c5a6be /net/dns.lua | |
parent | cad77ed8cfa2bdb6f93ea65c90a17c624bdc7e6e (diff) | |
download | prosody-d2b5e885a827c7f91c1216c2603b89831bf498d0.tar.gz prosody-d2b5e885a827c7f91c1216c2603b89831bf498d0.zip |
net.dns: Make timeout configurable (default 15s)
Diffstat (limited to 'net/dns.lua')
-rw-r--r-- | net/dns.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/dns.lua b/net/dns.lua index b3cce111..dbb4fc49 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -29,7 +29,7 @@ local ipairs, next, pairs, print, setmetatable, tostring, assert, error, unpack local get, set = ztact.get, ztact.set; -local dns_timeout = 15; +local default_timeout = 15; -------------------------------------------------- module dns module('dns') @@ -118,6 +118,7 @@ end local resolver = {}; resolver.__index = resolver; +resolver.timeout = default_timeout; local SRV_tostring; @@ -684,10 +685,10 @@ function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query local conn = self:getsocket(o.server) conn:send (o.packet) - if timer then + if timer and self.timeout then local num_servers = #self.server; local i = 1; - timer.add_task(dns_timeout, function () + timer.add_task(self.timeout, function () if get(self.wanted, qclass, qtype, qname, co) then if i < num_servers then i = i + 1; @@ -695,7 +696,7 @@ function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query o.server = self.best_server; conn = self:getsocket(o.server); conn:send(o.packet); - return dns_timeout; + return self.timeout; else -- Tried everything, failed resolver:cancel(qclass, qtype, qname, co, true); @@ -744,6 +745,10 @@ function resolver:servfail(sock) end end +function resolver:settimeout(seconds) + self.timeout = seconds; +end + function resolver:receive(rset) -- - - - - - - - - - - - - - - - - receive --print('receive'); print(self.socket); self.time = socket.gettime(); |