From b1b15e42c398297853101f3759c734971ba09ced Mon Sep 17 00:00:00 2001 From: Brad House Date: Thu, 18 Jul 2024 21:35:06 -0400 Subject: [PATCH] Event Select: need to monitor for socket exceptions too --- src/lib/ares_event_select.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/ares_event_select.c b/src/lib/ares_event_select.c index 4823e808..ec49ea3e 100644 --- a/src/lib/ares_event_select.c +++ b/src/lib/ares_event_select.c @@ -77,12 +77,14 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e, size_t i; fd_set read_fds; fd_set write_fds; + fd_set except_fds; int nfds = 0; struct timeval tv; struct timeval *tout = NULL; FD_ZERO(&read_fds); FD_ZERO(&write_fds); + FD_ZERO(&except_fds); for (i = 0; i < num_fds; i++) { const ares_event_t *ev = @@ -93,6 +95,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e, if (ev->flags & ARES_EVENT_FLAG_WRITE) { FD_SET(ev->fd, &write_fds); } + FD_SET(ev->fd, &except_fds); if (ev->fd + 1 > nfds) { nfds = ev->fd + 1; } @@ -104,7 +107,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e, tout = &tv; } - rv = select(nfds, &read_fds, &write_fds, NULL, tout); + rv = select(nfds, &read_fds, &write_fds, &except_fds, tout); if (rv > 0) { for (i = 0; i < num_fds; i++) { ares_event_t *ev; @@ -115,7 +118,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e, continue; } - if (FD_ISSET(fdlist[i], &read_fds)) { + if (FD_ISSET(fdlist[i], &read_fds) || FD_ISSET(fdlist[i], &except_fds)) { flags |= ARES_EVENT_FLAG_READ; }