mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
Update PipeReader.zig
This commit is contained in:
@@ -27,8 +27,10 @@ pub fn PosixPipeReader(
|
||||
const buffer = @call(.always_inline, vtable.getBuffer, .{this});
|
||||
const fd = @call(.always_inline, vtable.getFd, .{this});
|
||||
if (comptime bun.Environment.isLinux) {
|
||||
readFromBlockingPipeWithoutBlockingLinux(this, buffer, fd, 0);
|
||||
return;
|
||||
if (bun.C.linux.RWFFlagSupport.isMaybeSupported()) {
|
||||
readFromBlockingPipeWithoutBlockingLinux(this, buffer, fd, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (bun.isReadable(fd)) {
|
||||
@@ -61,11 +63,6 @@ pub fn PosixPipeReader(
|
||||
}
|
||||
}
|
||||
|
||||
const readFromBlockingPipeWithoutBlocking = if (bun.Environment.isLinux)
|
||||
readFromBlockingPipeWithoutBlockingLinux
|
||||
else
|
||||
readFromBlockingPipeWithoutBlockingPOSIX;
|
||||
|
||||
// On Linux, we use preadv2 to read without blocking.
|
||||
fn readFromBlockingPipeWithoutBlockingLinux(parent: *This, resizable_buffer: *std.ArrayList(u8), fd: bun.FileDescriptor, size_hint: isize) void {
|
||||
if (size_hint > stack_buffer_len) {
|
||||
@@ -120,6 +117,17 @@ pub fn PosixPipeReader(
|
||||
}
|
||||
}
|
||||
|
||||
fn readFromBlockingPipeWithoutBlocking(parent: *This, resizable_buffer: *std.ArrayList(u8), fd: bun.FileDescriptor, size_hint: isize) void {
|
||||
if (comptime bun.Environment.isLinux) {
|
||||
if (bun.C.linux.RWFFlagSupport.isMaybeSupported()) {
|
||||
readFromBlockingPipeWithoutBlockingLinux(parent, resizable_buffer, fd, size_hint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
readFromBlockingPipeWithoutBlockingPOSIX(parent, resizable_buffer, fd, size_hint);
|
||||
}
|
||||
|
||||
fn readFromBlockingPipeWithoutBlockingPOSIX(parent: *This, resizable_buffer: *std.ArrayList(u8), fd: bun.FileDescriptor, size_hint: isize) void {
|
||||
if (size_hint > stack_buffer_len) {
|
||||
resizable_buffer.ensureUnusedCapacity(@intCast(size_hint)) catch bun.outOfMemory();
|
||||
|
||||
Reference in New Issue
Block a user