trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1099287 - in /trafficserver/traffic/trunk: contrib/perl/AdminClient/lib/Apache/TS/ example/protocol/ iocore/net/ mgmt/ proxy/ proxy/api/ts/ proxy/logging/
Date Tue, 03 May 2011 22:37:48 GMT
Author: zwoop
Date: Tue May  3 22:37:48 2011
New Revision: 1099287

URL: http://svn.apache.org/viewvc?rev=1099287&view=rev
Log:
TS-757 Change TSNetAccept() API to take an option for enabling (and
number of) accept threads. Also have it take a protocol "domain"
argument, to be consistent with the underlying internal APIs.

Modified:
    trafficserver/traffic/trunk/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
    trafficserver/traffic/trunk/example/protocol/Protocol.c
    trafficserver/traffic/trunk/iocore/net/I_NetProcessor.h
    trafficserver/traffic/trunk/iocore/net/SSLUnixNet.cc
    trafficserver/traffic/trunk/iocore/net/UnixNetAccept.cc
    trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc
    trafficserver/traffic/trunk/mgmt/RecordsConfig.cc
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/InkAPITest.cc
    trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
    trafficserver/traffic/trunk/proxy/logging/LogCollationAccept.cc

Modified: trafficserver/traffic/trunk/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm (original)
+++ trafficserver/traffic/trunk/contrib/perl/AdminClient/lib/Apache/TS/AdminClient.pm Tue
May  3 22:37:48 2011
@@ -616,7 +616,6 @@ The Apache Traffic Server Administration
  proxy.config.net.ink_disk_io_watermark
  proxy.config.net.listen_backlog
  proxy.config.net.max_kqueue_len
- proxy.config.net.nt.main_accept_pool_size
  proxy.config.net_snapshot_filename
  proxy.config.net.sock_mss_in
  proxy.config.net.sock_option_flag_in

Modified: trafficserver/traffic/trunk/example/protocol/Protocol.c
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/protocol/Protocol.c?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/protocol/Protocol.c (original)
+++ trafficserver/traffic/trunk/example/protocol/Protocol.c Tue May  3 22:37:48 2011
@@ -96,7 +96,7 @@ protocol_init(int accept_port, int serve
      When there are requests coming in, contp's handler
      should be called, in this case, contp's handler
      is accept_event, see AcceptSM.c */
-  pending_action = TSNetAccept(contp, accept_port);
+  pending_action = TSNetAccept(contp, accept_port, -1, 1);
 }
 
 int

Modified: trafficserver/traffic/trunk/iocore/net/I_NetProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/I_NetProcessor.h?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/I_NetProcessor.h (original)
+++ trafficserver/traffic/trunk/iocore/net/I_NetProcessor.h Tue May  3 22:37:48 2011
@@ -132,7 +132,8 @@ public:
       port becomes free immediately.
 
   */
