Add comments for the new xsendfile. - geomyidae - A small C-based gopherd.
git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
Log
Files
Refs
Tags
README
LICENSE
---
commit 8b62f1e60e9774368bfdb209f3bebc8f51d6e0b8
parent b92f702f27e642838e51e8b308c482c08ebdc786
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 24 Sep 2017 18:35:50 +0200

Add comments for the new xsendfile.

Diffstat:
  M ind.c                               |      10 ++++++++++

1 file changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/ind.c b/ind.c
@@ -60,16 +60,21 @@ xsendfile(int fd, int sock)
         size_t bufsiz = BUFSIZ, count = 0;
         int len, sent, optval;
 
+/* Tell the kernel to not send small packets on every write. */
 #ifdef TCP_CORK
         optval = 1;
         setsockopt(sock, IPPROTO_TCP, TCP_CORK, &optval, sizeof(int));
 #endif
 
+/* TCP_CORK for FreeBSD */
 #ifdef TCP_NOPUSH
         optval = 1;
         setsockopt(sock, IPPROTO_TCP, TCP_NOPUSH, &optval, sizeof(int));
 #endif
 
+/*
+ * Disable Nagle algorithm, which means to sent segments as soon as possible.
+ */
 #ifdef TCP_NODELAY
         optval = 0;
         setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(int));
@@ -81,6 +86,10 @@ xsendfile(int fd, int sock)
                 count = st.st_size;
         }
 
+/*
+ * If we are on the said operating systems, use some special method for data
+ * transfer.
+ */
 #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
         count = 0;
 #endif
@@ -101,6 +110,7 @@ xsendfile(int fd, int sock)
                 return 0;
         }
 
+/* Different sendfile(2) implementations on different platforms. :/ */
 #ifdef __linux__
         return sendfile(sock, fd, NULL, count);
 #endif