about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-01-17 01:37:17 +0000
committerEric Wong <normalperson@yhbt.net>2013-01-17 01:41:27 +0000
commit0e9a8e156f0a060c7822069c4f69eea3710c793c (patch)
treefcce7388ed16aca76d5c15580ae0db210d3f38bb
parent14e0684507c06439ee9c7a731fd6ca90b7b9adcb (diff)
downloadcmogstored-0e9a8e156f0a060c7822069c4f69eea3710c793c.tar.gz
Since we no longer use TCP_CORK under Linux (where we use
MSG_MORE instead), we can cleanup the nomenclature and avoid
confusing people by mentioning TCP_CORK.
-rw-r--r--bind_listen.c9
-rw-r--r--cmogstored.h25
-rw-r--r--http.c13
3 files changed, 20 insertions, 27 deletions
diff --git a/bind_listen.c b/bind_listen.c
index e9f6345..aaea72f 100644
--- a/bind_listen.c
+++ b/bind_listen.c
@@ -4,17 +4,16 @@
  */
 #include "cmogstored.h"
 
-/* Under Linux, TCP_CORK is inherited by accepted sockets */
 /* Under FreeBSD, TCP_NOPUSH is inherited by accepted sockets */
-static int tcp_cork_prepare(int fd)
+static int tcp_nopush_prepare(int fd)
 {
         socklen_t len = (socklen_t)sizeof(int);
         int val = 1;
 
-        if (MOG_TCP_CORK == 0)
+        if (MOG_TCP_NOPUSH == 0)
                 return 0;
 
-        return setsockopt(fd, IPPROTO_TCP, MOG_TCP_CORK, &val, len);
+        return setsockopt(fd, IPPROTO_TCP, MOG_TCP_NOPUSH, &val, len);
 }
 
 /*
@@ -48,7 +47,7 @@ static int set_tcp_opts(int fd, const char *accept_filter)
 
         if (accept_filter) {
                 if (strcmp(accept_filter, "httpready") == 0)
-                        rc = tcp_cork_prepare(fd);
+                        rc = tcp_nopush_prepare(fd);
         }
 
         return rc;
diff --git a/cmogstored.h b/cmogstored.h
index fbe0aae..7c61fdd 100644
--- a/cmogstored.h
+++ b/cmogstored.h
@@ -479,25 +479,20 @@ bool mog_valid_put_path(const char *buf, size_t len);
  * non-Linux may not allow MSG_MORE on stream sockets,
  * so limit MSG_MORE usage to Linux for now
  */
-#if defined(TCP_CORK) /* Linux (most likely) */
-#  if defined(MSG_MORE) && defined(__linux__)
-#    define MOG_TCP_CORK (0)
-#    define MOG_MSG_MORE (MSG_MORE)
-#  else
-#    define MOG_TCP_CORK TCP_CORK
-#  endif
-#elif defined(TCP_NOPUSH) /* FreeBSD */
+#if defined(MSG_MORE) && defined(__linux__)
+#  define MOG_MSG_MORE (MSG_MORE)
+#else
+#  define MOG_MSG_MORE (0)
+#endif
+
+#if defined(TCP_NOPUSH) /* FreeBSD */
 /*
  * TCP_NOPUSH in modern versions of FreeBSD behave identically to
- * TCP_CORK under Linux
+ * TCP_CORK under Linux (which we used before we switched Linux to MSG_MORE)
  */
-#  define MOG_TCP_CORK TCP_NOPUSH
+#  define MOG_TCP_NOPUSH TCP_NOPUSH
 #else
-#  define MOG_TCP_CORK (0)
-#endif
-
-#ifndef MOG_MSG_MORE
-#  define MOG_MSG_MORE (0)
+#  define MOG_TCP_NOPUSH (0)
 #endif
 
 /* cmogstored.c */
diff --git a/http.c b/http.c
index 9900a3a..f25d577 100644
--- a/http.c
+++ b/http.c
@@ -6,25 +6,24 @@
 #include "http.h"
 
 /*
- * 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
  */
-static void tcp_flush(struct mog_fd *mfd, bool recork)
+static void tcp_push(struct mog_fd *mfd, bool recork)
 {
         socklen_t len = (socklen_t)sizeof(int);
         int val = 0;
         int rv;
 
-        if (MOG_TCP_CORK == 0)
+        if (MOG_TCP_NOPUSH == 0)
                 return;
 
-        rv = setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_CORK, &val, len);
+        rv = setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_NOPUSH, &val, len);
 
         if (rv == 0 && recork) {
                 val = 1;
-                setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_CORK, &val, len);
+                setsockopt(mfd->fd, IPPROTO_TCP, MOG_TCP_NOPUSH, &val, len);
         }
         /* deal with errors elsewhere */
 }
@@ -87,7 +86,7 @@ MOG_NOINLINE static void http_close(struct mog_fd *mfd)
          * writing a request that's too big to read and we reset
          * their connection to save ourselves bandwidth/cycles
          */
-        tcp_flush(mfd, false);
+        tcp_push(mfd, false);
 
         mog_fd_put(mfd);
 }
@@ -350,6 +349,6 @@ mog_http_resp0(
 /* call whenever we're ready to read the next HTTP request */
 void mog_http_reset(struct mog_http *http)
 {
-        tcp_flush(mog_fd_of(http), true);
+        tcp_push(mog_fd_of(http), true);
         mog_http_reset_parser(http);
 }