Skip to content

Commit

Permalink
vhost: decrease log level for invalid FD
Browse files Browse the repository at this point in the history
This patch improves the FD manager logging in case
of FD removal from the epoll FD set failure.

When the FD is not valid anymore, like for example if it
has already been closed, only emit a debug log and not
an error one.

Fixes: 0e38b42 ("vhost: manage FD with epoll")

Reported-by: David Marchand <[email protected]>
Signed-off-by: Maxime Coquelin <[email protected]>
Reviewed-by: David Marchand <[email protected]>
  • Loading branch information
mcoquelin committed Jul 5, 2024
1 parent 95547dc commit 1e5bf7b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/vhost/fd_man.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)
static void
fdset_del_locked(struct fdset *pfdset, struct fdentry *pfdentry)
{
if (epoll_ctl(pfdset->epfd, EPOLL_CTL_DEL, pfdentry->fd, NULL) == -1)
VHOST_FDMAN_LOG(ERR, "could not remove %d fd from %d epfd: %s",
pfdentry->fd, pfdset->epfd, strerror(errno));
if (epoll_ctl(pfdset->epfd, EPOLL_CTL_DEL, pfdentry->fd, NULL) == -1) {
if (errno == EBADF) /* File might have already been closed. */
VHOST_FDMAN_LOG(DEBUG, "could not remove %d fd from %d epfd: %s",
pfdentry->fd, pfdset->epfd, strerror(errno));
else
VHOST_FDMAN_LOG(ERR, "could not remove %d fd from %d epfd: %s",
pfdentry->fd, pfdset->epfd, strerror(errno));
}

fdset_remove_entry(pfdset, pfdentry);
}
Expand Down

0 comments on commit 1e5bf7b

Please sign in to comment.