You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2015/09/04 23:09:14 UTC

trafficserver git commit: TS-3871: VC Migration Can Lose Events.

Repository: trafficserver
Updated Branches:
  refs/heads/master f079f9831 -> 6d4a36262


TS-3871: VC Migration Can Lose Events.


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

Branch: refs/heads/master
Commit: 6d4a362622bcaa58a9055db6d93e896de70da87b
Parents: f079f98
Author: shinrich <sh...@yahoo-inc.com>
Authored: Fri Sep 4 16:07:48 2015 -0500
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Fri Sep 4 16:07:48 2015 -0500

----------------------------------------------------------------------
 iocore/net/Connection.cc         | 10 ++++------
 iocore/net/P_Connection.h        |  2 --
 iocore/net/UnixNetVConnection.cc | 10 ++++++++--
 proxy/http/HttpSessionManager.cc |  1 +
 4 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d4a3626/iocore/net/Connection.cc
----------------------------------------------------------------------
diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc
index 57532da..4f11e45 100644
--- a/iocore/net/Connection.cc
+++ b/iocore/net/Connection.cc
@@ -62,7 +62,7 @@ NetVCOptions::toString(addr_bind_style s)
   return ANY_ADDR == s ? "any" : INTF_ADDR == s ? "interface" : "foreign";
 }
 
-Connection::Connection() : fd(NO_FD), is_bound(false), is_connected(false), is_zombie(false), sock_type(0)
+Connection::Connection() : fd(NO_FD), is_bound(false), is_connected(false), sock_type(0)
 {
   memset(&addr, 0, sizeof(addr));
 }
@@ -114,13 +114,12 @@ Connection::close()
   is_connected = false;
   is_bound = false;
   // don't close any of the standards
-  if (fd >= 2 && !is_zombie) {
+  if (fd >= 2) {
     int fd_save = fd;
     fd = NO_FD;
     return socketManager.close(fd_save);
   } else {
     fd = NO_FD;
-    is_zombie = false;
     return -EBADF;
   }
 }
@@ -135,11 +134,10 @@ Connection::move(Connection &orig)
   this->is_connected = orig.is_connected;
   this->is_bound = orig.is_bound;
   this->fd = orig.fd;
+  // The target has taken ownership of the file descriptor
+  orig.fd = NO_FD;
   this->addr = orig.addr;
   this->sock_type = orig.sock_type;
-  // The original is now the zombie
-  // The target has taken ownership of the file descriptor
-  orig.is_zombie = true;
 }
 
 static int

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d4a3626/iocore/net/P_Connection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_Connection.h b/iocore/net/P_Connection.h
index 4dd2696..34ff091 100644
--- a/iocore/net/P_Connection.h
+++ b/iocore/net/P_Connection.h
@@ -83,7 +83,6 @@ struct Connection {
   IpEndpoint addr;   ///< Associated address.
   bool is_bound;     ///< Flag for already bound to a local address.
   bool is_connected; ///< Flag for already connected.
-  bool is_zombie;    ///< Flag true if the fd should not be closed
   int sock_type;
 
   /** Create and initialize the socket for this connection.
@@ -142,7 +141,6 @@ struct Connection {
 
   /**
    * Move control of the socket from the argument object orig to the current object.
-   * Orig is marked as zombie, so when it is freed, the socket will not be closed
    */
   void move(Connection &);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d4a3626/iocore/net/UnixNetVConnection.cc
----------------------------------------------------------------------
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 444c6cf..56f38b9 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1205,8 +1205,11 @@ UnixNetVConnection::populate(Connection &con_in, Continuation *c, void *arg)
 
   EThread *t = this_ethread();
   if (ep.start(get_PollDescriptor(t), this, EVENTIO_READ | EVENTIO_WRITE) < 0) {
-    Debug("iocore_net", "populate : Failed to add to epoll list\n");
-    return EVENT_ERROR;
+    // EEXIST should be ok, though it should have been cleared before we got back here
+    if (errno != EEXIST) {
+      Debug("iocore_net", "populate : Failed to add to epoll list\n");
+      return EVENT_ERROR;
+    }
   }
 
   SET_HANDLER(&UnixNetVConnection::mainEvent);
@@ -1385,6 +1388,9 @@ UnixNetVConnection::migrateToCurrentThread(Continuation *cont, EThread *t)
 
   // Do_io_close will signal the VC to be freed on the original thread
   // Since we moved the con context, the fd will not be closed
+  // Go ahead and remove the fd from the original thread's epoll structure, so it is not
+  // processed on two threads simultaneously
+  this->ep.stop();
   this->do_io_close();
 
   // Create new VC:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d4a3626/proxy/http/HttpSessionManager.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc
index 2dc1e43..5527ebb 100644
--- a/proxy/http/HttpSessionManager.cc
+++ b/proxy/http/HttpSessionManager.cc
@@ -297,6 +297,7 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad
                 // Close out to_return, we were't able to get a connection
                 to_return->do_io_close();
                 to_return = NULL;
+                retval = HSM_NOT_FOUND;
               } else {
                 // Keep things from timing out on us
                 new_vc->set_inactivity_timeout(new_vc->get_inactivity_timeout());