std::rt: Ignore 0-byte udp reads

This commit is contained in:
Brian Anderson 2013-07-09 16:54:48 -07:00
parent 6fb92f8cab
commit 413d51e32d
1 changed files with 7 additions and 0 deletions

View File

@ -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);