@@ -1022,7 +1022,7 @@ pub const Loop = struct {
|
||||
|
||||
/// Performs an async `os.pwrite` using a separate thread.
|
||||
/// `fd` must block and not return EAGAIN.
|
||||
pub fn pwrite(self: *Loop, fd: os.fd_t, bytes: []const u8, offset: u64, simulate_evented: bool) os.PWriteError!usize {
|
||||
pub fn pwrite(self: *Loop, fd: os.fd_t, bytes: []const u8, offset: u64, simulate_evented: bool) os.PerformsWriteError!usize {
|
||||
if (simulate_evented) {
|
||||
var req_node = Request.Node{
|
||||
.data = .{
|
||||
@@ -1056,24 +1056,36 @@ pub const Loop = struct {
|
||||
|
||||
/// Performs an async `os.pwritev` using a separate thread.
|
||||
/// `fd` must block and not return EAGAIN.
|
||||
pub fn pwritev(self: *Loop, fd: os.fd_t, iov: []const os.iovec_const, offset: u64) os.PWriteError!usize {
|
||||
var req_node = Request.Node{
|
||||
.data = .{
|
||||
.msg = .{
|
||||
.pwritev = .{
|
||||
.fd = fd,
|
||||
.iov = iov,
|
||||
.offset = offset,
|
||||
.result = undefined,
|
||||
pub fn pwritev(self: *Loop, fd: os.fd_t, iov: []const os.iovec_const, offset: u64, simulate_evented: bool) os.PWriteError!usize {
|
||||
if (simulate_evented) {
|
||||
var req_node = Request.Node{
|
||||
.data = .{
|
||||
.msg = .{
|
||||
.pwritev = .{
|
||||
.fd = fd,
|
||||
.iov = iov,
|
||||
.offset = offset,
|
||||
.result = undefined,
|
||||
},
|
||||
},
|
||||
.finish = .{ .TickNode = .{ .data = @frame() } },
|
||||
},
|
||||
.finish = .{ .TickNode = .{ .data = @frame() } },
|
||||
},
|
||||
};
|
||||
suspend {
|
||||
self.posixFsRequest(&req_node);
|
||||
};
|
||||
suspend {
|
||||
self.posixFsRequest(&req_node);
|
||||
}
|
||||
return req_node.data.msg.pwritev.result;
|
||||
} else {
|
||||
while (true) {
|
||||
return os.pwritev(fd, iov, offset) catch |err| switch (err) {
|
||||
error.WouldBlock => {
|
||||
self.waitUntilFdWritable(fd);
|
||||
continue;
|
||||
},
|
||||
else => return err,
|
||||
};
|
||||
}
|
||||
}
|
||||
return req_node.data.msg.pwritev.result;
|
||||
}
|
||||
|
||||
/// Performs an async `os.faccessatZ` using a separate thread.
|
||||
|
||||
@@ -621,10 +621,12 @@ pub const File = struct {
|
||||
if (iovecs.len == 0) return @as(usize, 0);
|
||||
const first = iovecs[0];
|
||||
return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset, self.intended_io_mode);
|
||||
} else if (self.capable_io_mode != self.intended_io_mode) {
|
||||
return std.event.Loop.instance.?.pwritev(self.handle, iovecs, offset);
|
||||
} else {
|
||||
}
|
||||
|
||||
if (self.intended_io_mode == .blocking) {
|
||||
return os.pwritev(self.handle, iovecs, offset);
|
||||
} else {
|
||||
return std.event.Loop.instance.?.pwritev(self.handle, iovecs, offset, self.capable_io_mode != self.intended_io_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -958,12 +958,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
|
||||
EINTR => continue,
|
||||
EINVAL => unreachable,
|
||||
EFAULT => unreachable,
|
||||
EAGAIN => if (std.event.Loop.instance) |loop| {
|
||||
loop.waitUntilFdWritable(fd);
|
||||
continue;
|
||||
} else {
|
||||
return error.WouldBlock;
|
||||
},
|
||||
EAGAIN => return error.WouldBlock,
|
||||
EBADF => return error.NotOpenForWriting, // Can be a race condition.
|
||||
EDESTADDRREQ => unreachable, // `connect` was never called.
|
||||
EDQUOT => return error.DiskQuota,
|
||||
|
||||
Reference in New Issue
Block a user