]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tcp: handle ERRNO_AGAIN in tcp_fill_htsbuf_from_fd (2nd)
authorJaroslav Kysela <perex@perex.cz>
Fri, 17 Feb 2017 10:44:59 +0000 (11:44 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 17 Feb 2017 10:44:59 +0000 (11:44 +0100)
src/tcp.c

index 56c34055e47ffca1b64ec7ba4118dcaabb634cb4..18e71740805ddc9cf09c5e18ee879281265e3af6 100644 (file)
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -255,16 +255,18 @@ tcp_fill_htsbuf_from_fd(int fd, htsbuf_queue_t *hq)
   hd->hd_data_size = 1000;
   hd->hd_data = malloc(hd->hd_data_size);
 
-  c = read(fd, hd->hd_data, hd->hd_data_size);
-  if(c < 1) {
+  do {
+    r = read(fd, hd->hd_data, hd->hd_data_size);
+  } while (r < 0 && ERRNO_AGAIN(errno));
+  if(r < 1) {
     free(hd->hd_data);
     free(hd);
     return -1;
   }
-  hd->hd_data_len = c;
+  hd->hd_data_len = r;
   hd->hd_data_off = 0;
   TAILQ_INSERT_TAIL(&hq->hq_q, hd, hd_link);
-  hq->hq_size += c;
+  hq->hq_size += r;
   return 0;
 }