[PATCH v2 4/5] stream_pvr: fix bogus error message on device poll timeout

Reza Arbab <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
The error check for the call to poll() should actually be for the
subsequent read(). Move it there.

Add a different check for poll(), to correctly report timeout.

Signed-off-by: Reza Arbab <[email protected]>
---
v2:
 * Fix error checking on read() in addition to poll().

 stream/stream_pvr.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index cbf4f17..4657210 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -1629,9 +1629,15 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
     pfds[0].fd = fd;
     pfds[0].events = POLLIN | POLLPRI;
 
-    rk = size - pos;
+    if (!poll (pfds, 1, 500))
+    {
+      mp_msg (MSGT_OPEN, MSGL_ERR,
+              "%s 500ms timeout polling stream device\n", LOG_LEVEL_PVR);
+      return -1;
+    }
 
-    if (poll (pfds, 1, 500) <= 0)
+    rk = read (fd, &buffer[pos], size-pos);
+    if (rk < 0)
     {
       mp_msg (MSGT_OPEN, MSGL_ERR,
               "%s failed with errno %d when reading %d bytes\n",
@@ -1639,13 +1645,12 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
       break;
     }
 
-    rk = read (fd, &buffer[pos], rk);
-    if (rk > 0)
-    {
-      pos += rk;
-      mp_msg (MSGT_OPEN, MSGL_DBG3,
-              "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
-    }
+    if (!rk)
+      break;
+
+    pos += rk;
+    mp_msg (MSGT_OPEN, MSGL_DBG3,
+            "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
   }
 
   if (!pos)
-- 
2.5.0

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.