# HG changeset patch # User Kim Alvefur # Date 1780161668 -7200 # Node ID c4aa9b2b4787b54602f0c12012159b3851ead714 # Parent 9c062f243d3aac24e3d570c8c41a31194dd77847 net.unbound: Simplify by removing cancel() Not aware that it is used anywhere. Removes potential "leak" by forgetting to remove the entry from the now deleted table. diff -r 9c062f243d3a -r c4aa9b2b4787 net/unbound.lua --- a/net/unbound.lua Sat May 30 19:18:21 2026 +0200 +++ b/net/unbound.lua Sat May 30 19:21:08 2026 +0200 @@ -83,8 +83,6 @@ end; }; -local waiting_queries = {}; - local function prep_answer(a) if not a then return end local status = errors[a.rcode]; @@ -117,11 +115,9 @@ local ntype, nclass = types[qtype], classes[qclass]; local m; - local ret; local log_query = logger.init("unbound.query"..new_id()); local function callback_wrapper(a, err) m(); - waiting_queries[ret] = nil; if a then prep_answer(a); log_query("debug", "Results for %s %s %s: %s (%s)", qname, qclass, qtype, a.rcode == 0 and (#a .. " items") or a.status, @@ -134,11 +130,8 @@ end log_query("debug", "Resolve %s %s %s", qname, qclass, qtype); m = measure(qclass, qtype); - local err; - ret, err = unbound:resolve_async(callback_wrapper, qname, ntype, nclass); - if ret then - waiting_queries[ret] = callback; - else + local ret, err = unbound:resolve_async(callback_wrapper, qname, ntype, nclass); + if not ret then log_query("error", "Resolver error: %s", err); end return ret, err; @@ -154,24 +147,15 @@ return prep_answer(a); end -local function cancel(id) - local cb = waiting_queries[id]; - unbound:cancel(id); - if cb then - cb(nil, "canceled"); - waiting_queries[id] = nil; - end - return true; -end - -- Reinitiate libunbound context, drops cache local function purge() if server_conn then local old_unbound, old_server_conn = unbound, server_conn; timer.add_task(30, function() old_server_conn:close(); - -- Blocking wait for any straggler queries to prevent "leak" of waiting_queries[] entries - old_unbound:wait(); + if old_unbound.cancelall then + old_unbound:cancelall(); + end end) end initialize(); @@ -194,11 +178,11 @@ -- Public API local _M = { lookup = lookup; - cancel = cancel; + cancel = not_implemented; new_async_socket = not_implemented; dns = { lookup = lookup_sync; - cancel = cancel; + cancel = not_implemented; cache = noop; socket_wrapper_set = noop; settimeout = noop;