-
Notifications
You must be signed in to change notification settings - Fork 125
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
Try recv timeout #284
Try recv timeout #284
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
This failure seems unrelated to my change https://ci.appveyor.com/project/servo/ipc-channel/builds/41572812/job/iqg5fi9asp0exnec#L15 |
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.
This looks great! Thank you!
src/platform/windows/mod.rs
Outdated
let mut overlapped: winapi::um::minwinbase::OVERLAPPED = mem::zeroed(); | ||
// Create a manually reset event. The documentation for GetOverlappedResultEx | ||
// states you must do this in the remarks section. | ||
overlapped.hEvent = CreateEventA(ptr::null_mut(), winapi::shared::minwindef::TRUE, winapi::shared::minwindef::FALSE, ptr::null_mut()); |
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.
nit: Let's import winapi::shared::minwindef::TRUE
and winapi::shared::minwindef::FALSE
to make this easier to read.
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.
Resolved in bec4ef6
src/platform/unix/mod.rs
Outdated
}, | ||
BlockingMode::Timeout(duration) => { | ||
let events = libc::POLLIN | libc::POLLPRI | libc::POLLRDHUP; | ||
let fd = &mut [libc::pollfd {fd, events, revents: 0}]; |
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.
Let's write this as let mut fd = [...]
instead. I find that easier to reason about.
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.
Resolved in da99fca
@@ -612,7 +612,8 @@ impl OsIpcOneShotServer { | |||
let socket_path = temp_dir.path().join("socket"); | |||
let path_string = socket_path.to_str().unwrap(); | |||
|
|||
let (sockaddr, len) = new_sockaddr_un(CString::new(path_string).unwrap().as_ptr()); | |||
let path_c_string = CString::new(path_string).unwrap(); | |||
let (sockaddr, len) = new_sockaddr_un(path_c_string.as_ptr()); |
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.
Oh! Thank you for finding and fixing this.
@bors-servo r+ |
📌 Commit da99fca has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
There are currently two prominent ways to receive messages on the ipc channel, you can either block indefinitely, or not at all. For my use case, I'd like to have the lower CPU usage that comes with blocking, but also be able to exit the call periodically so my thread can check if it needs to exit. So I've added the
try_recv_timeout
method, and implemented it for all supported platforms. This method uses the platform facilities to block a recv call, but only for a set duration, at which point it will returnTryRecvError::Empty
if nothing came back.