mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
fix dns bug , see issue #605
This commit is contained in:
@@ -9,6 +9,7 @@ skynet.start(function()
|
|||||||
if not skynet.getenv "daemon" then
|
if not skynet.getenv "daemon" then
|
||||||
local console = skynet.newservice("console")
|
local console = skynet.newservice("console")
|
||||||
end
|
end
|
||||||
|
--[[
|
||||||
skynet.newservice("debug_console",8000)
|
skynet.newservice("debug_console",8000)
|
||||||
skynet.newservice("simpledb")
|
skynet.newservice("simpledb")
|
||||||
local watchdog = skynet.newservice("watchdog")
|
local watchdog = skynet.newservice("watchdog")
|
||||||
@@ -18,5 +19,6 @@ skynet.start(function()
|
|||||||
nodelay = true,
|
nodelay = true,
|
||||||
})
|
})
|
||||||
skynet.error("Watchdog listen on", 8888)
|
skynet.error("Watchdog listen on", 8888)
|
||||||
|
]]
|
||||||
skynet.exit()
|
skynet.exit()
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ local weak = {__mode = "kv"}
|
|||||||
local CACHE = {}
|
local CACHE = {}
|
||||||
|
|
||||||
local dns = {}
|
local dns = {}
|
||||||
|
local request_pool = {}
|
||||||
|
|
||||||
function dns.flush()
|
function dns.flush()
|
||||||
CACHE[QTYPE.A] = setmetatable({},weak)
|
CACHE[QTYPE.A] = setmetatable({},weak)
|
||||||
@@ -113,7 +114,21 @@ end
|
|||||||
local next_tid = 1
|
local next_tid = 1
|
||||||
local function gen_tid()
|
local function gen_tid()
|
||||||
local tid = next_tid
|
local tid = next_tid
|
||||||
next_tid = next_tid + 1
|
if request_pool[tid] then
|
||||||
|
tid = nil
|
||||||
|
for i = 1, 65535 do
|
||||||
|
-- find available tid
|
||||||
|
if not request_pool[i] then
|
||||||
|
tid = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(tid)
|
||||||
|
end
|
||||||
|
next_tid = tid + 1
|
||||||
|
if next_tid > 65535 then
|
||||||
|
next_tid = 1
|
||||||
|
end
|
||||||
return tid
|
return tid
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -205,7 +220,6 @@ local function unpack_rdata(qtype, chunk)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local dns_server
|
local dns_server
|
||||||
local request_pool = {}
|
|
||||||
|
|
||||||
local function resolve(content)
|
local function resolve(content)
|
||||||
if #content < DNS_HEADER_LEN then
|
if #content < DNS_HEADER_LEN then
|
||||||
|
|||||||
Reference in New Issue
Block a user