Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass part echo CI in windows #248

Merged
merged 8 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions monoio/src/driver/op/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
std::ffi::c_void,
windows_sys::Win32::{
Foundation::TRUE,
Networking::WinSock::{WSAGetLastError, WSARecv, SOCKET_ERROR},
Networking::WinSock::{WSAGetLastError, WSARecv},
Storage::FileSystem::{ReadFile, SetFilePointer, FILE_CURRENT, INVALID_SET_FILE_POINTER},
},
};
Expand Down Expand Up @@ -155,9 +155,7 @@ impl<T: IoVecBufMut> Op<ReadVec<T>> {

if let Ok(n) = res {
// Safety: the kernel wrote `n` bytes to the buffer.
unsafe {
buf_vec.set_init(n);
}
unsafe { buf_vec.set_init(n) };
}
(res, buf_vec)
}
Expand Down Expand Up @@ -193,21 +191,19 @@ impl<T: IoVecBufMut> OpAble for ReadVec<T> {
WSARecv(
self.fd.raw_socket() as _,
self.buf_vec.write_wsabuf_ptr(),
self.buf_vec.write_wsabuf_len() as _,
self.buf_vec.write_wsabuf_len().min(u32::MAX as usize) as _,
&mut bytes_recved,
std::ptr::null_mut(),
std::ptr::null_mut(),
None,
)
};
match ret {
0 => return Err(std::io::ErrorKind::WouldBlock.into()),
SOCKET_ERROR => {
0 => Ok(bytes_recved),
_ => {
let error = unsafe { WSAGetLastError() };
return Err(std::io::Error::from_raw_os_error(error));
Err(io::Error::from_raw_os_error(error))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails in here, got a WSAEFAULT, but I think there should be no problem with the pointers. Could you please provide some help? @ihciah

}
_ => (),
}
Ok(bytes_recved)
}
}
10 changes: 4 additions & 6 deletions monoio/src/driver/op/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use io_uring::{opcode, types};
#[cfg(all(windows, any(feature = "legacy", feature = "poll-io")))]
use windows_sys::Win32::{
Foundation::TRUE,
Networking::WinSock::{WSAGetLastError, WSASend, SOCKET_ERROR},
Networking::WinSock::{WSAGetLastError, WSASend},
Storage::FileSystem::{SetFilePointer, WriteFile, FILE_CURRENT, INVALID_SET_FILE_POINTER},
};
#[cfg(all(unix, any(feature = "legacy", feature = "poll-io")))]
Expand Down Expand Up @@ -188,13 +188,11 @@ impl<T: IoVecBuf> OpAble for WriteVec<T> {
)
};
match ret {
0 => return Err(std::io::ErrorKind::WouldBlock.into()),
SOCKET_ERROR => {
0 => Ok(bytes_sent),
_ => {
let error = unsafe { WSAGetLastError() };
return Err(std::io::Error::from_raw_os_error(error));
Err(io::Error::from_raw_os_error(error))
}
_ => (),
}
Ok(bytes_sent)
}
}
2 changes: 0 additions & 2 deletions monoio/tests/tcp_echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use monoio::{
net::{TcpListener, TcpStream},
};

// todo fix these CI in windows
#[cfg(not(windows))]
#[monoio::test_all]
async fn echo_server() {
const ITER: usize = 1024;
Expand Down
Loading