You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2017/08/24 06:10:51 UTC

[trafficserver] branch quic-latest updated: Set inactivity timeout before handshake start

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
     new ed4ff1b  Set inactivity timeout before handshake start
ed4ff1b is described below

commit ed4ff1b7ab89b0176d7559519d493377ecb5f949
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Thu Aug 24 15:09:43 2017 +0900

    Set inactivity timeout before handshake start
---
 iocore/net/P_QUICNetVConnection.h |  4 +++
 iocore/net/QUICNetVConnection.cc  | 59 ++++++++++++++++++++++++++-------------
 2 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index 6d70c00..40a9a40 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -111,6 +111,9 @@ class SSLNextProtocolSet;
  * @brief A NetVConnection for a QUIC network socket
  * @detail
  *
+ * state_pre_handshake()
+ *  |
+ *  v
  * state_handshake()
  *  | READ:
  *  |   _state_handshake_process_initial_client_packet()
@@ -150,6 +153,7 @@ public:
   VIO *do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) override;
   VIO *do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner = false) override;
   int startEvent(int event, Event *e);
+  int state_pre_handshake(int event, Event *data);
   int state_handshake(int event, Event *data);
   int state_connection_established(int event, Event *data);
   int state_connection_closing(int event, Event *data);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 3ec81cb..2588579 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -54,9 +54,10 @@ ClassAllocator<QUICNetVConnection> quicNetVCAllocator("quicNetVCAllocator");
 
 QUICNetVConnection::QUICNetVConnection() : UnixNetVConnection()
 {
-  SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_handshake);
+  SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_pre_handshake);
 }
 
+// XXX This might be called on ET_UDP thread
 void
 QUICNetVConnection::init(UDPConnection *udp_con, QUICPacketHandler *packet_handler)
 {
@@ -340,35 +341,53 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame)
   return error;
 }
 
-// TODO: Timeout by active_timeout / inactive_timeout
+// XXX Setup QUICNetVConnection on regular EThread.
+// QUICNetVConnection::init() and QUICNetVConnection::start() might be called on ET_UDP EThread.
 int
-QUICNetVConnection::state_handshake(int event, Event *data)
+QUICNetVConnection::state_pre_handshake(int event, Event *data)
 {
-  QUICError error;
-
-  if (!thread) {
-    thread = this_ethread();
+  if (!this->thread) {
+    this->thread = this_ethread();
   }
 
-  if (!nh) {
-    nh = get_NetHandler(this_ethread());
+  if (!this->nh) {
+    this->nh = get_NetHandler(this_ethread());
   }
 
+  // FIXME: Should be accept_no_activity_timeout?
+  QUICConfig::scoped_config params;
+
+  this->set_inactivity_timeout(HRTIME_SECONDS(params->no_activity_timeout_in()));
+  this->add_to_active_queue();
+
+  SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_handshake);
+  return this->handleEvent(event, data);
+}
+
+// TODO: Timeout by active_timeout
+int
+QUICNetVConnection::state_handshake(int event, Event *data)
+{
+  QUICError error;
+
   switch (event) {
   case QUIC_EVENT_PACKET_READ_READY: {
     std::unique_ptr<const QUICPacket> p = std::unique_ptr<const QUICPacket>(this->_packet_recv_queue.dequeue());
     net_activity(this, this_ethread());
 
     switch (p->type()) {
-    case QUICPacketType::CLIENT_INITIAL:
+    case QUICPacketType::CLIENT_INITIAL: {
       error = this->_state_handshake_process_initial_client_packet(std::move(p));
       break;
-    case QUICPacketType::CLIENT_CLEARTEXT:
+    }
+    case QUICPacketType::CLIENT_CLEARTEXT: {
       error = this->_state_handshake_process_client_cleartext_packet(std::move(p));
       break;
-    case QUICPacketType::ZERO_RTT_PROTECTED:
+    }
+    case QUICPacketType::ZERO_RTT_PROTECTED: {
       error = this->_state_handshake_process_zero_rtt_protected_packet(std::move(p));
       break;
+    }
     default:
       error = QUICError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::QUIC_INTERNAL_ERROR);
       break;
@@ -380,6 +399,15 @@ QUICNetVConnection::state_handshake(int event, Event *data)
     error = this->_state_common_send_packet();
     break;
   }
+  case EVENT_IMMEDIATE: {
+    // Start Implicit Shutdown. Because of no network activity for the duration of the idle timeout.
+    this->remove_from_active_queue();
+    this->close({});
+
+    // TODO: signal VC_EVENT_ACTIVE_TIMEOUT/VC_EVENT_INACTIVITY_TIMEOUT to application
+    break;
+  }
+
   default:
     DebugQUICCon("Unexpected event: %u", event);
   }
@@ -395,13 +423,6 @@ QUICNetVConnection::state_handshake(int event, Event *data)
     this->_application_map.set_default(this->_create_application());
     DebugQUICCon("Enter state_connection_established");
     SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_connection_established);
-
-    QUICConfig::scoped_config params;
-
-    // TODO:  use idle_timeout from negotiated Transport Prameters
-    ink_hrtime idle_timeout = HRTIME_SECONDS(params->no_activity_timeout_in());
-    this->set_inactivity_timeout(idle_timeout);
-    this->add_to_active_queue();
   }
 
   return EVENT_CONT;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].