# HG changeset patch # User reimar # Date 1309807319 0 # Node ID 1bb847d89fd51cd5c6c16ce2d00b1e87e103a8fd # Parent 0cb1d3b6539d981fe937d93509f854281080ab67 Improve checks for when to try reconnecting to be more thorough and readable. diff -r 0cb1d3b6539d -r 1bb847d89fd5 stream/stream.c --- a/stream/stream.c Mon Jul 04 19:14:06 2011 +0000 +++ b/stream/stream.c Mon Jul 04 19:21:59 2011 +0000 @@ -308,22 +308,27 @@ len= s->fill_buffer ? s->fill_buffer(s, buf, len) : 0; } if(len<=0){ + off_t pos = s->pos; + // do not retry if this looks like proper eof + if (s->eof || (s->end_pos && pos == s->end_pos)) + goto eof_out; // dvdnav has some horrible hacks to "suspend" reads, // we need to skip this code or seeks will hang. - if (!s->eof && s->type != STREAMTYPE_DVDNAV) { + if (s->type == STREAMTYPE_DVDNAV) + goto eof_out; // just in case this is an error e.g. due to network // timeout reset and retry // Seeking is used as a hack to make network streams // reopen the connection, ideally they would implement // e.g. a STREAM_CTRL_RECONNECT to do this - off_t pos = s->pos; s->eof=1; stream_reset(s); - stream_seek_internal(s, pos); + if (stream_seek_internal(s, pos) >= 0 || s->pos != pos) // seek failed + goto eof_out; // make sure EOF is set to ensure no endless loops s->eof=1; return stream_read_internal(s, buf, orig_len); - } +eof_out: s->eof=1; return 0; }