Skip to content

Commit

Permalink
vhost: only emit debug log with 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 more valid, 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]>
  • Loading branch information
mcoquelin authored and david-marchand committed Jun 25, 2024
1 parent 4a44d97 commit b2c7aed
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 b2c7aed

Please sign in to comment.