-
Notifications
You must be signed in to change notification settings - Fork 230
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
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2df7e2c
try fix echo_server
loongs-zhang 860268e
try fix echo_server
loongs-zhang d6ef64d
polish code
loongs-zhang 904bdc1
polish code
loongs-zhang f36e4c1
test WSASend
loongs-zhang 1d5ddc3
pass part CI
loongs-zhang df48149
fix clippy
loongs-zhang 78971c1
fix clippy
loongs-zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}, | ||
}, | ||
}; | ||
|
@@ -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) | ||
} | ||
|
@@ -188,26 +186,24 @@ impl<T: IoVecBufMut> OpAble for ReadVec<T> { | |
|
||
#[cfg(all(any(feature = "legacy", feature = "poll-io"), windows))] | ||
fn legacy_call(&mut self) -> io::Result<u32> { | ||
let mut bytes_recved = 0; | ||
let mut bytes_received = 0; | ||
let ret = unsafe { | ||
WSARecv( | ||
self.fd.raw_socket() as _, | ||
self.buf_vec.write_wsabuf_ptr(), | ||
self.buf_vec.write_wsabuf_len() as _, | ||
&mut bytes_recved, | ||
std::ptr::null_mut(), | ||
self.buf_vec.write_wsabuf_len().min(u32::MAX as usize) as _, | ||
&mut bytes_received, | ||
&mut 0, | ||
std::ptr::null_mut(), | ||
None, | ||
) | ||
}; | ||
match ret { | ||
0 => return Err(std::io::ErrorKind::WouldBlock.into()), | ||
SOCKET_ERROR => { | ||
0 => Ok(bytes_received), | ||
_ => { | ||
let error = unsafe { WSAGetLastError() }; | ||
return Err(std::io::Error::from_raw_os_error(error)); | ||
Err(io::Error::from_raw_os_error(error)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
_ => (), | ||
} | ||
Ok(bytes_recved) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lpFlags here is used as both in and out. So it has to be able to read and write.
Have you tried to implement it like rust std? In std impl, it declare 2 temp variable nread and flags, and then pass the mut references.
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/windows/net.rs#L253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is equivalent.

Still blocked in
monoio/tests/tcp_echo.rs:45