diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-03-05 00:21:22 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-03-05 00:21:22 +0100 |
commit | c850aa60f945079f5a486cd9ca2a6ab723f6e094 (patch) | |
tree | db55892a0aebf5820288a972a45f95678c3bb888 | |
parent | bab11d536f278a5856c42b00fa87f8d5b8d29065 (diff) |
libpipe: Do not optimize reading pipe->write_limit
It may have changed while sleeping.
-rw-r--r-- | libpipe/pipe.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libpipe/pipe.h b/libpipe/pipe.h index 1b1ef82f..f724e98b 100644 --- a/libpipe/pipe.h +++ b/libpipe/pipe.h @@ -208,10 +208,9 @@ pipe_select_readable (struct pipe *pipe, struct timespec *tsp, int data_only) PIPE_EI error_t pipe_wait_writable (struct pipe *pipe, int noblock) { - size_t limit = pipe->write_limit; if (pipe->flags & PIPE_BROKEN) return EPIPE; - while (pipe_readable (pipe, 1) >= limit) + while (pipe_readable (pipe, 1) >= pipe->write_limit) { if (noblock) return EWOULDBLOCK; @@ -229,9 +228,9 @@ pipe_wait_writable (struct pipe *pipe, int noblock) PIPE_EI error_t pipe_select_writable (struct pipe *pipe, struct timespec *tsp) { - size_t limit = pipe->write_limit; error_t err = 0; - while (! (pipe->flags & PIPE_BROKEN) && pipe_readable (pipe, 1) >= limit) + while (! (pipe->flags & PIPE_BROKEN) + && pipe_readable (pipe, 1) >= pipe->write_limit) { err = pthread_hurd_cond_timedwait_np (&pipe->pending_writes, &pipe->lock, tsp); |