From c87d75f2aa6fde49a99cf3287e535a14f354f781 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 21 Sep 2022 18:49:53 -0400 Subject: [PATCH 1/3] adapt res_msend DNS query core for working with multiple sockets this is groundwork for TCP fallback support, but does not itself change behavior in any way. --- src/network/res_msend.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/network/res_msend.c b/src/network/res_msend.c index 9adaea13..98e6d8a3 100644 --- a/src/network/res_msend.c +++ b/src/network/res_msend.c @@ -16,7 +16,9 @@ static void cleanup(void *p) { - __syscall(SYS_close, (intptr_t)p); + struct pollfd *pfd = p; + for (int i=0; pfd[i].fd >= -1; i++) + if (pfd[i].fd >= 0) __syscall(SYS_close, pfd[i].fd); } static unsigned long mtime() @@ -44,7 +46,7 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, int next; int i, j; int cs; - struct pollfd pfd; + struct pollfd pfd[nqueries+2]; unsigned long t0, t1, t2; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); @@ -92,7 +94,12 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries, * yield either no reply (indicated by zero length) or an answer * packet which is up to the caller to interpret. */ - pthread_cleanup_push(cleanup, (void *)(intptr_t)fd); + for (i=0; i= 0) { -- 2.21.0