parent
419aea54cb
commit
c196c27af8
|
@ -1109,6 +1109,24 @@ pub const Loop = struct {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn recvfrom(
|
||||
sockfd: os.fd_t,
|
||||
buf: []u8,
|
||||
flags: u32,
|
||||
src_addr: ?*os.sockaddr,
|
||||
addrlen: ?*os.socklen_t,
|
||||
) os.RecvFromError!usize {
|
||||
while (true) {
|
||||
return os.recvfrom(sockfd, buf, flags, src_addr, addrlen) catch |err| switch (err) {
|
||||
error.WouldBlock => {
|
||||
self.waitUntilFdReadable(sockfd);
|
||||
continue;
|
||||
},
|
||||
else => return err,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Performs an async `os.faccessatZ` using a separate thread.
|
||||
/// `fd` must block and not return EAGAIN.
|
||||
pub fn faccessatZ(
|
||||
|
|
|
@ -1454,7 +1454,10 @@ fn resMSendRc(
|
|||
|
||||
while (true) {
|
||||
var sl_copy = sl;
|
||||
const rlen = os.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break;
|
||||
const rlen = if (std.io.is_async)
|
||||
std.event.Loop.instance.?.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break
|
||||
else
|
||||
os.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break;
|
||||
|
||||
// Ignore non-identifiable packets
|
||||
if (rlen < 4) continue;
|
||||
|
|
|
@ -5068,12 +5068,7 @@ pub fn recvfrom(
|
|||
ENOTCONN => unreachable,
|
||||
ENOTSOCK => unreachable,
|
||||
EINTR => continue,
|
||||
EAGAIN => if (std.event.Loop.instance) |loop| {
|
||||
loop.waitUntilFdReadable(sockfd);
|
||||
continue;
|
||||
} else {
|
||||
return error.WouldBlock;
|
||||
},
|
||||
EAGAIN => return error.WouldBlock,
|
||||
ENOMEM => return error.SystemResources,
|
||||
ECONNREFUSED => return error.ConnectionRefused,
|
||||
else => |err| return unexpectedErrno(err),
|
||||
|
|
Loading…
Reference in New Issue