From 25cb09553d8af5eebc487e6cee5d4ece3ca77d0c Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Thu, 21 Sep 2017 03:01:44 +1200 Subject: [PATCH] Fix partial reads Partial reads use an internal buffer that is filled and drained into the requestors buffer. If some data is drained we still wait on the file descriptor even though no more data may arrive until the requestor responds (e.g. last chunk of HTTP was drained from the rxbuf here but we still wait for more data though we need to send a response first likely!) --- fd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fd.c b/fd.c index 7be72a37..5f7e593b 100644 --- a/fd.c +++ b/fd.c @@ -265,6 +265,8 @@ ssize_t fd_recv(int s, struct fd_rxbuf *rxbuf, struct iolist *first, if(errno == EPIPE) errno = ECONNRESET; return -1; } + /* If we have read data return it immediately */ + if (read > 0) return read; /* Wait for more data. */ int rc = fdin(s, deadline); if(dill_slow(rc < 0)) return -1;