Repository: trafficserver
Updated Branches:
  refs/heads/master 6d258ea0d -> fbb5c0716


TS-4056: Remove cached netVC from NetAccept.
This close #381.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fbb5c071
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fbb5c071
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fbb5c071

Branch: refs/heads/master
Commit: fbb5c07162bc6d3a8b44bc2a0d30b6cbeb2153bc
Parents: 6d258ea
Author: Oknet <[email protected]>
Authored: Mon Dec 7 22:13:42 2015 +0800
Committer: Alan M. Carroll <[email protected]>
Committed: Fri Mar 18 19:18:18 2016 -0500

----------------------------------------------------------------------
 iocore/net/P_NetAccept.h    |  1 -
 iocore/net/UnixNetAccept.cc | 27 +++++++++++++--------------
 2 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fbb5c071/iocore/net/P_NetAccept.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_NetAccept.h b/iocore/net/P_NetAccept.h
index d596003..5cafbee 100644
--- a/iocore/net/P_NetAccept.h
+++ b/iocore/net/P_NetAccept.h
@@ -80,7 +80,6 @@ struct NetAcceptAction : public Action, public RefCountObj {
 struct NetAccept : public Continuation {
   ink_hrtime period;
   Server server;
-  void *alloc_cache;
   AcceptFunctionPtr accept_fn;
   int ifd;
   bool callback_on_open;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fbb5c071/iocore/net/UnixNetAccept.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc
index 7096f7c..835d17f 100644
--- a/iocore/net/UnixNetAccept.cc
+++ b/iocore/net/UnixNetAccept.cc
@@ -84,6 +84,7 @@ net_accept(NetAccept *na, void *ep, bool blockable)
   int count = 0;
   int loop = accept_till_done;
   UnixNetVConnection *vc = NULL;
+  Connection con;
 
   if (!blockable)
     if (!MUTEX_TAKE_TRY_LOCK_FOR(na->action_->mutex, e->ethread, 
na->action_->continuation))
@@ -91,14 +92,7 @@ net_accept(NetAccept *na, void *ep, bool blockable)
   // do-while for accepting all the connections
   // added by YTS Team, yamsat
   do {
-    vc = (UnixNetVConnection *)na->alloc_cache;
-    if (!vc) {
-      vc = (UnixNetVConnection 
*)na->getNetProcessor()->allocate_vc(e->ethread);
-      NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
-      vc->id = net_next_connection_number();
-      na->alloc_cache = vc;
-    }
-    if ((res = na->server.accept(&vc->con)) < 0) {
+    if ((res = na->server.accept(&con)) < 0) {
       if (res == -EAGAIN || res == -ECONNABORTED || res == -EPIPE)
         goto Ldone;
       if (na->server.fd != NO_FD && !na->action_->cancelled) {
@@ -112,9 +106,15 @@ net_accept(NetAccept *na, void *ep, bool blockable)
       count = res;
       goto Ldone;
     }
-    count++;
-    na->alloc_cache = NULL;
 
+    vc = static_cast<UnixNetVConnection 
*>(na->getNetProcessor()->allocate_vc(e->ethread));
+    if (!vc)
+      goto Ldone; // note: @a con will clean up the socket when it goes out of 
scope.
+
+    ++count;
+    NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
+    vc->id = net_next_connection_number();
+    vc->con.move(con);
     vc->submit_time = Thread::get_hrtime();
     ats_ip_copy(&vc->server_addr, &vc->con.addr);
     vc->mutex = new_ProxyMutex();
@@ -283,7 +283,6 @@ NetAccept::do_blocking_accept(EThread *t)
     vc->apply_options();
     vc->from_accept_thread = true;
     vc->id = net_next_connection_number();
-    alloc_cache = NULL;
 
     check_emergency_throttle(con);
 
@@ -359,7 +358,7 @@ NetAccept::acceptFastEvent(int event, void *ep)
 
   do {
     if (!backdoor && check_net_throttle(ACCEPT, Thread::get_hrtime())) {
-      ifd = -1;
+      ifd = NO_FD;
       return EVENT_CONT;
     }
 
@@ -507,8 +506,8 @@ NetAccept::acceptLoopEvent(int event, Event *e)
 //
 
 NetAccept::NetAccept()
-  : Continuation(NULL), period(0), alloc_cache(0), ifd(-1), 
callback_on_open(false), backdoor(false), recv_bufsize(0),
-    send_bufsize(0), sockopt_flags(0), packet_mark(0), packet_tos(0), etype(0)
+  : Continuation(NULL), period(0), ifd(NO_FD), callback_on_open(false), 
backdoor(false), recv_bufsize(0), send_bufsize(0),
+    sockopt_flags(0), packet_mark(0), packet_tos(0), etype(0)
 {
 }
 

Reply via email to