diff options
author | Charles Longeau <github@chl.be> | 2013-04-18 19:29:04 +0200 |
---|---|---|
committer | Charles Longeau <github@chl.be> | 2013-04-18 19:29:04 +0200 |
commit | ca61e61fc6992916f63112700f080a0b79ea5583 (patch) | |
tree | db400ea8690f709c6d6cfe5581e719d4ccfdc367 /contrib | |
parent | Merge branch 'master' into portable (diff) | |
download | OpenSMTPD-ca61e61fc6992916f63112700f080a0b79ea5583.tar.xz OpenSMTPD-ca61e61fc6992916f63112700f080a0b79ea5583.zip |
sync with latest asr changes
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/lib/libc/asr/CVS/Entries | 28 | ||||
-rw-r--r-- | contrib/lib/libc/asr/asr.c | 35 |
2 files changed, 35 insertions, 28 deletions
diff --git a/contrib/lib/libc/asr/CVS/Entries b/contrib/lib/libc/asr/CVS/Entries index 59e65afd..bad144ac 100644 --- a/contrib/lib/libc/asr/CVS/Entries +++ b/contrib/lib/libc/asr/CVS/Entries @@ -4,23 +4,23 @@ /getnetnamadr_async.c/1.8/Result of merge// /res_search_async.c/1.6/Result of merge// /Makefile.inc/1.5/Sat Nov 24 17:15:45 2012// -/asr.c/1.22/Result of merge// /asr_debug.c/1.12/Result of merge// -/asr_private.h/1.16/Tue Apr 16 18:44:14 2013// /asr_utils.c/1.7/Result of merge// -/async_resolver.3/1.10/Tue Apr 16 18:44:14 2013// -/getaddrinfo.c/1.1/Tue Apr 16 18:44:14 2013// /getaddrinfo_async.c/1.15/Result of merge// -/gethostnamadr.c/1.6/Tue Apr 16 18:45:05 2013// /gethostnamadr_async.c/1.18/Result of merge// -/getnameinfo.c/1.1/Tue Apr 16 18:44:14 2013// -/getnetnamadr.c/1.4/Tue Apr 16 18:44:14 2013// -/getrrsetbyname.c/1.1/Tue Apr 16 18:44:14 2013// -/res_debug.c/1.1/Tue Apr 16 18:44:14 2013// -/res_init.c/1.1/Tue Apr 16 18:44:14 2013// -/res_mkquery.c/1.5/Tue Apr 16 18:44:14 2013// -/res_query.c/1.2/Tue Apr 16 18:45:05 2013// -/res_send.c/1.2/Tue Apr 16 18:45:05 2013// /res_send_async.c/1.16/Result of merge// -/sethostent.c/1.1/Tue Apr 16 18:44:14 2013// +/asr.c/1.24/Result of merge// +/asr_private.h/1.16/Thu Apr 18 17:28:02 2013// +/async_resolver.3/1.10/Thu Apr 18 17:28:02 2013// +/getaddrinfo.c/1.1/Thu Apr 18 17:28:02 2013// +/gethostnamadr.c/1.6/Thu Apr 18 17:28:02 2013// +/getnameinfo.c/1.1/Thu Apr 18 17:28:02 2013// +/getnetnamadr.c/1.4/Thu Apr 18 17:28:02 2013// +/getrrsetbyname.c/1.1/Thu Apr 18 17:28:02 2013// +/res_debug.c/1.1/Thu Apr 18 17:28:02 2013// +/res_init.c/1.1/Thu Apr 18 17:28:02 2013// +/res_mkquery.c/1.5/Thu Apr 18 17:28:02 2013// +/res_query.c/1.2/Thu Apr 18 17:28:02 2013// +/res_send.c/1.2/Thu Apr 18 17:28:02 2013// +/sethostent.c/1.1/Thu Apr 18 17:28:02 2013// D diff --git a/contrib/lib/libc/asr/asr.c b/contrib/lib/libc/asr/asr.c index d7a71acb..81d36a26 100644 --- a/contrib/lib/libc/asr/asr.c +++ b/contrib/lib/libc/asr/asr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr.c,v 1.22 2013/04/11 20:19:16 otto Exp $ */ +/* $OpenBSD: asr.c,v 1.24 2013/04/17 19:13:23 otto Exp $ */ /* * Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org> * @@ -130,6 +130,8 @@ async_resolver(const char *conf) } else { /* Use the given config file */ asr->a_path = strdup(conf); + if (asr->a_path == NULL) + goto fail; asr_check_reload(asr); if (asr->a_ctx == NULL) { if ((asr->a_ctx = asr_ctx_create()) == NULL) @@ -151,6 +153,7 @@ async_resolver(const char *conf) if (asr) { if (asr->a_ctx) asr_ctx_free(asr->a_ctx); + free(asr->a_path); free(asr); } @@ -175,8 +178,7 @@ async_resolver_done(struct asr *asr) } asr_ctx_unref(asr->a_ctx); - if (asr->a_path) - free(asr->a_path); + free(asr->a_path); free(asr); } @@ -255,8 +257,8 @@ async_new(struct asr_ctx *ac, int type) struct async *as; DPRINT("asr: async_new(ctx=%p) type=%i refcount=%i\n", ac, type, - ac->ac_refcount); - if ((as = calloc(1, sizeof(*as))) == NULL) + ac ? ac->ac_refcount : 0); + if (ac == NULL || (as = calloc(1, sizeof(*as))) == NULL) return (NULL); ac->ac_refcount += 1; @@ -359,10 +361,12 @@ asr_use_resolver(struct asr *asr) } asr = *priv; } - - asr_check_reload(asr); - asr_ctx_ref(asr->a_ctx); - return (asr->a_ctx); + if (asr != NULL) { + asr_check_reload(asr); + asr_ctx_ref(asr->a_ctx); + return (asr->a_ctx); + } + return (NULL); } static void @@ -379,7 +383,10 @@ asr_ctx_ref(struct asr_ctx *ac) void asr_ctx_unref(struct asr_ctx *ac) { - DPRINT("asr: asr_ctx_unref(ctx=%p) refcount=%i\n", ac, ac->ac_refcount); + DPRINT("asr: asr_ctx_unref(ctx=%p) refcount=%i\n", ac, + ac ? ac->ac_refcount : 0); + if (ac == NULL) + return; if (--ac->ac_refcount) return; @@ -410,19 +417,19 @@ asr_check_reload(struct asr *asr) struct asr_ctx *ac; #if ASR_OPT_RELOADCONF struct stat st; - struct timespec tp; + struct timespec ts; #endif if (asr->a_path == NULL) return; #if ASR_OPT_RELOADCONF - if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) return; - if ((tp.tv_sec - asr->a_rtime) < RELOAD_DELAY && asr->a_rtime != 0) + if ((ts.tv_sec - asr->a_rtime) < RELOAD_DELAY && asr->a_rtime != 0) return; - asr->a_rtime = tp.tv_sec; + asr->a_rtime = ts.tv_sec; DPRINT("asr: checking for update of \"%s\"\n", asr->a_path); if (stat(asr->a_path, &st) == -1 || |