Software /
code /
prosody
Comparison
net/adns.lua @ 2558:0a65fc0c7bee
net.adns: Use different flavour of voodoo to make UDP sockets work smoothly with libevent (no packet merging)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 31 Jan 2010 19:54:56 +0000 |
parent | 2556:50d1ba86a959 |
child | 2578:61e5eff54415 |
comparison
equal
deleted
inserted
replaced
2557:e5254ccd5ef8 | 2558:0a65fc0c7bee |
---|---|
11 | 11 |
12 local log = require "util.logger".init("adns"); | 12 local log = require "util.logger".init("adns"); |
13 | 13 |
14 local t_insert, t_remove = table.insert, table.remove; | 14 local t_insert, t_remove = table.insert, table.remove; |
15 local coroutine, tostring, pcall = coroutine, tostring, pcall; | 15 local coroutine, tostring, pcall = coroutine, tostring, pcall; |
16 | |
17 local function dummy_send(sock, data, i, j) return (j-i)+1; end | |
16 | 18 |
17 module "adns" | 19 module "adns" |
18 | 20 |
19 function lookup(handler, qname, qtype, qclass) | 21 function lookup(handler, qname, qtype, qclass) |
20 return coroutine.wrap(function (peek) | 22 return coroutine.wrap(function (peek) |
63 log("warn", "handler is nil"); | 65 log("warn", "handler is nil"); |
64 end | 66 end |
65 | 67 |
66 handler.settimeout = function () end | 68 handler.settimeout = function () end |
67 handler.setsockname = function (_, ...) return sock:setsockname(...); end | 69 handler.setsockname = function (_, ...) return sock:setsockname(...); end |
68 handler.setpeername = function (_, ...) peername = (...); local ret = sock:setpeername(...); _:set_send(sock.send); return ret; end | 70 handler.setpeername = function (_, ...) peername = (...); local ret = sock:setpeername(...); _:set_send(dummy_send); return ret; end |
69 handler.connect = function (_, ...) return sock:connect(...) end | 71 handler.connect = function (_, ...) return sock:connect(...) end |
70 handler.send = function (_, data) _:write(data); return _.sendbuffer and _.sendbuffer(); end | 72 --handler.send = function (_, data) _:write(data); return _.sendbuffer and _.sendbuffer(); end |
73 handler.send = function (_, data) return sock:send(data); end | |
71 return handler; | 74 return handler; |
72 end | 75 end |
73 | 76 |
74 dns:socket_wrapper_set(new_async_socket); | 77 dns:socket_wrapper_set(new_async_socket); |
75 | 78 |