Skip to content

Commit 4098cdb

Browse files
fix(driver): unify buffer pool error to ResourceBusy across backends (compio-rs#961)
1 parent aa6cc46 commit 4098cdb

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

compio-driver/src/sys/buffer_pool/fallback.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ impl BufControl {
2222
}
2323

2424
pub fn pop(&mut self) -> io::Result<u16> {
25-
self.queue
26-
.pop_front()
27-
.ok_or_else(|| io::Error::other("buffer ring has no available buffer"))
25+
self.queue.pop_front().ok_or_else(|| {
26+
io::Error::new(
27+
io::ErrorKind::ResourceBusy,
28+
"buffer ring has no available buffer",
29+
)
30+
})
2831
}
2932

3033
pub unsafe fn reset(&mut self, buffer_id: u16, _: BufPtr, _: u32) {

compio-driver/src/sys/driver/iour/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,15 @@ fn create_entry(cq_entry: CEntry) -> Entry {
462462

463463
fn create_result(result: i32) -> io::Result<usize> {
464464
if result < 0 {
465-
Err(io::Error::from_raw_os_error(-result))
465+
// ENOBUFS indicates the io_uring buffer pool has no available buffer.
466+
if -result == libc::ENOBUFS {
467+
Err(io::Error::new(
468+
io::ErrorKind::ResourceBusy,
469+
"buffer ring has no available buffer",
470+
))
471+
} else {
472+
Err(io::Error::from_raw_os_error(-result))
473+
}
466474
} else {
467475
Ok(result as _)
468476
}

0 commit comments

Comments
 (0)