parent
7fec5b3def
commit
419aea54cb
|
@ -1088,6 +1088,27 @@ pub const Loop = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sendto(
|
||||||
|
self: *Loop,
|
||||||
|
/// The file descriptor of the sending socket.
|
||||||
|
sockfd: os.fd_t,
|
||||||
|
/// Message to send.
|
||||||
|
buf: []const u8,
|
||||||
|
flags: u32,
|
||||||
|
dest_addr: ?*const os.sockaddr,
|
||||||
|
addrlen: os.socklen_t,
|
||||||
|
) os.SendError!usize {
|
||||||
|
while (true) {
|
||||||
|
return os.sendto(sockfd, buf, flags, dest_addr, addrlen) catch |err| switch (err) {
|
||||||
|
error.WouldBlock => {
|
||||||
|
self.waitUntilFdWritable(sockfd);
|
||||||
|
continue;
|
||||||
|
},
|
||||||
|
else => return err,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Performs an async `os.faccessatZ` using a separate thread.
|
/// Performs an async `os.faccessatZ` using a separate thread.
|
||||||
/// `fd` must block and not return EAGAIN.
|
/// `fd` must block and not return EAGAIN.
|
||||||
pub fn faccessatZ(
|
pub fn faccessatZ(
|
||||||
|
|
|
@ -1435,10 +1435,14 @@ fn resMSendRc(
|
||||||
if (answers[i].len == 0) {
|
if (answers[i].len == 0) {
|
||||||
var j: usize = 0;
|
var j: usize = 0;
|
||||||
while (j < ns.len) : (j += 1) {
|
while (j < ns.len) : (j += 1) {
|
||||||
|
if (std.io.is_async) {
|
||||||
|
_ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
||||||
|
} else {
|
||||||
_ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
_ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
servfail_retry = 2 * queries.len;
|
servfail_retry = 2 * queries.len;
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1480,11 @@ fn resMSendRc(
|
||||||
0, 3 => {},
|
0, 3 => {},
|
||||||
2 => if (servfail_retry != 0) {
|
2 => if (servfail_retry != 0) {
|
||||||
servfail_retry -= 1;
|
servfail_retry -= 1;
|
||||||
|
if (std.io.is_async) {
|
||||||
|
_ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
||||||
|
} else {
|
||||||
_ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
_ = os.sendto(fd, queries[i], os.MSG_NOSIGNAL, &ns[j].any, sl) catch undefined;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
else => continue,
|
else => continue,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4571,14 +4571,8 @@ pub fn sendto(
|
||||||
const rc = system.sendto(sockfd, buf.ptr, buf.len, flags, dest_addr, addrlen);
|
const rc = system.sendto(sockfd, buf.ptr, buf.len, flags, dest_addr, addrlen);
|
||||||
switch (errno(rc)) {
|
switch (errno(rc)) {
|
||||||
0 => return @intCast(usize, rc),
|
0 => return @intCast(usize, rc),
|
||||||
|
|
||||||
EACCES => return error.AccessDenied,
|
EACCES => return error.AccessDenied,
|
||||||
EAGAIN => if (std.event.Loop.instance) |loop| {
|
EAGAIN => return error.WouldBlock,
|
||||||
loop.waitUntilFdWritable(sockfd);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
return error.WouldBlock;
|
|
||||||
},
|
|
||||||
EALREADY => return error.FastOpenAlreadyInProgress,
|
EALREADY => return error.FastOpenAlreadyInProgress,
|
||||||
EBADF => unreachable, // always a race condition
|
EBADF => unreachable, // always a race condition
|
||||||
ECONNRESET => return error.ConnectionResetByPeer,
|
ECONNRESET => return error.ConnectionResetByPeer,
|
||||||
|
|
Loading…
Reference in New Issue