From 684c4eeb02854be85b2d82ac1fbb50bcd234716e Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 20 Feb 2022 17:38:37 +0100 Subject: [PATCH] Avoid printing spurious ENOENT error from EPOLL_CTL_DEL In openconnect_close_https() we always unmonitor the ssl_fd even if we are still in the auth phase and hadn't actually monitored it yet. I think I'd like to keep track of that better, with a flag to explicitly keep track of whether a given fd is registered. Or maybe abusing a high bit of the existing vpninfo->XXX_epoll variables that already keep state. For the imminent release though, let's take the simple approach and just ignore the harmless error. Not pretty, but safer. Signed-off-by: David Woodhouse --- openconnect-internal.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openconnect-internal.h b/openconnect-internal.h index b3fd398d..5db87638 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -930,10 +930,14 @@ static inline void __remove_epoll_fd(struct openconnect_info *vpninfo, int fd) { struct epoll_event ev = { 0 }; if (vpninfo->epoll_fd >= 0 && - epoll_ctl(vpninfo->epoll_fd, EPOLL_CTL_DEL, fd, &ev) < 0) + epoll_ctl(vpninfo->epoll_fd, EPOLL_CTL_DEL, fd, &ev) < 0 && + errno != ENOENT) vpn_perror(vpninfo, "EPOLL_CTL_DEL"); - /* No other action on error; if it truly matters we'll bail - * later and fall back to select() */ + /* No other action on error; if it truly matters we'll bail later + * and fall back to select(). We also explicitly ignore ENOENT + * because openconnect_close_https() will always unmonitor the + * ssl_fd even when we never got to the point of using it in the + * main loop and actually monitoring it. */ } #define __unmonitor_fd(_v, _n) do { \ -- 2.50.1