aboutsummaryrefslogtreecommitdiffstats
path: root/net/unbound.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-05 21:36:04 +0100
committerKim Alvefur <zash@zash.se>2021-01-05 21:36:04 +0100
commit4972d5b7fd8a549577eefc75f77ee9fbd1a5bcdd (patch)
tree363f3bb05f09f83fd8d553e922a414eb1d51dd9b /net/unbound.lua
parentcc47c921afd867fc9152e31f84ac4780087e7cc5 (diff)
downloadprosody-4972d5b7fd8a549577eefc75f77ee9fbd1a5bcdd.tar.gz
prosody-4972d5b7fd8a549577eefc75f77ee9fbd1a5bcdd.zip
net.unbound: Move libunbound initialization into a function
Prepare for lazy-loading it.
Diffstat (limited to 'net/unbound.lua')
-rw-r--r--net/unbound.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/unbound.lua b/net/unbound.lua
index 48a8df0e..85ae624f 100644
--- a/net/unbound.lua
+++ b/net/unbound.lua
@@ -54,9 +54,13 @@ local function connect_server(unbound, server)
end);
end
-local unbound = libunbound.new(unbound_config);
+local unbound, server_conn;
-local server_conn = connect_server(unbound, net_server);
+local function initialize()
+ unbound = libunbound.new(unbound_config);
+ server_conn = connect_server(unbound, net_server);
+end
+initialize();
local answer_mt = {
__tostring = function(self)
@@ -154,8 +158,7 @@ end
local function purge()
for id in pairs(waiting_queries) do cancel(id); end
if server_conn then server_conn:close(); end
- unbound = libunbound.new(unbound_config);
- server_conn = connect_server(unbound, net_server);
+ initialize();
return true;
end