]> git.sesse.net Git - ffmpeg/commitdiff
tcp: properly return EOF
authorwm4 <nfxjfg@googlemail.com>
Sat, 30 Dec 2017 16:44:03 +0000 (17:44 +0100)
committerwm4 <nfxjfg@googlemail.com>
Sun, 31 Dec 2017 15:14:23 +0000 (16:14 +0100)
There is no POSIX error code for EOF - recv() signals EOF by simply
returning 0. But libavformat recently changed its conventions and
requires an explicit AVERROR_EOF, or it might get into an endless retry
loop, consuming 100% CPU while doing nothing.

libavformat/tcp.c

index fef0729da683bdd29ade1e656346be26ec355f20..8773493df1efebac33cff5d203c8c9ff17299d4b 100644 (file)
@@ -225,6 +225,8 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
             return ret;
     }
     ret = recv(s->fd, buf, size, 0);
+    if (ret == 0)
+        return AVERROR_EOF;
     return ret < 0 ? ff_neterrno() : ret;
 }