diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2017-02-23 17:04:03 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2017-02-23 17:04:03 +0000 |
commit | 66c4973318718ddd69f77d8bde5ca4d77fbabef9 (patch) | |
tree | de1915776aab0ac4f3dc56fbb5105cb681f7b03c /lib/libc/asr | |
parent | 752791f421bedfa4637cff8ab0f4307fbf6d712e (diff) |
Put a common subq pointer in the query struct, rather than one in each
element of the union.
ok gilles@ millert@ krw@
Diffstat (limited to 'lib/libc/asr')
-rw-r--r-- | lib/libc/asr/asr.c | 18 | ||||
-rw-r--r-- | lib/libc/asr/asr_private.h | 9 | ||||
-rw-r--r-- | lib/libc/asr/getaddrinfo_async.c | 10 | ||||
-rw-r--r-- | lib/libc/asr/gethostnamadr_async.c | 12 | ||||
-rw-r--r-- | lib/libc/asr/getnameinfo_async.c | 10 | ||||
-rw-r--r-- | lib/libc/asr/getnetnamadr_async.c | 12 | ||||
-rw-r--r-- | lib/libc/asr/getrrsetbyname_async.c | 12 | ||||
-rw-r--r-- | lib/libc/asr/res_search_async.c | 10 |
8 files changed, 40 insertions, 53 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c index d91a537599d..b678ebccebf 100644 --- a/lib/libc/asr/asr.c +++ b/lib/libc/asr/asr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr.c,v 1.55 2017/02/18 19:23:05 jca Exp $ */ +/* $OpenBSD: asr.c,v 1.56 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org> * @@ -236,6 +236,10 @@ void _asr_async_free(struct asr_query *as) { DPRINT("asr: asr_async_free(%p)\n", as); + + if (as->as_subq) + _asr_async_free(as->as_subq); + switch (as->as_type) { case ASR_SEND: if (as->as_fd != -1) @@ -249,38 +253,28 @@ _asr_async_free(struct asr_query *as) break; case ASR_SEARCH: - if (as->as.search.subq) - _asr_async_free(as->as.search.subq); if (as->as.search.name) free(as->as.search.name); break; case ASR_GETRRSETBYNAME: - if (as->as.rrset.subq) - _asr_async_free(as->as.rrset.subq); if (as->as.rrset.name) free(as->as.rrset.name); break; case ASR_GETHOSTBYNAME: case ASR_GETHOSTBYADDR: - if (as->as.hostnamadr.subq) - _asr_async_free(as->as.hostnamadr.subq); if (as->as.hostnamadr.name) free(as->as.hostnamadr.name); break; case ASR_GETNETBYNAME: case ASR_GETNETBYADDR: - if (as->as.netnamadr.subq) - _asr_async_free(as->as.netnamadr.subq); if (as->as.netnamadr.name) free(as->as.netnamadr.name); break; case ASR_GETADDRINFO: - if (as->as.ai.subq) - _asr_async_free(as->as.ai.subq); if (as->as.ai.aifirst) freeaddrinfo(as->as.ai.aifirst); if (as->as.ai.hostname) @@ -292,8 +286,6 @@ _asr_async_free(struct asr_query *as) break; case ASR_GETNAMEINFO: - if (as->as.ni.subq) - _asr_async_free(as->as.ni.subq); break; } diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h index 690d9ed537b..1bd49300d32 100644 --- a/lib/libc/asr/asr_private.h +++ b/lib/libc/asr/asr_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asr_private.h,v 1.42 2017/02/18 19:23:05 jca Exp $ */ +/* $OpenBSD: asr_private.h,v 1.43 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -170,6 +170,7 @@ struct asr_query { /* cond */ int as_timeout; int as_fd; + struct asr_query *as_subq; /* loop indices in ctx */ int as_dom_step; @@ -209,7 +210,6 @@ struct asr_query { int class; int type; char *name; - struct asr_query *subq; int saved_h_errno; } search; @@ -218,13 +218,11 @@ struct asr_query { int class; int type; char *name; - struct asr_query *subq; } rrset; struct { char *name; int family; - struct asr_query *subq; char addr[16]; int addrlen; int subq_h_errno; @@ -233,7 +231,6 @@ struct asr_query { struct { char *name; int family; - struct asr_query *subq; in_addr_t addr; } netnamadr; @@ -252,7 +249,6 @@ struct asr_query { char *fqdn; struct addrinfo *aifirst; struct addrinfo *ailast; - struct asr_query *subq; int flags; } ai; @@ -267,7 +263,6 @@ struct asr_query { struct sockaddr_in6 sain6; } sa; int flags; - struct asr_query *subq; } ni; #define MAXTOKEN 10 } as; diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index 1e78bd09bc6..b2bc71d4b5f 100644 --- a/lib/libc/asr/getaddrinfo_async.c +++ b/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.52 2017/02/21 22:32:28 eric Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.53 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -365,11 +365,11 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) break; } - as->as.ai.subq = _res_query_async_ctx(as->as.ai.fqdn, + as->as_subq = _res_query_async_ctx(as->as.ai.fqdn, C_IN, (family == AF_INET6) ? T_AAAA : T_A, as->as_ctx); - if (as->as.ai.subq == NULL) { + if (as->as_subq == NULL) { if (errno == ENOMEM) ar->ar_gai_errno = EAI_MEMORY; else @@ -407,10 +407,10 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) break; case ASR_STATE_SUBQUERY: - if ((r = asr_run(as->as.ai.subq, ar)) == ASYNC_COND) + if ((r = asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); - as->as.ai.subq = NULL; + as->as_subq = NULL; if (ar->ar_datalen == -1) { async_set_state(as, ASR_STATE_NEXT_FAMILY); diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c index a9a7801aab7..ae882c5d78a 100644 --- a/lib/libc/asr/gethostnamadr_async.c +++ b/lib/libc/asr/gethostnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr_async.c,v 1.42 2015/12/16 16:32:30 deraadt Exp $ */ +/* $OpenBSD: gethostnamadr_async.c,v 1.43 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -215,18 +215,18 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar) if (as->as_type == ASR_GETHOSTBYNAME) { type = (as->as.hostnamadr.family == AF_INET) ? T_A : T_AAAA; - as->as.hostnamadr.subq = _res_search_async_ctx( + as->as_subq = _res_search_async_ctx( as->as.hostnamadr.name, C_IN, type, as->as_ctx); } else { _asr_addr_as_fqdn(as->as.hostnamadr.addr, as->as.hostnamadr.family, name, sizeof(name)); - as->as.hostnamadr.subq = _res_query_async_ctx( + as->as_subq = _res_query_async_ctx( name, C_IN, T_PTR, as->as_ctx); } - if (as->as.hostnamadr.subq == NULL) { + if (as->as_subq == NULL) { ar->ar_errno = errno; ar->ar_h_errno = NETDB_INTERNAL; async_set_state(as, ASR_STATE_HALT); @@ -275,11 +275,11 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar) /* Run the DNS subquery. */ - if ((r = asr_run(as->as.hostnamadr.subq, ar)) == ASYNC_COND) + if ((r = asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); /* Done. */ - as->as.hostnamadr.subq = NULL; + as->as_subq = NULL; if (ar->ar_datalen == -1) { async_set_state(as, ASR_STATE_NEXT_DB); diff --git a/lib/libc/asr/getnameinfo_async.c b/lib/libc/asr/getnameinfo_async.c index 714e6b9696c..93d9a2dbea9 100644 --- a/lib/libc/asr/getnameinfo_async.c +++ b/lib/libc/asr/getnameinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnameinfo_async.c,v 1.12 2015/09/20 14:19:21 eric Exp $ */ +/* $OpenBSD: getnameinfo_async.c,v 1.13 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -140,10 +140,10 @@ getnameinfo_async_run(struct asr_query *as, struct asr_result *ar) /* * Create a subquery to lookup the address. */ - as->as.ni.subq = _gethostbyaddr_async_ctx(addr, addrlen, + as->as_subq = _gethostbyaddr_async_ctx(addr, addrlen, as->as.ni.sa.sa.sa_family, as->as_ctx); - if (as->as.ni.subq == NULL) { + if (as->as_subq == NULL) { ar->ar_gai_errno = EAI_MEMORY; async_set_state(as, ASR_STATE_HALT); break; @@ -154,13 +154,13 @@ getnameinfo_async_run(struct asr_query *as, struct asr_result *ar) case ASR_STATE_SUBQUERY: - if ((r = asr_run(as->as.ni.subq, ar)) == ASYNC_COND) + if ((r = asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); /* * Request done. */ - as->as.ni.subq = NULL; + as->as_subq = NULL; if (ar->ar_hostent == NULL) { if (as->as.ni.flags & NI_NAMEREQD) { diff --git a/lib/libc/asr/getnetnamadr_async.c b/lib/libc/asr/getnetnamadr_async.c index a1ff84a455e..0b8adc944b9 100644 --- a/lib/libc/asr/getnetnamadr_async.c +++ b/lib/libc/asr/getnetnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetnamadr_async.c,v 1.24 2017/02/21 22:32:28 eric Exp $ */ +/* $OpenBSD: getnetnamadr_async.c,v 1.25 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -155,7 +155,7 @@ getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar) */ type = T_PTR; name = as->as.netnamadr.name; - as->as.netnamadr.subq = _res_search_async_ctx( + as->as_subq = _res_search_async_ctx( name, C_IN, type, as->as_ctx); } else { type = T_PTR; @@ -165,11 +165,11 @@ getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar) _asr_addr_as_fqdn((char *)&in, as->as.netnamadr.family, dname, sizeof(dname)); - as->as.netnamadr.subq = _res_query_async_ctx( + as->as_subq = _res_query_async_ctx( name, C_IN, type, as->as_ctx); } - if (as->as.netnamadr.subq == NULL) { + if (as->as_subq == NULL) { ar->ar_errno = errno; ar->ar_h_errno = NETDB_INTERNAL; async_set_state(as, ASR_STATE_HALT); @@ -211,9 +211,9 @@ getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar) case ASR_STATE_SUBQUERY: - if ((r = asr_run(as->as.netnamadr.subq, ar)) == ASYNC_COND) + if ((r = asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); - as->as.netnamadr.subq = NULL; + as->as_subq = NULL; if (ar->ar_datalen == -1) { async_set_state(as, ASR_STATE_NEXT_DB); diff --git a/lib/libc/asr/getrrsetbyname_async.c b/lib/libc/asr/getrrsetbyname_async.c index ac2bc32be57..e5e7c23c261 100644 --- a/lib/libc/asr/getrrsetbyname_async.c +++ b/lib/libc/asr/getrrsetbyname_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrrsetbyname_async.c,v 1.10 2015/09/20 14:19:21 eric Exp $ */ +/* $OpenBSD: getrrsetbyname_async.c,v 1.11 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -94,12 +94,12 @@ getrrsetbyname_async_run(struct asr_query *as, struct asr_result *ar) } /* Create a delegate the lookup to a subquery. */ - as->as.rrset.subq = _res_query_async_ctx( + as->as_subq = _res_query_async_ctx( as->as.rrset.name, as->as.rrset.class, as->as.rrset.type, as->as_ctx); - if (as->as.rrset.subq == NULL) { + if (as->as_subq == NULL) { ar->ar_rrset_errno = ERRSET_FAIL; async_set_state(as, ASR_STATE_HALT); break; @@ -110,10 +110,10 @@ getrrsetbyname_async_run(struct asr_query *as, struct asr_result *ar) case ASR_STATE_SUBQUERY: - if ((asr_run(as->as.rrset.subq, ar)) == ASYNC_COND) + if ((asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); - as->as.rrset.subq = NULL; + as->as_subq = NULL; /* No packet received.*/ if (ar->ar_datalen == -1) { @@ -170,7 +170,7 @@ getrrsetbyname_async_run(struct asr_query *as, struct asr_result *ar) /* The rest of this file is taken from the orignal implementation. */ -/* $OpenBSD: getrrsetbyname_async.c,v 1.10 2015/09/20 14:19:21 eric Exp $ */ +/* $OpenBSD: getrrsetbyname_async.c,v 1.11 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2001 Jakob Schlyter. All rights reserved. diff --git a/lib/libc/asr/res_search_async.c b/lib/libc/asr/res_search_async.c index 5a351d636d3..26be7d91622 100644 --- a/lib/libc/asr/res_search_async.c +++ b/lib/libc/asr/res_search_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: res_search_async.c,v 1.19 2015/12/16 16:32:30 deraadt Exp $ */ +/* $OpenBSD: res_search_async.c,v 1.20 2017/02/23 17:04:02 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -120,9 +120,9 @@ res_search_async_run(struct asr_query *as, struct asr_result *ar) async_set_state(as, ASR_STATE_HALT); break; } - as->as.search.subq = _res_query_async_ctx(fqdn, + as->as_subq = _res_query_async_ctx(fqdn, as->as.search.class, as->as.search.type, as->as_ctx); - if (as->as.search.subq == NULL) { + if (as->as_subq == NULL) { ar->ar_errno = errno; if (errno == EINVAL) ar->ar_h_errno = NO_RECOVERY; @@ -138,9 +138,9 @@ res_search_async_run(struct asr_query *as, struct asr_result *ar) case ASR_STATE_SUBQUERY: - if ((r = asr_run(as->as.search.subq, ar)) == ASYNC_COND) + if ((r = asr_run(as->as_subq, ar)) == ASYNC_COND) return (ASYNC_COND); - as->as.search.subq = NULL; + as->as_subq = NULL; if (ar->ar_h_errno == NETDB_SUCCESS) { async_set_state(as, ASR_STATE_HALT); |