tcp: properly return EOF

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.
This commit is contained in:
wm4 2017-12-30 17:44:03 +01:00
parent e45f7bca73
commit 0e1f771d22

View 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;
}