diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2018-11-12 12:31:50 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2018-11-12 12:31:50 +0000 |
commit | f2d3cbfe0dd6be6b43cd81d5ace56bee4eb94c4f (patch) | |
tree | d87fa439db798aee7be239067e3adb16585845a6 | |
parent | e7f73d9bf2f7e9693f5d93e3676a9cb23afcf983 (diff) |
simplify code for resolver_getnaimeinfo()
ok gilles@
-rw-r--r-- | usr.sbin/smtpd/resolver.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/usr.sbin/smtpd/resolver.c b/usr.sbin/smtpd/resolver.c index 22011520f09..5422141647b 100644 --- a/usr.sbin/smtpd/resolver.c +++ b/usr.sbin/smtpd/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.3 2018/11/11 14:56:05 eric Exp $ */ +/* $OpenBSD: resolver.c,v 1.4 2018/11/12 12:31:49 eric Exp $ */ /* * Copyright (c) 2017-2018 Eric Faurot <eric@openbsd.org> @@ -206,6 +206,8 @@ resolver_dispatch_request(struct mproc *proc, struct imsg *imsg) m_create(proc, IMSG_GETNAMEINFO, reqid, 0, -1); m_add_int(proc, EAI_SYSTEM); m_add_int(proc, save_errno); + m_add_string(proc, NULL); + m_add_string(proc, NULL); m_close(proc); break; @@ -283,15 +285,12 @@ resolver_dispatch_result(struct mproc *proc, struct imsg *imsg) case IMSG_GETNAMEINFO: m_get_int(&m, &gai_errno); m_get_int(&m, &errno); - if (gai_errno == 0) { - m_get_string(&m, &host); - m_get_string(&m, &serv); - } + m_get_string(&m, &host); + m_get_string(&m, &serv); m_end(&m); SPLAY_REMOVE(reqtree, &reqs, req); - req->cb_ni(req->arg, gai_errno, gai_errno ? NULL : host, - gai_errno ? NULL : serv); + req->cb_ni(req->arg, gai_errno, host, serv); free(req); break; } @@ -343,10 +342,8 @@ resolver_getnameinfo_cb(struct asr_result *ar, void *arg) m_create(s->proc, IMSG_GETNAMEINFO, s->reqid, 0, -1); m_add_int(s->proc, ar->ar_gai_errno); m_add_int(s->proc, ar->ar_errno); - if (ar->ar_gai_errno == 0) { - m_add_string(s->proc, s->host); - m_add_string(s->proc, s->serv); - } + m_add_string(s->proc, ar->ar_gai_errno ? NULL : s->host); + m_add_string(s->proc, ar->ar_gai_errno ? NULL : s->serv); m_close(s->proc); free(s->host); |