aboutsummaryrefslogtreecommitdiffstats
path: root/net/adns.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-05-26 21:48:32 +0100
committerMatthew Wild <mwild1@gmail.com>2009-05-26 21:48:32 +0100
commitd2197f6ca335ee102665743a4efa157bf5b2dfa9 (patch)
treea4fbff14d2a6bf50bac1fc4934349bae79030bfc /net/adns.lua
parentc394acafc8fe231cc64b6bd21e5e10733a2bfb0e (diff)
downloadprosody-d2197f6ca335ee102665743a4efa157bf5b2dfa9.tar.gz
prosody-d2197f6ca335ee102665743a4efa157bf5b2dfa9.zip
net.adns: Add support for cancelling a non-blocking lookup, optionally calling the handler
Diffstat (limited to 'net/adns.lua')
-rw-r--r--net/adns.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/adns.lua b/net/adns.lua
index 07d4fe54..6062da73 100644
--- a/net/adns.lua
+++ b/net/adns.lua
@@ -16,7 +16,7 @@ function lookup(handler, qname, qtype, qclass)
end
log("debug", "Records for %s not in cache, sending query (%s)...", qname, tostring(coroutine.running()));
dns.query(qname, qtype, qclass);
- coroutine.yield(nil); -- Wait for reply
+ coroutine.yield({ qclass or "IN", qtype or "A", qname, coroutine.running()}); -- Wait for reply
log("debug", "Reply for %s (%s)", qname, tostring(coroutine.running()));
local ok, err = pcall(handler, dns.peek(qname, qtype, qclass));
if not ok then
@@ -25,6 +25,13 @@ function lookup(handler, qname, qtype, qclass)
end)(dns.peek(qname, qtype, qclass));
end
+function cancel(handle, call_handler)
+ dns.cancel(handle);
+ if call_handler then
+ handle[4]()
+ end
+end
+
function new_async_socket(sock)
local newconn = {};
local listener = {};