Skip to content

Commit a70d5d7

Browse files
committed
fix(driver): log post error
1 parent c90f23c commit a70d5d7

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

compio-driver/src/iocp/cp/global.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66
time::Duration,
77
};
88

9+
use compio_log::*;
910
#[cfg(not(feature = "once_cell_try"))]
1011
use once_cell::sync::OnceCell as OnceLock;
1112
use windows_sys::Win32::System::IO::PostQueuedCompletionStatus;
@@ -53,21 +54,30 @@ fn iocp_port() -> io::Result<&'static GlobalPort> {
5354
fn iocp_start() -> io::Result<()> {
5455
let port = iocp_port()?;
5556
std::thread::spawn(move || {
57+
instrument!(compio_log::Level::TRACE, "iocp_start");
5658
loop {
5759
for entry in port.port.poll_raw(None)? {
5860
// Any thin pointer is OK because we don't use the type of opcode.
5961
let overlapped_ptr: *mut Overlapped<()> = entry.lpOverlapped.cast();
6062
let overlapped = unsafe { &*overlapped_ptr };
61-
syscall!(
63+
if let Err(e) = syscall!(
6264
BOOL,
6365
PostQueuedCompletionStatus(
6466
overlapped.driver as _,
6567
entry.dwNumberOfBytesTransferred,
6668
entry.lpCompletionKey,
6769
entry.lpOverlapped,
6870
)
69-
)
70-
.ok();
71+
) {
72+
error!(
73+
"fail to dispatch entry ({}, {}, {:p}) to driver {:p}: {:?}",
74+
entry.dwNumberOfBytesTransferred,
75+
entry.lpCompletionKey,
76+
entry.lpOverlapped,
77+
overlapped.driver,
78+
e
79+
);
80+
}
7181
}
7282
}
7383
#[allow(unreachable_code)]

compio-driver/src/iocp/cp/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,24 @@ impl CompletionPort {
143143
if let Some(current_driver) = current_driver {
144144
if overlapped.driver != current_driver {
145145
// Repose the entry to correct port.
146-
syscall!(
146+
if let Err(e) = syscall!(
147147
BOOL,
148148
PostQueuedCompletionStatus(
149149
overlapped.driver as _,
150150
entry.dwNumberOfBytesTransferred,
151151
entry.lpCompletionKey,
152152
entry.lpOverlapped,
153153
)
154-
)
155-
.ok();
154+
) {
155+
error!(
156+
"fail to repost entry ({}, {}, {:p}) to driver {:p}: {:?}",
157+
entry.dwNumberOfBytesTransferred,
158+
entry.lpCompletionKey,
159+
entry.lpOverlapped,
160+
overlapped.driver,
161+
e
162+
);
163+
}
156164
}
157165
}
158166
let res = if matches!(

0 commit comments

Comments
 (0)