Skip to content

Commit

Permalink
Close fd with blocking syscall if ring is full
Browse files Browse the repository at this point in the history
If the submission queue is full when we want to close an AsyncFd, we now
fallback to closing the fd using a blocking close(2) call.
  • Loading branch information
Thomasdezeeuw committed Jul 27, 2024
1 parent 39cf63b commit 42565a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd};
use std::{fmt, io};

use crate::op::{op_future, Submission};
use crate::{libc, SubmissionQueue};
use crate::SubmissionQueue;
use crate::libc::{self, syscall};

/// An open file descriptor.
///
Expand Down Expand Up @@ -188,7 +189,10 @@ impl<D: Descriptor> Drop for AsyncFd<D> {
D::use_flags(submission);
});
if let Err(err) = result {
log::error!("error submitting close operation for a10::AsyncFd: {err}");
log::warn!("error submitting close operation for a10::AsyncFd: {err}");
if let Err(err) = syscall!(close(self.fd())) {
log::warn!("error closing a10::AsyncFd: {err}");
}
}
}
}
Expand Down

0 comments on commit 42565a3

Please sign in to comment.