trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject svn commit: r1170006 - in /trafficserver/traffic/trunk/iocore/net: Connection.cc P_Connection.h UnixNetProcessor.cc
Date Tue, 13 Sep 2011 02:10:17 GMT
Author: jesus
Date: Tue Sep 13 02:10:17 2011
New Revision: 1170006

URL: http://svn.apache.org/viewvc?rev=1170006&view=rev
Log:
Implements TS-943

Modified:
    trafficserver/traffic/trunk/iocore/net/Connection.cc
    trafficserver/traffic/trunk/iocore/net/P_Connection.h
    trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc

Modified: trafficserver/traffic/trunk/iocore/net/Connection.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/Connection.cc?rev=1170006&r1=1170005&r2=1170006&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/Connection.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/Connection.cc Tue Sep 13 02:10:17 2011
@@ -128,6 +128,15 @@ Connection::close()
   }
 }
 
+static int
+add_http_filter(int fd) {
+  int err = -1;
+#if defined(SOL_FILTER) && defined(FIL_ATTACH)
+  err = setsockopt(fd, SOL_FILTER, FIL_ATTACH, "httpf", 6);
+#endif
+  return err;
+}
+
 int
 Server::setup_fd_for_listen(
   bool non_blocking,
@@ -135,7 +144,12 @@ Server::setup_fd_for_listen(
   int send_bufsize,
   bool transparent
 ) {
+
   int res = 0;
+
+  if (http_accept_filter)
+    add_http_filter(fd);
+
 #ifdef SEND_BUF_SIZE
   {
     int send_buf_size = SEND_BUF_SIZE;
@@ -259,6 +273,9 @@ Server::listen(bool non_blocking, int re
     return res;
   fd = res;
 
+  if (http_accept_filter)
+    add_http_filter(fd);
+
 #ifdef SEND_BUF_SIZE
   {
     int send_buf_size = SEND_BUF_SIZE;

Modified: trafficserver/traffic/trunk/iocore/net/P_Connection.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/P_Connection.h?rev=1170006&r1=1170005&r2=1170006&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/P_Connection.h (original)
+++ trafficserver/traffic/trunk/iocore/net/P_Connection.h Tue Sep 13 02:10:17 2011
@@ -208,6 +208,9 @@ struct Server: public Connection
   /// If set, the related incoming connect was transparent.
   bool f_inbound_transparent;
 
+  /// If set, a kernel HTTP accept filter
+  bool http_accept_filter;
+
   //
   // Use this call for the main proxy accept
   //

Modified: trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc?rev=1170006&r1=1170005&r2=1170006&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc Tue Sep 13 02:10:17 2011
@@ -135,6 +135,12 @@ UnixNetProcessor::accept_internal(
     );
   }
 
+  int should_filter_int = 0;
+  na->server.http_accept_filter = false;
+  IOCORE_ReadConfigInteger(should_filter_int, "proxy.config.net.defer_accept");
+  if (should_filter_int > 0 && opt.etype == ET_NET)
+    na->server.http_accept_filter = true;
+
   na->action_ = NEW(new NetAcceptAction());
   *na->action_ = cont;
   na->action_->server = &na->server;
@@ -169,10 +175,8 @@ UnixNetProcessor::accept_internal(
 #ifdef TCP_DEFER_ACCEPT
   // set tcp defer accept timeout if it is configured, this will not trigger an accept until
there is
   // data on the socket ready to be read
-  int accept_timeout = 0;
-  IOCORE_ReadConfigInteger(accept_timeout, "proxy.config.net.defer_accept");
-  if (accept_timeout > 0) {
-    setsockopt(na->server.fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &accept_timeout, sizeof(int));
+  if (should_filter_int > 0) {
+    setsockopt(na->server.fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &should_filter_int, sizeof(int));
   }
 #endif
 #ifdef TCP_INIT_CWND



Mime
View raw message