From 413d51e32debf0c3f7dda2434b64d73585df21ef Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 9 Jul 2013 16:54:48 -0700 Subject: [PATCH] std::rt: Ignore 0-byte udp reads --- src/libstd/rt/uv/net.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstd/rt/uv/net.rs b/src/libstd/rt/uv/net.rs index b7caba849b7e..6d096f9885a7 100644 --- a/src/libstd/rt/uv/net.rs +++ b/src/libstd/rt/uv/net.rs @@ -392,6 +392,13 @@ impl UdpWatcher { extern fn recv_cb(handle: *uvll::uv_udp_t, nread: ssize_t, buf: Buf, addr: *uvll::sockaddr, flags: c_uint) { + // When there's no data to read the recv callback can be a no-op. + // This can happen if read returns EAGAIN/EWOULDBLOCK. By ignoring + // this we just drop back to kqueue and wait for the next callback. + if nread == 0 { + return; + } + rtdebug!("buf addr: %x", buf.base as uint); rtdebug!("buf len: %d", buf.len as int); let mut udp_watcher: UdpWatcher = NativeHandle::from_native_handle(handle);