-  inkcoreapi virtual Action * accept(Continuation * cont, int port, int domain = AF_INET,
bool frequent_accept = false,
+  inkcoreapi virtual Action * accept(Continuation * cont, int port, int domain = AF_INET,
int accept_threads = -1,
+                                     bool frequent_accept = false,
                                      // not used
                                      unsigned int accept_ip = INADDR_ANY, char *accept_ip_str
= NULL, bool callback_on_open = false,
                                      SOCKET listen_socket_in = NO_FD,   // NT only

Modified: trafficserver/traffic/trunk/iocore/net/SSLUnixNet.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/SSLUnixNet.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/SSLUnixNet.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/SSLUnixNet.cc Tue May  3 22:37:48 2011
@@ -61,7 +61,7 @@ SSLNetProcessor::start(int number_of_ssl
   ET_SSL = eventProcessor.spawn_event_threads(number_of_ssl_threads);
   if (err == 0)
     err = UnixNetProcessor::start();
-  return (err);
+  return err;
 }
 
 
@@ -87,20 +87,20 @@ SSLNetProcessor::upgradeEtype(EventType 
 EventType
 SSLNetAccept::getEtype()
 {
-  return (ET_SSL);
+  return ET_SSL;
 }
 
 // Functions all THREAD_FREE and THREAD_ALLOC to be performed
 // for both SSL and regular NetVConnection transparent to
 // accept functions.
 UnixNetVConnection *
-SSLNetAccept::allocateThread(EThread * t)
+SSLNetAccept::allocateThread(EThread *t)
 {
   return ((UnixNetVConnection *) THREAD_ALLOC(sslNetVCAllocator, t));
 }
 
 void
-SSLNetAccept::freeThread(UnixNetVConnection * vc, EThread * t)
+SSLNetAccept::freeThread(UnixNetVConnection *vc, EThread *t)
 {
   ink_assert(!vc->from_accept_thread);
   THREAD_FREE((SSLNetVConnection *) vc, sslNetVCAllocator, t);
@@ -119,13 +119,13 @@ SSLNetAccept::allocateGlobal()
 // have them in both places, but it saves a bunch of
 // connect code from being duplicated.
 UnixNetVConnection *
-SSLNetProcessor::allocateThread(EThread * t)
+SSLNetProcessor::allocateThread(EThread *t)
 {
   return ((UnixNetVConnection *) THREAD_ALLOC(sslNetVCAllocator, t));
 }
 
 void
-SSLNetProcessor::freeThread(UnixNetVConnection * vc, EThread * t)
+SSLNetProcessor::freeThread(UnixNetVConnection *vc, EThread *t)
 {
   ink_assert(!vc->from_accept_thread);
   THREAD_FREE((SSLNetVConnection *) vc, sslNetVCAllocator, t);

Modified: trafficserver/traffic/trunk/iocore/net/UnixNetAccept.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/UnixNetAccept.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/UnixNetAccept.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/UnixNetAccept.cc Tue May  3 22:37:48 2011
@@ -555,14 +555,13 @@ NetAccept::acceptLoopEvent(int event, Ev
 //
 //
 
-NetAccept::NetAccept():
-Continuation(NULL),
-port(0),
-period(0),
-alloc_cache(0),
-ifd(-1), callback_on_open(false), recv_bufsize(0), send_bufsize(0), sockopt_flags(0), etype(0)
-{
-}
+NetAccept::NetAccept()
+  : Continuation(NULL),
+    port(0),
+    period(0),
+    alloc_cache(0),
+    ifd(-1), callback_on_open(false), recv_bufsize(0), send_bufsize(0), sockopt_flags(0),
etype(0)
+{ }
 
 
 //

Modified: trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc (original)
+++ trafficserver/traffic/trunk/iocore/net/UnixNetProcessor.cc Tue May  3 22:37:48 2011
@@ -63,6 +63,7 @@ Action *
 NetProcessor::accept(Continuation * cont,
                      int port,
                      int domain,
+                     int accept_threads,
                      bool frequent_accept,
                      unsigned int accept_ip,
                      char *accept_ip_str,
@@ -80,11 +81,11 @@ NetProcessor::accept(Continuation * cont
   (void) bound_sockaddr;        // NT only
   (void) bound_sockaddr_size;   // NT only
   Debug("iocore_net_processor",
-           "NetProcessor::accept - port %d,recv_bufsize %d, send_bufsize %d, sockopt 0x%0lX",
-           port, recv_bufsize, send_bufsize, sockopt_flags
-           );
+        "NetProcessor::accept - port %d,recv_bufsize %d, send_bufsize %d, sockopt 0x%0lX",
+        port, recv_bufsize, send_bufsize, sockopt_flags);
 
   AcceptOptions opt;
+
   opt.port = port;
   opt.domain = domain;
   opt.etype = etype;
@@ -92,6 +93,8 @@ NetProcessor::accept(Continuation * cont
   opt.recv_bufsize = recv_bufsize;
   opt.send_bufsize = send_bufsize;
   opt.sockopt_flags = opt.sockopt_flags;
+  opt.accept_threads = accept_threads;
+
   return ((UnixNetProcessor *) this)->accept_internal(cont, NO_FD,
                                                       bound_sockaddr,
                                                       bound_sockaddr_size,
@@ -99,8 +102,7 @@ NetProcessor::accept(Continuation * cont
                                                       net_accept,
                                                       accept_ip,
                                                       accept_ip_str,
-                                                      opt
-                                                      );
+                                                      opt);
 }
 
 Action *
@@ -120,8 +122,7 @@ NetProcessor::main_accept(Continuation *
                                                       net_accept,
                                                       ((UnixNetProcessor *) this)->incoming_ip_to_bind_saddr,
                                                       ((UnixNetProcessor *) this)->incoming_ip_to_bind,
-                                                      opt
-                                                      );
+                                                      opt);
 }
 
 
@@ -135,17 +136,21 @@ UnixNetProcessor::accept_internal(Contin
                                   AcceptFunction fn,
                                   unsigned int accept_ip,
                                   char *accept_ip_str,
-                                  AcceptOptions const& opt
-                                  )
+                                  AcceptOptions const& opt)
 {
   EventType et = opt.etype; // setEtype requires non-const ref.
   NetAccept *na = createNetAccept();
   EThread *thread = this_ethread();
   ProxyMutex *mutex = thread->mutex;
+  int accept_threads = opt.accept_threads;
 
   // Potentially upgrade to SSL.
   upgradeEtype(et);
 
+  // Fill in accept thread from configuration if necessary.
+  if (opt.accept_threads < 0)
+    IOCORE_ReadConfigInteger(accept_threads, "proxy.config.accept_threads");
+
   NET_INCREMENT_DYN_STAT(net_accepts_currently_open_stat);
   na->port = opt.port;
   na->domain = opt.domain;
@@ -167,18 +172,18 @@ UnixNetProcessor::accept_internal(Contin
   if (na->callback_on_open)
     na->mutex = cont->mutex;
   if (frequent_accept) { // true
-    if (opt.accept_threads > 0)  {
+    if (accept_threads > 0)  {
       if (0 == na->do_listen(BLOCKING)) {
         NetAccept *a;
 
-        for (int i=1; i < opt.accept_threads; ++i) {
+        for (int i=1; i < accept_threads; ++i) {
           a = NEW(new NetAccept);
           *a = *na;
           a->init_accept_loop();
           Debug("iocore_net_accept", "Created accept thread #%d for port %d", i, opt.port);
         }
         // Start the "template" accept thread last.
-        Debug("iocore_net_accept", "Created accept thread #%d for port %d", opt.accept_threads,
opt.port);
+        Debug("iocore_net_accept", "Created accept thread #%d for port %d", accept_threads,
opt.port);
         na->init_accept_loop();
       }
     } else {

Modified: trafficserver/traffic/trunk/mgmt/RecordsConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/RecordsConfig.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/RecordsConfig.cc (original)
+++ trafficserver/traffic/trunk/mgmt/RecordsConfig.cc Tue May  3 22:37:48 2011
@@ -865,8 +865,6 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.net.sock_mss_in", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL,
NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.net.nt.main_accept_pool_size", RECD_INT, "500", RECU_RESTART_TS,
RR_NULL, RECC_NULL, NULL, RECA_NULL}
-  ,
 
   //##############################################################################
   //#

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Tue May  3 22:37:48 2011
@@ -6090,15 +6090,21 @@ TSNetConnect(TSCont contp, unsigned int 
 }
 
 TSAction
-TSNetAccept(TSCont contp, int port)
+TSNetAccept(TSCont contp, int port, int domain, int accept_threads)
 {
   sdk_assert(sdk_sanity_check_continuation(contp) == TS_SUCCESS);
   sdk_assert(port > 0);
+  sdk_assert(accept_threads >= -1);
 
+  // TODO: Does this imply that only one "accept thread" could be
+  // doing an accept at any time?
   FORCE_PLUGIN_MUTEX(contp);
 
+  if (domain < 0)
+    domain = AF_INET;
+
   INKContInternal *i = (INKContInternal *) contp;
-  return (TSAction)netProcessor.accept(i, port);
+  return (TSAction)netProcessor.accept(i, port, domain, accept_threads);
 }
 
 /* DNS Lookups */

Modified: trafficserver/traffic/trunk/proxy/InkAPITest.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITest.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITest.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITest.cc Tue May  3 22:37:48 2011
@@ -331,7 +331,7 @@ REGRESSION_TEST(SDK_API_TSNetVConn) (Reg
   TSCont server_cont = TSContCreate(server_handler, server_mutex);
   TSCont client_cont = TSContCreate(client_handler, client_mutex);
 
-  TSNetAccept(server_cont, server_port);
+  TSNetAccept(server_cont, server_port, -1, 0);
 
   unsigned int server_ip = IP(127, 0, 0, 1);
   TSNetConnect(client_cont, server_ip, server_port);

Modified: trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITestTool.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITestTool.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITestTool.cc Tue May  3 22:37:48 2011
@@ -743,7 +743,7 @@ static int
 synserver_start(SocketServer * s)
 {
   TSAssert(s->magic == MAGIC_ALIVE);
-  s->accept_action = TSNetAccept(s->accept_cont, s->accept_port);
+  s->accept_action = TSNetAccept(s->accept_cont, s->accept_port, -1, 0);
   return 1;
 }
 

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Tue May  3 22:37:48 2011
@@ -2349,7 +2349,7 @@ extern "C"
    */
   tsapi TSAction TSNetConnect(TSCont contp, unsigned int ip, int port);
 
-  tsapi TSAction TSNetAccept(TSCont contp, int port);
+  tsapi TSAction TSNetAccept(TSCont contp, int port, int domain, int accept_threads);
 
   /* --------------------------------------------------------------------------
      DNS Lookups */

Modified: trafficserver/traffic/trunk/proxy/logging/LogCollationAccept.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogCollationAccept.cc?rev=1099287&r1=1099286&r2=1099287&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogCollationAccept.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogCollationAccept.cc Tue May  3 22:37:48 2011
@@ -36,10 +36,10 @@
 // LogCollationAccept::LogCollationAccept
 //-------------------------------------------------------------------------
 
-LogCollationAccept::LogCollationAccept(int port):
-  Continuation(new_ProxyMutex()),
-  m_port(port),
-  m_pending_event(NULL)
+LogCollationAccept::LogCollationAccept(int port)
+  : Continuation(new_ProxyMutex()),
+    m_port(port),
+    m_pending_event(NULL)
 {
 
   SET_HANDLER((LogCollationAcceptHandler) & LogCollationAccept::accept_event);
@@ -47,9 +47,8 @@ LogCollationAccept::LogCollationAccept(i
   // appended to itself if multiple do_io_reads are called requesting
   // small amounts of data.  Most arguments are default except for the
   // last one which we will set to true.
-  m_accept_action = netProcessor.accept(this, m_port, AF_INET, false, INADDR_ANY, NULL, false,
NO_FD, ACCEPTEX_POOL_SIZE, true);
+  m_accept_action = netProcessor.accept(this, m_port, AF_INET, 0, false, INADDR_ANY, NULL,
false, NO_FD, ACCEPTEX_POOL_SIZE, true);
   ink_assert(NULL != m_accept_action);
-
 }
 
 //-------------------------------------------------------------------------
@@ -58,7 +57,6 @@ LogCollationAccept::LogCollationAccept(i
 
 LogCollationAccept::~LogCollationAccept()
 {
-
   Debug("log-collation", "LogCollationAccept::~LogCollationAccept");
 
   // stop the netProcessor
@@ -83,7 +81,6 @@ LogCollationAccept::~LogCollationAccept(
   if (m_pending_event && (m_pending_event != ACTION_RESULT_DONE)) {
     m_pending_event->cancel();
   }
-
 }
 
 //-------------------------------------------------------------------------
@@ -93,11 +90,9 @@ LogCollationAccept::~LogCollationAccept(
 int
 LogCollationAccept::accept_event(int event, NetVConnection * net_vc)
 {
-
   LogCollationHostSM *sm;
 
   switch (event) {
-
   case NET_EVENT_ACCEPT:
     sm = NEW(new LogCollationHostSM(net_vc));
     ink_assert(NULL != sm);
@@ -109,5 +104,4 @@ LogCollationAccept::accept_event(int eve
   }
 
   return EVENT_CONT;
-
 }



Mime
View raw message