Software /
code /
prosody
Changeset
10968:23ae55cbbeaf
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 25 Jun 2020 18:20:51 +0200 |
parents | 10967:67aabf83230b |
children | 10969:d70db967c1b7 |
files | net/unbound.lua |
diffstat | 1 files changed, 12 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/net/unbound.lua Thu Jun 25 17:56:48 2020 +0200 +++ b/net/unbound.lua Thu Jun 25 18:20:51 2020 +0200 @@ -16,7 +16,7 @@ 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 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 = {