From 71d6a178cf72488d80456415ac8ab8d9b85d47c3 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 2 Feb 2007 09:57:53 +0000 Subject: [PATCH] Small fixed. Get fwdaddr to work on BSD. Memleak fix. git-svn-id: file:///svn/unbound/trunk@52 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/unbound.c | 1 + daemon/worker.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/unbound.c b/daemon/unbound.c index 373d1280b..f1c90d456 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -118,6 +118,7 @@ main(int argc, char* argv[]) fatal_exit("could not initialize"); } if(!worker_set_fwd(worker, fwd, fwdport)) { + worker_delete(worker); fatal_exit("could set forwarder address"); } diff --git a/daemon/worker.c b/daemon/worker.c index 6f7525457..9051101b1 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -189,11 +189,15 @@ void worker_delete(struct worker* worker) int worker_set_fwd(struct worker* worker, const char* ip, const char* port) { struct addrinfo *res = NULL; + struct addrinfo hints; int r; log_assert(worker && ip); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; if(!port) port = UNBOUND_DNS_PORT; - if((r=getaddrinfo(ip, port, NULL, &res)) != 0 || !res) { + if((r=getaddrinfo(ip, port, &hints, &res)) != 0 || !res) { log_err("failed %s:%s getaddrinfo: %s %s", ip, port, gai_strerror(r), r==EAI_SYSTEM?strerror(errno):""); -- 2.47.2