aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-11 00:07:13 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-11 00:07:13 -0700
commit614d256cb68b718f69d9f54cfb82d61f8d0eb547 (patch)
tree367b7d5a4d719bc4fc7b9b76df2684624dcd341d
parent3867431ed18966c88eeadfb238a0535893f0f6d3 (diff)
downloadbun-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.zig18
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,
+ };
+ }
}
}