summaryrefslogtreecommitdiffstats
path: root/libc/netbsd/resolv/res_send.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/netbsd/resolv/res_send.c')
-rw-r--r--libc/netbsd/resolv/res_send.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/libc/netbsd/resolv/res_send.c b/libc/netbsd/resolv/res_send.c
index f3ee539..ceb2c77 100644
--- a/libc/netbsd/resolv/res_send.c
+++ b/libc/netbsd/resolv/res_send.c
@@ -370,10 +370,13 @@ res_nsend(res_state statp,
ResolvCacheStatus cache_status = RESOLV_CACHE_UNSUPPORTED;
#endif
+#if !USE_RESOLV_CACHE
if (statp->nscount == 0) {
errno = ESRCH;
return (-1);
}
+#endif
+
if (anssiz < HFIXEDSZ) {
errno = EINVAL;
return (-1);
@@ -385,17 +388,27 @@ res_nsend(res_state statp,
terrno = ETIMEDOUT;
#if USE_RESOLV_CACHE
- cache = __get_res_cache();
- if (cache != NULL) {
- int anslen = 0;
- cache_status = _resolv_cache_lookup(
- cache, buf, buflen,
- ans, anssiz, &anslen);
-
- if (cache_status == RESOLV_CACHE_FOUND) {
- return anslen;
- }
- }
+ // get the cache associated with the interface
+ cache = __get_res_cache(statp->iface);
+ if (cache != NULL) {
+ int anslen = 0;
+ cache_status = _resolv_cache_lookup(
+ cache, buf, buflen,
+ ans, anssiz, &anslen);
+
+ if (cache_status == RESOLV_CACHE_FOUND) {
+ return anslen;
+ } else {
+ // had a cache miss for a known interface, so populate the thread private
+ // data so the normal resolve path can do its thing
+ _resolv_populate_res_for_iface(statp);
+ }
+ }
+
+ if (statp->nscount == 0) {
+ errno = ESRCH;
+ return (-1);
+ }
#endif
/*