Comparison

net/adns.lua @ 10112:b327f2870382

net.*: Remove tostring call from logging Taken care of by loggingmanager now
author Kim Alvefur <zash@zash.se>
date Tue, 30 Jul 2019 02:35:17 +0200
parent 9731:47121e8dc5b1
child 10114:2f7628804db6
comparison
equal deleted inserted replaced
10111:0f335815244f 10112:b327f2870382
71 if peek then 71 if peek then
72 log("debug", "Records for %s already cached, using those...", qname); 72 log("debug", "Records for %s already cached, using those...", qname);
73 handler(peek); 73 handler(peek);
74 return; 74 return;
75 end 75 end
76 log("debug", "Records for %s not in cache, sending query (%s)...", qname, tostring(coroutine.running())); 76 log("debug", "Records for %s not in cache, sending query (%s)...", qname, coroutine.running());
77 local ok, err = resolver:query(qname, qtype, qclass); 77 local ok, err = resolver:query(qname, qtype, qclass);
78 if ok then 78 if ok then
79 coroutine.yield(setmetatable({ resolver, qclass or "IN", qtype or "A", qname, coroutine.running()}, query_mt)); -- Wait for reply 79 coroutine.yield(setmetatable({ resolver, qclass or "IN", qtype or "A", qname, coroutine.running()}, query_mt)); -- Wait for reply
80 log("debug", "Reply for %s (%s)", qname, tostring(coroutine.running())); 80 log("debug", "Reply for %s (%s)", qname, coroutine.running());
81 end 81 end
82 if ok then 82 if ok then
83 ok, err = pcall(handler, resolver:peek(qname, qtype, qclass)); 83 ok, err = pcall(handler, resolver:peek(qname, qtype, qclass));
84 else 84 else
85 log("error", "Error sending DNS query: %s", err); 85 log("error", "Error sending DNS query: %s", err);
86 ok, err = pcall(handler, nil, err); 86 ok, err = pcall(handler, nil, err);
87 end 87 end
88 if not ok then 88 if not ok then
89 log("error", "Error in DNS response handler: %s", tostring(err)); 89 log("error", "Error in DNS response handler: %s", err);
90 end 90 end
91 end)(resolver:peek(qname, qtype, qclass)); 91 end)(resolver:peek(qname, qtype, qclass));
92 end 92 end
93 93
94 function query_methods:cancel(call_handler, reason) -- luacheck: ignore 212/reason 94 function query_methods:cancel(call_handler, reason) -- luacheck: ignore 212/reason
95 log("warn", "Cancelling DNS lookup for %s", tostring(self[4])); 95 log("warn", "Cancelling DNS lookup for %s", self[4]);
96 self[1].cancel(self[2], self[3], self[4], self[5], call_handler); 96 self[1].cancel(self[2], self[3], self[4], self[5], call_handler);
97 end 97 end
98 98
99 local function new_async_resolver() 99 local function new_async_resolver()
100 local resolver = new_resolver(); 100 local resolver = new_resolver();