about summary refs log tree commit homepage
path: root/http.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-07-19 23:55:32 +0000
committerEric Wong <normalperson@yhbt.net>2012-07-19 16:56:35 -0700
commit84d7e098b71046a3f6aa3b263215123acfdcecac (patch)
tree89ab961d52b42cbb22174aa7601925b25734fb07 /http.c
parent8ddcaf62158ec3c4adbf1874576a73f45d41ddfe (diff)
downloadcmogstored-84d7e098b71046a3f6aa3b263215123acfdcecac.tar.gz
For many years now, TCP_NOPUSH behaves exactly like TCP_CORK
on Linux so we can just enable it to save system calls on
the /client/ side.

Using the integrated writev-like facility of the BSD sendfile()
implementation may not be worth it as it complicates error handling.

Tested on Debian GNU/kFreeBSD 6.0
Diffstat (limited to 'http.c')
-rw-r--r--http.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/http.c b/http.c
index 95fac53..3904caf 100644
--- a/http.c
+++ b/http.c
@@ -5,9 +5,9 @@
 #include "cmogstored.h"
 #include "http.h"
 
-#ifdef TCP_CORK
 /*
  * On Linux, this disables TCP_CORK momentarily to flush out corked data.
+ * On FreeBSD, this disables TCP_NOPUSH momentarily to flush out corked data.
  * This immediately recorks again if we're handling persistent connections,
  * otherwise we leave it uncorked if we're going to close the socket anyways
  */
@@ -15,17 +15,19 @@ static void tcp_flush(struct mog_fd *mfd, bool recork)
 {
         socklen_t len = (socklen_t)sizeof(int);
         int val = 0;
-        int rv = setsockopt(mfd->fd, IPPROTO_TCP, TCP_CORK, &val, len);
+        int rv;
+
+        if (MOG_TCP_CORK == 0)
+                return;
+
+        rv = setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_CORK, &val, len);
 
         if (rv == 0 && recork) {
                 val = 1;
-                setsockopt(mfd->fd, IPPROTO_TCP, TCP_CORK, &val, len);
+                setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_CORK, &val, len);
         }
         /* deal with errors elsewhere */
 }
-#else  /* !TCP_CORK */
-static void tcp_flush(struct mog_fd *mfd, bool recork) {}
-#endif /* !TCP_CORK */
 
 /* stash any pipelined data for the next round */
 static void