Blob Blame History Raw
From b6ae2adabfef64ace22698f76afae454a6419492 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 18 Feb 2020 21:16:38 +0100
Subject: [PATCH 4/7] event-loop: Fix debug-log "failed to delete fd # from
 epoll watch list" spam

The boot server uses a disconnect handler which closes the fd, this
causes deleting the fd from the epoll watch list to fail with an EBADF
error. Since the fd was closed it was already removed from the epoll
watch list, so the failure is harmless, silence these errors getting logged
to the debug logs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/libply/ply-event-loop.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c
index 0e8ad7c..5eb601c 100644
--- a/src/libply/ply-event-loop.c
+++ b/src/libply/ply-event-loop.c
@@ -641,7 +641,11 @@ ply_event_loop_remove_source_node (ply_event_loop_t *loop,
 
                 status = epoll_ctl (loop->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
 
-                if (status < 0)
+                /*
+                 * EBADF means that there was a disconnect handler, which has
+                 * closed the fd, which is fine, do not log an error for this.
+                 */
+                if (status < 0 && errno != EBADF)
                         ply_trace ("failed to delete fd %d from epoll watch list: %m", source->fd);
                 source->is_getting_polled = false;
         }
-- 
2.25.1