aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-05-26 21:47:25 +0100
committerMatthew Wild <mwild1@gmail.com>2009-05-26 21:47:25 +0100
commitc394acafc8fe231cc64b6bd21e5e10733a2bfb0e (patch)
treec53ad886d5087439352e19add934c8c382721783
parent173ba6433a1303ac24f0b29708f04e4f5c7e62b1 (diff)
downloadprosody-c394acafc8fe231cc64b6bd21e5e10733a2bfb0e.tar.gz
prosody-c394acafc8fe231cc64b6bd21e5e10733a2bfb0e.zip
net.dns: Add support for cancelling a coroutine-based request
-rw-r--r--net/dns.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/dns.lua b/net/dns.lua
index 0b37c0c6..69049317 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -21,8 +21,8 @@ local require = require
local coroutine, io, math, socket, string, table =
coroutine, io, math, socket, string, table
-local ipairs, next, pairs, print, setmetatable, tostring, assert, error =
- ipairs, next, pairs, print, setmetatable, tostring, assert, error
+local ipairs, next, pairs, print, setmetatable, tostring, assert, error, unpack =
+ ipairs, next, pairs, print, setmetatable, tostring, assert, error, unpack
local get, set = ztact.get, ztact.set
@@ -711,6 +711,12 @@ function resolver:feed(sock, packet)
return response
end
+function resolver:cancel(data)
+ local cos = get (self.wanted, unpack(data, 1, 3))
+ if cos then
+ cos[data[4]] = nil;
+ end
+end
function resolver:pulse () -- - - - - - - - - - - - - - - - - - - - - pulse
@@ -847,6 +853,8 @@ function dns.query (...) -- - - - - - - - - - - - - - - - - - - - - - query
function dns.feed (...) -- - - - - - - - - - - - - - - - - - - - - - feed
return resolve (resolver.feed, ...) end
+function dns.cancel(...) -- - - - - - - - - - - - - - - - - - - - - - cancel
+ return resolve(resolver.cancel, ...) end
function dns:socket_wrapper_set (...) -- - - - - - - - - socket_wrapper_set
return resolve (resolver.socket_wrapper_set, ...) end