From 4a09bd9e86fad30df5ba61d1ba885ab9880a0f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Fri, 7 Aug 2009 16:52:03 +0200 Subject: [PATCH] Fixed handling of fd_read() failing with EINTR in gimme_some_data(). Rev: src/modules/Pipe/pipe.c:1.67 --- src/modules/Pipe/pipe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/Pipe/pipe.c b/src/modules/Pipe/pipe.c index 05f2740f89..c9df830d19 100644 --- a/src/modules/Pipe/pipe.c +++ b/src/modules/Pipe/pipe.c @@ -484,17 +484,17 @@ static INLINE struct pike_string* gimme_some_data(size_t pos) /* We have a file cache, read from it */ if (this->fd!=-1) { - char buffer[READ_BUFFER_SIZE]; + char buffer[READ_BUFFER_SIZE]; + ptrdiff_t sz = this->pos-pos; - if (this->pos<=pos) return NULL; /* no data */ - len=this->pos-pos; - if (len>READ_BUFFER_SIZE) len=READ_BUFFER_SIZE; + if (sz <= 0) return NULL; /* no data */ + if (sz > READ_BUFFER_SIZE) sz = READ_BUFFER_SIZE; THREADS_ALLOW(); fd_lseek(this->fd, pos, SEEK_SET); THREADS_DISALLOW(); do { THREADS_ALLOW(); - len = fd_read(this->fd, buffer, len); + len = fd_read(this->fd, buffer, sz); THREADS_DISALLOW(); if (len < 0) { if (errno != EINTR) { -- GitLab