From cd57606202358acf72e47e54458c372030175c77 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Mon, 18 Apr 2005 19:49:40 +0000 Subject: check the result of poll() before read()ing; 100l git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15214 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/dvbin.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libmpdemux') diff --git a/libmpdemux/dvbin.c b/libmpdemux/dvbin.c index 679370adff..5531b6098a 100644 --- a/libmpdemux/dvbin.c +++ b/libmpdemux/dvbin.c @@ -404,14 +404,8 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size) pfds[0].fd = fd; pfds[0].events = POLLIN | POLLPRI; - poll(pfds, 1, 500); rk = size - pos; - if((rk = read(fd, &buffer[pos], rk)) > 0) - { - pos += rk; - mp_msg(MSGT_DEMUX, MSGL_DBG3, "ret (%d) bytes\n", pos); - } - else + if(poll(pfds, 1, 500) <= 0) { errno = 0; mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, attempt N. %d failed with errno %d when reading %d bytes\n", tries, errno, size-pos); @@ -419,8 +413,14 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size) continue; else break; - } } + if((rk = read(fd, &buffer[pos], rk)) > 0) + { + pos += rk; + mp_msg(MSGT_DEMUX, MSGL_DBG3, "ret (%d) bytes\n", pos); + } + } + if(! pos) mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_streaming_read, return %d bytes\n", pos); -- cgit v1.2.3