diff options
author | 2022-10-11 00:07:13 -0700 | |
---|---|---|
committer | 2022-10-11 00:07:13 -0700 | |
commit | 614d256cb68b718f69d9f54cfb82d61f8d0eb547 (patch) | |
tree | 367b7d5a4d719bc4fc7b9b76df2684624dcd341d | |
parent | 3867431ed18966c88eeadfb238a0535893f0f6d3 (diff) | |
download | bun-614d256cb68b718f69d9f54cfb82d61f8d0eb547.tar.gz bun-614d256cb68b718f69d9f54cfb82d61f8d0eb547.tar.zst bun-614d256cb68b718f69d9f54cfb82d61f8d0eb547.zip |
Use poll() to check if writable
Diffstat (limited to '')
-rw-r--r-- | src/bun.js/webcore/streams.zig | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 79a0339aa..61a232b5c 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -1153,16 +1153,26 @@ pub const FileSink = struct { // we flushed an entire fifo // but we still have more - // lets wait for the next poll + // lets check if its writable, so we avoid blocking if (std.os.S.ISFIFO(this.mode) and max_to_write == max_fifo_size and res.result == max_fifo_size and remain.len > 0) { - this.watch(this.fd); - return .{ - .pending = &this.pending, + var polls = [_]std.os.pollfd{ + .{ + .fd = fd, + .events = std.os.POLL.IN | std.os.POLL.ERR, + .revents = 0, + }, }; + + if ((std.os.poll(&polls, 0) catch 0) == 0) { + this.watch(this.fd); + return .{ + .pending = &this.pending, + }; + } } } |