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 2018/01/15 08:35:16 UTC

[trafficserver] branch quic-latest updated: Switch to close state on receiving a closing frame on draining state or closing state

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

maskit 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 54a24da  Switch to close state on receiving a closing frame on draining state or closing state
54a24da is described below

commit 54a24da4aaee498acb955a4a54409fb5d859489e
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Mon Jan 15 17:34:23 2018 +0900

    Switch to close state on receiving a closing frame on draining state or closing state
---
 iocore/net/QUICNetVConnection.cc | 45 ++++++++++++++--------------------------
 1 file changed, 16 insertions(+), 29 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 582d372..2f20b94 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -360,8 +360,13 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame)
     break;
   case QUICFrameType::APPLICATION_CLOSE:
   case QUICFrameType::CONNECTION_CLOSE:
-    this->_switch_to_draining_state(QUICConnectionErrorUPtr(
-      new QUICConnectionError(std::static_pointer_cast<const QUICApplicationCloseFrame>(frame)->error_code())));
+    if (this->handler == reinterpret_cast<NetVConnHandler>(&QUICNetVConnection::state_connection_closing) ||
+        this->handler == reinterpret_cast<NetVConnHandler>(&QUICNetVConnection::state_connection_draining)) {
+      this->_switch_to_close_state();
+    } else {
+      this->_switch_to_draining_state(QUICConnectionErrorUPtr(
+        new QUICConnectionError(std::static_pointer_cast<const QUICApplicationCloseFrame>(frame)->error_code())));
+    }
     break;
   default:
     QUICConDebug("Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
@@ -479,36 +484,27 @@ int
 QUICNetVConnection::state_connection_closing(int event, Event *data)
 {
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-  bool can_switch_to_close_state = false;
 
   QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
   switch (event) {
   case QUIC_EVENT_PACKET_READ_READY:
-    if (this->_handshake_handler && this->_handshake_handler->is_completed()) {
-      error = this->_state_common_receive_packet();
-      // TODO receiving a closing frame is sufficient confirmation
-      // can_switch_to_close_state = true;
-    } else {
-      // FIXME Just ignore for now but it has to be acked (GitHub#2609)
-    }
+    error = this->_state_common_receive_packet();
     break;
   case QUIC_EVENT_PACKET_WRITE_READY:
     this->_close_packet_write_ready(data);
-    // FIXME Only closing frames are allowed to send
+    // FIXME During the closing period, an endpoint that sends a
+    // closing frame SHOULD respond to any packet that it receives with
+    // another packet containing a closing frame.
     this->_state_common_send_packet();
     break;
   case QUIC_EVENT_CLOSING_TIMEOUT:
     this->_close_closing_timeout(data);
-    can_switch_to_close_state = true;
+    this->_switch_to_close_state();
     break;
   default:
     QUICConDebug("Unexpected event: %s", QUICDebugNames::quic_event(event));
   }
 
-  if (can_switch_to_close_state) {
-    this->_switch_to_close_state();
-  }
-
   return EVENT_DONE;
 }
 
@@ -516,18 +512,11 @@ int
 QUICNetVConnection::state_connection_draining(int event, Event *data)
 {
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-  bool can_switch_to_close_state = false;
 
   QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
   switch (event) {
   case QUIC_EVENT_PACKET_READ_READY:
-    if (this->_handshake_handler && this->_handshake_handler->is_completed()) {
-      error = this->_state_common_receive_packet();
-      // TODO receiving a closing frame is sufficient confirmation
-      // can_switch_to_close_state = true;
-    } else {
-      // FIXME Just ignore for now but it has to be acked (GitHub#2609)
-    }
+    error = this->_state_common_receive_packet();
     break;
   case QUIC_EVENT_PACKET_WRITE_READY:
     // Do not send any packets in this state.
@@ -536,16 +525,12 @@ QUICNetVConnection::state_connection_draining(int event, Event *data)
     break;
   case QUIC_EVENT_CLOSING_TIMEOUT:
     this->_close_closing_timeout(data);
-    can_switch_to_close_state = true;
+    this->_switch_to_close_state();
     break;
   default:
     QUICConDebug("Unexpected event: %s", QUICDebugNames::quic_event(event));
   }
 
-  if (can_switch_to_close_state) {
-    this->_switch_to_close_state();
-  }
-
   return EVENT_DONE;
 }
 
@@ -1188,6 +1173,8 @@ QUICNetVConnection::_switch_to_draining_state(QUICConnectionErrorUPtr error)
 void
 QUICNetVConnection::_switch_to_close_state()
 {
+  this->_unschedule_closing_timeout();
+
   if (this->_complete_handshake_if_possible() != 0) {
     QUICConDebug("Switching state without handshake completion");
   }

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