This is an automated email from the ASF dual-hosted git repository. scw00 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 fa51000 drain all of udp packets and make sure PollCont run before UDPNetHandler fa51000 is described below commit fa5100060a43d95ec8df9c3b67ca9fa3388b141a Author: scw00 <sc...@apache.org> AuthorDate: Tue Feb 13 18:14:13 2018 +0800 drain all of udp packets and make sure PollCont run before UDPNetHandler --- iocore/net/P_UDPNet.h | 3 +- iocore/net/QUICNetVConnection.cc | 111 ++++++++++++++++++++++----------------- iocore/net/UnixUDPNet.cc | 2 +- 3 files changed, 67 insertions(+), 49 deletions(-) diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h index 52de3b8..ae584ab 100644 --- a/iocore/net/P_UDPNet.h +++ b/iocore/net/P_UDPNet.h @@ -59,7 +59,8 @@ extern UDPNetProcessorInternal udpNetInternal; #define SLOT_TIME HRTIME_MSECONDS(SLOT_TIME_MSEC) #define N_SLOTS 2048 -constexpr int UDP_PERIOD = 9; +constexpr int UDP_PERIOD = 9; +constexpr int UDP_NH_PERIOD = UDP_PERIOD + 1; class PacketQueue { diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index dc8823f..372403e 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -513,14 +513,24 @@ QUICNetVConnection::state_handshake(int event, Event *data) switch (event) { case QUIC_EVENT_PACKET_READ_READY: { QUICPacketCreationResult result; - QUICPacketUPtr packet = this->_dequeue_recv_packet(result); - if (result == QUICPacketCreationResult::NOT_READY) { - error = QUICErrorUPtr(new QUICNoError()); - } else if (result == QUICPacketCreationResult::FAILED) { - error = QUICConnectionErrorUPtr(new QUICConnectionError(QUICTransErrorCode::TLS_FATAL_ALERT_GENERATED)); - } else { - error = this->_state_handshake_process_packet(std::move(packet)); - } + do { + QUICPacketUPtr packet = this->_dequeue_recv_packet(result); + if (result == QUICPacketCreationResult::NOT_READY) { + error = QUICErrorUPtr(new QUICNoError()); + } else if (result == QUICPacketCreationResult::FAILED) { + error = QUICConnectionErrorUPtr(new QUICConnectionError(QUICTransErrorCode::TLS_FATAL_ALERT_GENERATED)); + } else if (result == QUICPacketCreationResult::SUCCESS) { + error = this->_state_handshake_process_packet(std::move(packet)); + } + + // if we complete handshake, switch to establish state + if (this->_handshake_handler && this->_handshake_handler->is_completed()) { + this->_switch_to_established_state(); + return this->handleEvent(event, data); + } + + } while (error->cls == QUICErrorClass::NONE && + (result == QUICPacketCreationResult::SUCCESS || result == QUICPacketCreationResult::IGNORED)); break; } case QUIC_EVENT_PACKET_WRITE_READY: { @@ -801,47 +811,51 @@ QUICNetVConnection::_state_common_receive_packet() QUICPacketCreationResult result; // Receive a QUIC packet - QUICPacketUPtr p = this->_dequeue_recv_packet(result); - if (result == QUICPacketCreationResult::FAILED) { - return QUICConnectionErrorUPtr(new QUICConnectionError(QUICTransErrorCode::TLS_FATAL_ALERT_GENERATED)); - } else if (result == QUICPacketCreationResult::NOT_READY) { - return QUICErrorUPtr(new QUICNoError()); - } else if (result == QUICPacketCreationResult::IGNORED) { - return QUICErrorUPtr(new QUICNoError()); - } - - net_activity(this, this_ethread()); + do { + QUICPacketUPtr p = this->_dequeue_recv_packet(result); + if (result == QUICPacketCreationResult::FAILED) { + return QUICConnectionErrorUPtr(new QUICConnectionError(QUICTransErrorCode::TLS_FATAL_ALERT_GENERATED)); + } else if (result == QUICPacketCreationResult::NOT_READY) { + return QUICErrorUPtr(new QUICNoError()); + } else if (result == QUICPacketCreationResult::IGNORED) { + continue; + } - // Check connection migration - if (this->_handshake_handler->is_completed() && p->connection_id() != this->_quic_connection_id) { - for (unsigned int i = 0; i < countof(this->_alt_quic_connection_ids); ++i) { - AltConnectionInfo &info = this->_alt_quic_connection_ids[i]; - if (info.id == p->connection_id()) { - // Migrate connection - // TODO Address Validation - // TODO Adjust expected packet number with a gap computed based on info.seq_num - // TODO Unregister the old connection id (Should we wait for a while?) - this->_quic_connection_id = info.id; - this->_reset_token = info.token; - this->_update_alt_connection_ids(i); - break; + net_activity(this, this_ethread()); + + // Check connection migration + if (this->_handshake_handler->is_completed() && p->connection_id() != this->_quic_connection_id) { + for (unsigned int i = 0; i < countof(this->_alt_quic_connection_ids); ++i) { + AltConnectionInfo &info = this->_alt_quic_connection_ids[i]; + if (info.id == p->connection_id()) { + // Migrate connection + // TODO Address Validation + // TODO Adjust expected packet number with a gap computed based on info.seq_num + // TODO Unregister the old connection id (Should we wait for a while?) + this->_quic_connection_id = info.id; + this->_reset_token = info.token; + this->_update_alt_connection_ids(i); + break; + } } + ink_assert(p->connection_id() == this->_quic_connection_id); } - ink_assert(p->connection_id() == this->_quic_connection_id); - } - // Process the packet - switch (p->type()) { - case QUICPacketType::PROTECTED: - error = this->_state_connection_established_process_packet(std::move(p)); - break; - case QUICPacketType::HANDSHAKE: - // FIXME Just ignore for now but it has to be acked (GitHub#2609) - break; - default: - error = QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::INTERNAL_ERROR)); - break; - } + // Process the packet + switch (p->type()) { + case QUICPacketType::PROTECTED: + error = this->_state_connection_established_process_packet(std::move(p)); + break; + case QUICPacketType::HANDSHAKE: + // FIXME Just ignore for now but it has to be acked (GitHub#2609) + break; + default: + error = QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::INTERNAL_ERROR)); + break; + } + + } while (error->cls == QUICErrorClass::NONE && + (result == QUICPacketCreationResult::SUCCESS || result == QUICPacketCreationResult::IGNORED)); return error; } @@ -1147,8 +1161,11 @@ QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result) quic_packet = this->_packet_factory.create(std::move(pkt), written, this->largest_received_packet_number(), result); if (result == QUICPacketCreationResult::NOT_READY) { QUICConDebug("Not ready to decrypt the packet"); - // Retry later - this->_packet_recv_queue.enqueue(udp_packet); + // FIXME: unordered packet should be buffered and retried + udp_packet->free(); + if (this->_packet_recv_queue.size > 0) { + result = QUICPacketCreationResult::SUCCESS; + } this_ethread()->schedule_in_local(this, HRTIME_MSECONDS(10), QUIC_EVENT_PACKET_READ_READY); } else if (result == QUICPacketCreationResult::IGNORED) { QUICConDebug("Ignore to decrypt the packet"); diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index e3891b8..9c75b4e 100644 --- a/iocore/net/UnixUDPNet.cc +++ b/iocore/net/UnixUDPNet.cc @@ -923,7 +923,7 @@ UDPNetHandler::startNetEvent(int event, Event *e) (void)event; SET_HANDLER((UDPNetContHandler)&UDPNetHandler::mainNetEvent); trigger_event = e; - e->schedule_every(-HRTIME_MSECONDS(UDP_PERIOD)); + e->schedule_every(-HRTIME_MSECONDS(UDP_NH_PERIOD)); return EVENT_CONT; } -- To stop receiving notification emails like this one, please contact sc...@apache.org.