Software /
code /
prosody
Comparison
net/unbound.lua @ 11252:ba335004ca60
net.unbound: Move libunbound initialization into a function
Prepare for lazy-loading it.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 05 Jan 2021 21:36:04 +0100 |
parent | 11250:d1351683dfe5 |
child | 11253:919e7b962f0b |
comparison
equal
deleted
inserted
replaced
11251:520b09bbbad5 | 11252:ba335004ca60 |
---|---|
52 log("debug", "Processing queries for %s", unbound); | 52 log("debug", "Processing queries for %s", unbound); |
53 unbound:process() | 53 unbound:process() |
54 end); | 54 end); |
55 end | 55 end |
56 | 56 |
57 local unbound = libunbound.new(unbound_config); | 57 local unbound, server_conn; |
58 | 58 |
59 local server_conn = connect_server(unbound, net_server); | 59 local function initialize() |
60 unbound = libunbound.new(unbound_config); | |
61 server_conn = connect_server(unbound, net_server); | |
62 end | |
63 initialize(); | |
60 | 64 |
61 local answer_mt = { | 65 local answer_mt = { |
62 __tostring = function(self) | 66 __tostring = function(self) |
63 if self._string then return self._string end | 67 if self._string then return self._string end |
64 local h = s_format("Status: %s", errors[self.status]); | 68 local h = s_format("Status: %s", errors[self.status]); |
152 | 156 |
153 -- Reinitiate libunbound context, drops cache | 157 -- Reinitiate libunbound context, drops cache |
154 local function purge() | 158 local function purge() |
155 for id in pairs(waiting_queries) do cancel(id); end | 159 for id in pairs(waiting_queries) do cancel(id); end |
156 if server_conn then server_conn:close(); end | 160 if server_conn then server_conn:close(); end |
157 unbound = libunbound.new(unbound_config); | 161 initialize(); |
158 server_conn = connect_server(unbound, net_server); | |
159 return true; | 162 return true; |
160 end | 163 end |
161 | 164 |
162 local function not_implemented() | 165 local function not_implemented() |
163 error "not implemented"; | 166 error "not implemented"; |