mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53: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
|
||||
local console = skynet.newservice("console")
|
||||
end
|
||||
--[[
|
||||
skynet.newservice("debug_console",8000)
|
||||
skynet.newservice("simpledb")
|
||||
local watchdog = skynet.newservice("watchdog")
|
||||
@@ -18,5 +19,6 @@ skynet.start(function()
|
||||
nodelay = true,
|
||||
})
|
||||
skynet.error("Watchdog listen on", 8888)
|
||||
]]
|
||||
skynet.exit()
|
||||
end)
|
||||
|
||||
@@ -87,6 +87,7 @@ local weak = {__mode = "kv"}
|
||||
local CACHE = {}
|
||||
|
||||
local dns = {}
|
||||
local request_pool = {}
|
||||
|
||||
function dns.flush()
|
||||
CACHE[QTYPE.A] = setmetatable({},weak)
|
||||
@@ -113,7 +114,21 @@ end
|
||||
local next_tid = 1
|
||||
local function gen_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
|
||||
end
|
||||
|
||||
@@ -205,7 +220,6 @@ local function unpack_rdata(qtype, chunk)
|
||||
end
|
||||
|
||||
local dns_server
|
||||
local request_pool = {}
|
||||
|
||||
local function resolve(content)
|
||||
if #content < DNS_HEADER_LEN then
|
||||
|
||||
Reference in New Issue
Block a user