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 bbda3db127acc7e916bdd1668edb00ca7235ad02
parent 4481c2cbcf4bb258d8f06785528c0387386064ca
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 30 Jan 2021 18:28:55 +0100

Add the story of xsendfile to the source.

Diffstat:
ind.c | 21++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/ind.c b/ind.c @@ -116,9 +116,27 @@ xsendfile(int fd, int sock) USED(optval); - if (fstat(fd, &st) >= 0) + /* + * The story of xsendfile. + * + * Once upon a time, here you saw a big #ifdef switch source of + * many ways how to send files with special functions on + * different operating systems. All of this was removed, because + * operating systems and kernels got better over time, + * simplifying what you need and reducing corner cases. + * + * For example Linux sendfile(2) sounds nice and faster, but + * the function is different on every OS and slower to the now + * used approach of read(2) and write(2). + * + * If you ever consider changing this to some "faster" approach, + * consider benchmarks on all platforms. + */ + + if (fstat(fd, &st) >= 0) { if ((bufsiz = st.st_blksize) < BUFSIZ) bufsiz = BUFSIZ; + } sendb = xmalloc(bufsiz); while ((len = read(fd, sendb, bufsiz)) > 0) { @@ -133,6 +151,7 @@ xsendfile(int fd, int sock) } } free(sendb); + return 0; }