[MPlayer-cvslog] r32954 - trunk/stream/stream.c

reimar subversion at mplayerhq.hu
Tue Feb 22 23:27:02 CET 2011


Author: reimar
Date: Tue Feb 22 23:27:01 2011
New Revision: 32954

Log:
When reading from a stream fails, try one more time after a reset.
This should re-establish for example timed-out network connections.
Fixes bug #1841.

Modified:
   trunk/stream/stream.c

Modified: trunk/stream/stream.c
==============================================================================
--- trunk/stream/stream.c	Tue Feb 22 19:58:50 2011	(r32953)
+++ trunk/stream/stream.c	Tue Feb 22 23:27:01 2011	(r32954)
@@ -304,7 +304,19 @@ int stream_read_internal(stream_t *s, vo
   default:
     len= s->fill_buffer ? s->fill_buffer(s, buf, len) : 0;
   }
-  if(len<=0){ s->eof=1; return 0; }
+  if(len<=0){
+    if (!s->eof) {
+      // just in case this is an error e.g. due to network
+      // timeout reset and retry
+      off_t pos = s->pos;
+      stream_reset(s);
+      stream_seek_internal(s, pos);
+      s->eof=1;
+      return stream_read_internal(s, buf, len);
+    }
+    s->eof=1;
+    return 0;
+  }
   // When reading succeeded we are obviously not at eof.
   // This e.g. avoids issues with eof getting stuck when lavf seeks in MPEG-TS
   s->eof=0;


More information about the MPlayer-cvslog mailing list