aboutsummaryrefslogtreecommitdiffstats
path: root/net/unbound.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-06-25 18:20:51 +0200
committerKim Alvefur <zash@zash.se>2020-06-25 18:20:51 +0200
commit02c3cc978d3320eead41d114bb8b814c98557756 (patch)
tree605962633fb568f4af5a9b47e46da0b4c56b4207 /net/unbound.lua
parent9be5cb3fbdffc7c19ade04d635501cbea1be3af7 (diff)
downloadprosody-02c3cc978d3320eead41d114bb8b814c98557756.tar.gz
prosody-02c3cc978d3320eead41d114bb8b814c98557756.zip
net.unbound: Remove compat for missing promises (pre-0.11)
Code existed in a separate project before merged into Prosody, so util.promise was not always around.
Diffstat (limited to 'net/unbound.lua')
-rw-r--r--net/unbound.lua27
1 files changed, 12 insertions, 15 deletions
diff --git a/net/unbound.lua b/net/unbound.lua
index dbf010ea..49f220e1 100644
--- a/net/unbound.lua
+++ b/net/unbound.lua
@@ -16,7 +16,7 @@ local noop = function() end;
local log = require "util.logger".init("unbound");
local net_server = require "net.server";
local libunbound = require"lunbound";
-local have_promise, promise = pcall(require, "util.promise");
+local promise = require"util.promise";
local gettime = require"socket".gettime;
local dns_utils = require"util.dns";
@@ -178,21 +178,18 @@ local _M = {
};
};
-local lookup_promise;
-if have_promise then
- function lookup_promise(_, qname, qtype, qclass)
- return promise.new(function (resolve, reject)
- local function callback(answer, err)
- if err then
- return reject(err);
- else
- return resolve(answer);
- end
+local function lookup_promise(_, qname, qtype, qclass)
+ return promise.new(function (resolve, reject)
+ local function callback(answer, err)
+ if err then
+ return reject(err);
+ else
+ return resolve(answer);
end
- local ret, err = lookup(callback, qname, qtype, qclass)
- if not ret then reject(err); end
- end);
- end
+ end
+ local ret, err = lookup(callback, qname, qtype, qclass)
+ if not ret then reject(err); end
+ end);
end
local wrapper = {