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

Foolproof the SSDPReceiver timeout mechanism #27

Merged
merged 3 commits into from
Jul 12, 2016
Merged

Conversation

ebarnard
Copy link
Contributor

On OS X it is possible to have addresses that cannot receive packets but can send them so set a socket read timeout just to be safe.

I noticed this on tun devices with ipv6 link-local addresses. Previously the receive_packets would never time out.

ebarnard added 2 commits July 10, 2016 13:29
On OS X it is possible to have addresses that cannot receive packets but can send them so set a socket read timeout just to be safe.
@GGist
Copy link
Owner

GGist commented Jul 10, 2016

Ah yes. It seems that this would also fix the issue of having UdpSockets bound to 0.0.0.0 not being woken up when sending to their local_addr() to see that the kill flag has been set.

For the AppVeyor build, it looks like rustc 1.12.0 broke something with the Windows build using unstable features. I am going to install the latest nightly and see about fixing that before testing these changes and merging.

@@ -195,6 +200,11 @@ fn receive_packets<T>(recv: PacketReceiver, kill: Arc<AtomicBool>, send: Sender<
trace!("Waiting on packet at {}...", recv);
let (msg_bytes, addr) = match recv.recv_pckt() {
Ok((bytes, addr)) => (bytes, addr),
Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {
Copy link
Owner

Choose a reason for hiding this comment

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

While testing on Windows I found that timeouts do not return WouldBlock but instead TimedOut. Is this behavior consistent on Mac OS as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OS X and Linux return WouldBlock (see: https://is.gd/TFOY1G). There should probably be a rust issue for this.

I suppose for the moment the check should be for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GGist
Copy link
Owner

GGist commented Jul 12, 2016

Ah yes, I didn't think to check the docs first; I think their decision in the linked issue seems reasonable.

Anyway, all is looking good, thanks for the pull request!

Cheers!

@GGist GGist merged commit 66f7c29 into GGist:master Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants