]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Avoid printing spurious ENOENT error from EPOLL_CTL_DEL
authorDavid Woodhouse <dwmw2@infradead.org>
Sun, 20 Feb 2022 16:38:37 +0000 (17:38 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Sun, 20 Feb 2022 16:38:37 +0000 (17:38 +0100)
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 <dwmw2@infradead.org>
openconnect-internal.h

index b3fd398d213ddd41c49040e79b9f3dede7801cc8..5db87638854d240d663f10ecb55767dc4d859977 100644 (file)
@@ -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 {                \