From: Jaroslav Kysela Date: Fri, 17 Feb 2017 10:44:59 +0000 (+0100) Subject: tcp: handle ERRNO_AGAIN in tcp_fill_htsbuf_from_fd (2nd) X-Git-Tag: v4.2.1~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=559ec46c9614208c1e6aebeab2f744b91d27aa28;p=thirdparty%2Ftvheadend.git tcp: handle ERRNO_AGAIN in tcp_fill_htsbuf_from_fd (2nd) --- diff --git a/src/tcp.c b/src/tcp.c index 56c34055e..18e717408 100644 --- 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; }