From 0d5e6084aed34a9e6f48a4a2cfaf095b17acb21b Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Jun 2013 20:40:02 +0200 Subject: stream: don't set EOF flag in stream implementations EOF should be set when reading more data fails. The stream implementations have nothing to say here and should behave correctly when trying to read when EOF was actually read. Even when seeking, a correct EOF flag should be guaranteed. stream_seek() (or actually stream_seek_long()) calls stream_fill_buffer() at least once, which also updates the EOF flag. --- stream/stream_file.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index 8b587e6048..5797aef59f 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -55,8 +55,6 @@ static const struct m_struct_st stream_opts = { static int fill_buffer(stream_t *s, char* buffer, int max_len){ int r = read(s->fd,buffer,max_len); - // We are certain this is EOF, do not retry - if (max_len && r == 0) s->eof = 1; return (r <= 0) ? -1 : r; } @@ -76,7 +74,6 @@ static int write_buffer(stream_t *s, char* buffer, int len) { static int seek(stream_t *s,int64_t newpos) { s->pos = newpos; if(lseek(s->fd,s->pos,SEEK_SET)<0) { - s->eof=1; return 0; } return 1; @@ -89,7 +86,7 @@ static int seek_forward(stream_t *s,int64_t newpos) { } while(s->posfill_buffer(s,s->buffer,STREAM_BUFFER_SIZE); - if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; break; } // EOF + if(len<=0){ s->buf_pos=s->buf_len=0; break; } // EOF s->buf_pos=0; s->buf_len=len; s->pos+=len; -- cgit v1.2.3