URI: 
       Add the story of xsendfile to the source. - geomyidae - A small C-based gopherd.
  HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit bbda3db127acc7e916bdd1668edb00ca7235ad02
   DIR parent 4481c2cbcf4bb258d8f06785528c0387386064ca
  HTML 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:
         M ind.c                               |      21 ++++++++++++++++++++-
       
       1 file changed, 20 insertions(+), 1 deletion(-)
       ---
   DIR 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;
        }