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 74efed84eb2e5cc3f5b72be8b112020a362e7232
parent e9292b7acff19655482c6b53ff19f8c51f06bdcd
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed,  7 Feb 2018 20:17:56 +0100

Advance send buffer in xsendfile for conservative method.

Thanks Lucas Gabriel Vuotto <lgv@nanashi.co>!

Diffstat:
ind.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ind.c b/ind.c @@ -78,7 +78,7 @@ int xsendfile(int fd, int sock) { struct stat st; - char *sendb; + char *sendb, *sendi; size_t bufsiz = BUFSIZ, count = 0; int len, sent, optval; @@ -121,12 +121,14 @@ xsendfile(int fd, int sock) if (count > 0) { sendb = xmalloc(bufsiz); while ((len = read(fd, sendb, bufsiz)) > 0) { + sendi = sendb; while (len > 0) { - if ((sent = send(sock, sendb, len, 0)) < 0) { + if ((sent = send(sock, sendi, len, 0)) < 0) { free(sendb); return -1; } len -= sent; + sendi += sent; } } free(sendb);