Make url_read_complete retry on EAGAIN and return how much data it read

if it reached EOF, making it useful in more cases.

Originally committed as revision 21393 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger 2010-01-23 10:23:47 +00:00
parent 98287358e9
commit ddb901b74d
2 changed files with 12 additions and 2 deletions

View file

@ -156,8 +156,10 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size)
len = 0;
while (len < size) {
ret = url_read(h, buf+len, size-len);
if (ret < 1)
return ret;
if (ret == AVERROR(EAGAIN)) {
ret = 0;
} else if (ret < 1)
return ret < 0 ? ret : len;
len += ret;
}
return len;