geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit 429ea45adba32c7ffa87b8b00528e26edc701e74
parent a2eaebc870ac0a24f35beef0bf8ffa786d5933a3
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun,  7 Jun 2020 21:39:30 +0200

Fix xsendfile properly.

Diffstat:
ind.c | 24++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/ind.c b/ind.c @@ -119,23 +119,19 @@ xsendfile(int fd, int sock) count = st.st_size; } - if (count == 0) { - sendb = xmalloc(bufsiz); - while ((len = read(fd, sendb, bufsiz)) > 0) { - sendi = sendb; - while (len > 0) { - if ((sent = send(sock, sendi, len, 0)) < 0) { - free(sendb); - return -1; - } - len -= sent; - sendi += sent; + sendb = xmalloc(bufsiz); + while ((len = read(fd, sendb, bufsiz)) > 0) { + sendi = sendb; + while (len > 0) { + if ((sent = send(sock, sendi, len, 0)) < 0) { + free(sendb); + return -1; } + len -= sent; + sendi += sent; } - free(sendb); - return 0; } - + free(sendb); return 0; }