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 fc88686 Reduce duplicate code
fc88686 is described below
commit fc88686b10f94b33a4cdc5976f81b417889d2020
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Wed Feb 27 15:21:47 2019 +0900
Reduce duplicate code
---
iocore/net/P_QUICNetVConnection.h | 2 +
iocore/net/QUICNetVConnection.cc | 86 ++++++++++++++++-----------------------
2 files changed, 37 insertions(+), 51 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h
b/iocore/net/P_QUICNetVConnection.h
index 1050902..f8a9132 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -304,6 +304,7 @@ private:
void _close_path_validation_timeout(Event *data);
Event *_path_validation_timeout = nullptr;
+ void _schedule_ack_manager_periodic(ink_hrtime interval);
void _unschedule_ack_manager_periodic();
Event *_ack_manager_periodic = nullptr;
@@ -357,6 +358,7 @@ private:
bool _application_started = false;
void _start_application();
+ void _handle_periodic_ack_event();
void _handle_path_validation_timeout(Event *data);
void _handle_idle_timeout();
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 33f0e2c..d16542d 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -251,7 +251,7 @@ QUICNetVConnection::start()
this->_hs_protocol =
this->_setup_handshake_protocol(params->server_ssl_ctx());
this->_handshake_handler = new QUICHandshake(this, this->_hs_protocol,
this->_reset_token, params->stateless_retry());
this->_ack_frame_manager.set_max_ack_delay(params->max_ack_delay_in());
- this->_ack_manager_periodic = this->thread->schedule_every(this,
params->max_ack_delay_in(), QUIC_EVENT_ACK_PERIODIC);
+ this->_schedule_ack_manager_periodic(params->max_ack_delay_in());
} else {
this->_pp_key_info.set_context(QUICPacketProtectionKeyInfo::Context::CLIENT);
this->_ack_frame_manager.set_ack_delay_exponent(params->ack_delay_exponent_out());
@@ -260,7 +260,7 @@ QUICNetVConnection::start()
this->_handshake_handler->start(&this->_packet_factory,
params->vn_exercise_enabled());
this->_handshake_handler->do_handshake();
this->_ack_frame_manager.set_max_ack_delay(params->max_ack_delay_out());
- this->_ack_manager_periodic = this->thread->schedule_every(this,
params->max_ack_delay_out(), QUIC_EVENT_ACK_PERIODIC);
+ this->_schedule_ack_manager_periodic(params->max_ack_delay_out());
}
this->_application_map = new QUICApplicationMap();
@@ -629,37 +629,16 @@ QUICNetVConnection::state_handshake(int event, Event
*data)
} while (error == nullptr && (result == QUICPacketCreationResult::SUCCESS
|| result == QUICPacketCreationResult::IGNORED));
break;
}
- case QUIC_EVENT_ACK_PERIODIC: {
- ink_hrtime timestamp = Thread::get_hrtime();
- bool need_schedule = false;
- for (auto level : QUIC_ENCRYPTION_LEVELS) {
- if (this->_ack_frame_manager.will_generate_frame(level, timestamp)) {
- need_schedule = true;
- break;
- }
- }
-
- if (!need_schedule) {
- break;
- }
-
- // we have ack to send
- // FIXME: should sent depend on socket event.
- this->_schedule_packet_write_ready();
+ case QUIC_EVENT_ACK_PERIODIC:
+ this->_handle_periodic_ack_event();
break;
- }
-
- case QUIC_EVENT_PACKET_WRITE_READY: {
+ case QUIC_EVENT_PACKET_WRITE_READY:
this->_close_packet_write_ready(data);
-
// TODO: support RETRY packet
error = this->_state_common_send_packet();
-
// Reschedule WRITE_READY
this->_schedule_packet_write_ready(true);
-
break;
- }
case QUIC_EVENT_PATH_VALIDATION_TIMEOUT:
this->_handle_path_validation_timeout(data);
break;
@@ -684,45 +663,25 @@ QUICNetVConnection::state_connection_established(int
event, Event *data)
SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
QUICConnectionErrorUPtr error = nullptr;
switch (event) {
- case QUIC_EVENT_PACKET_READ_READY: {
+ case QUIC_EVENT_PACKET_READ_READY:
error = this->_state_connection_established_receive_packet();
break;
- }
- case QUIC_EVENT_ACK_PERIODIC: {
- ink_hrtime timestamp = Thread::get_hrtime();
- bool need_schedule = false;
- for (auto level : QUIC_ENCRYPTION_LEVELS) {
- if (this->_ack_frame_manager.will_generate_frame(level, timestamp)) {
- need_schedule = true;
- break;
- }
- }
-
- if (!need_schedule) {
- break;
- }
-
- // we have ack to send
- // FIXME: should sent depend on socket event.
- this->_schedule_packet_write_ready();
+ case QUIC_EVENT_ACK_PERIODIC:
+ this->_handle_periodic_ack_event();
break;
- }
-
- case QUIC_EVENT_PACKET_WRITE_READY: {
+ case QUIC_EVENT_PACKET_WRITE_READY:
this->_close_packet_write_ready(data);
error = this->_state_common_send_packet();
// Reschedule WRITE_READY
this->_schedule_packet_write_ready(true);
break;
- }
case QUIC_EVENT_PATH_VALIDATION_TIMEOUT:
this->_handle_path_validation_timeout(data);
break;
- case EVENT_IMMEDIATE: {
+ case EVENT_IMMEDIATE:
// Start Immediate Close because of Idle Timeout
this->_handle_idle_timeout();
break;
- }
default:
QUICConDebug("Unexpected event: %s (%d)",
QUICDebugNames::quic_event(event), event);
}
@@ -1729,6 +1688,12 @@ QUICNetVConnection::_unschedule_closing_timeout()
}
void
+QUICNetVConnection::_schedule_ack_manager_periodic(ink_hrtime interval)
+{
+ this->_ack_manager_periodic = this->thread->schedule_every(this, interval,
QUIC_EVENT_ACK_PERIODIC);
+}
+
+void
QUICNetVConnection::_unschedule_ack_manager_periodic()
{
if (this->_ack_manager_periodic) {
@@ -2134,6 +2099,25 @@
QUICNetVConnection::_state_connection_established_initiate_connection_migration(
}
void
+QUICNetVConnection::_handle_periodic_ack_event()
+{
+ ink_hrtime timestamp = Thread::get_hrtime();
+ bool need_schedule = false;
+ for (auto level : QUIC_ENCRYPTION_LEVELS) {
+ if (this->_ack_frame_manager.will_generate_frame(level, timestamp)) {
+ need_schedule = true;
+ break;
+ }
+ }
+
+ if (need_schedule) {
+ // we have ack to send
+ // FIXME: should sent depend on socket event.
+ this->_schedule_packet_write_ready();
+ }
+}
+
+void
QUICNetVConnection::_handle_path_validation_timeout(Event *data)
{
this->_close_path_validation_timeout(data);