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
commit 35abc38261e68d3d3ba7ffc9730f43f071387ac7 Author: scw00 <[email protected]> AuthorDate: Sat Feb 3 11:04:14 2018 +0800 connect_re processed by nethandler --- cmd/traffic_quic/quic_client.cc | 1 + cmd/traffic_quic/traffic_quic.cc | 2 +- iocore/net/QUICNetProcessor.cc | 24 ++++++++++++++++++++++-- iocore/net/QUICNetVConnection.cc | 34 ++++++++++++++++++++++++++++++++-- iocore/net/UnixUDPNet.cc | 2 +- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/cmd/traffic_quic/quic_client.cc b/cmd/traffic_quic/quic_client.cc index c42410c..d6a7176 100644 --- a/cmd/traffic_quic/quic_client.cc +++ b/cmd/traffic_quic/quic_client.cc @@ -51,6 +51,7 @@ QUICClient::start() NetVCOptions opt; opt.ip_proto = NetVCOptions::USE_UDP; opt.ip_family = info->ai_family; + opt.etype = ET_NET; opt.socket_recv_bufsize = 1048576; opt.socket_send_bufsize = 1048576; diff --git a/cmd/traffic_quic/traffic_quic.cc b/cmd/traffic_quic/traffic_quic.cc index 9749ce1..c46e80f 100644 --- a/cmd/traffic_quic/traffic_quic.cc +++ b/cmd/traffic_quic/traffic_quic.cc @@ -88,7 +88,7 @@ main(int argc, const char **argv) quic_NetProcessor.start(-1, stacksize); QUICClient client(addr, port); - eventProcessor.schedule_in(&client, 1, ET_UDP); + eventProcessor.schedule_in(&client, 1, ET_NET); this_thread()->execute(); } diff --git a/iocore/net/QUICNetProcessor.cc b/iocore/net/QUICNetProcessor.cc index 1064bd7..979af87 100644 --- a/iocore/net/QUICNetProcessor.cc +++ b/iocore/net/QUICNetProcessor.cc @@ -123,6 +123,7 @@ QUICNetProcessor::allocate_vc(EThread *t) } } + vc->ep.syscall = false; return vc; } @@ -181,10 +182,29 @@ QUICNetProcessor::connect_re(Continuation *cont, sockaddr const *remote_addr, Ne vc->mutex = cont->mutex; vc->action_ = cont; - SET_CONTINUATION_HANDLER(vc, &QUICNetVConnection::state_pre_handshake); + SET_CONTINUATION_HANDLER(vc, &QUICNetVConnection::startEvent); vc->start(this->_ssl_ctx); - vc->connectUp(t, NO_FD); + + if (t->is_event_type(opt->etype)) { + MUTEX_TRY_LOCK(lock, cont->mutex, t); + if (lock.is_locked()) { + MUTEX_TRY_LOCK(lock2, get_NetHandler(t)->mutex, t); + if (lock2.is_locked()) { + vc->connectUp(t, NO_FD); + return ACTION_RESULT_DONE; + } + } + } + + // Try to stay on the current thread if it is the right type + if (t->is_event_type(opt->etype)) { + t->schedule_imm(vc); + } else { // Otherwise, pass along to another thread of the right type + eventProcessor.schedule_imm(vc, opt->etype); + } + + // vc->connectUp(t, NO_FD); return ACTION_RESULT_DONE; } diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index ee1d16f..dc8823f 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -70,7 +70,6 @@ QUICNetVConnection::init(QUICConnectionId original_cid, UDPConnection *udp_con, this->_packet_handler = packet_handler; this->_original_quic_connection_id = original_cid; this->_quic_connection_id.randomize(); - this->ep.syscall = false; // PacketHandler for out going connection doesn't have connection table if (ctable) { this->_ctable = ctable; @@ -118,6 +117,8 @@ QUICNetVConnection::acceptEvent(int event, Event *e) free(t); return EVENT_DONE; } + + // FIXME: complete do_io_xxxx instead this->read.enabled = 1; // Handshake callback handler. @@ -141,8 +142,21 @@ QUICNetVConnection::acceptEvent(int event, Event *e) } int -QUICNetVConnection::startEvent(int /*event ATS_UNUSED */, Event *e) +QUICNetVConnection::startEvent(int event, Event *e) { + ink_assert(event == EVENT_IMMEDIATE); + MUTEX_TRY_LOCK(lock, get_NetHandler(e->ethread)->mutex, e->ethread); + if (!lock.is_locked()) { + e->schedule_in(HRTIME_MSECONDS(net_retry_delay)); + return EVENT_CONT; + } + + if (!action_.cancelled) { + this->connectUp(e->ethread, NO_FD); + } else { + this->free(e->ethread); + } + return EVENT_DONE; } @@ -220,6 +234,17 @@ QUICNetVConnection::reenable(VIO *vio) int QUICNetVConnection::connectUp(EThread *t, int fd) { + int res = 0; + NetHandler *nh = get_NetHandler(t); + this->thread = this_ethread(); + ink_assert(nh->mutex->thread_holding == this->thread); + + SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_pre_handshake); + + if ((res = nh->startIO(this)) < 0) { + // FIXME: startIO only return 0 now! what should we do if it failed ? + } + // create stream for handshake QUICErrorUPtr error = this->_stream_manager->create_stream(STREAM_ID_FOR_HANDSHAKE); if (error->cls != QUICErrorClass::NONE) { @@ -228,6 +253,11 @@ QUICNetVConnection::connectUp(EThread *t, int fd) return CONNECT_FAILURE; } + nh->startCop(this); + + // FIXME: complete do_io_xxxx instead + this->read.enabled = 1; + // start QUIC handshake this->_handshake_handler->handleEvent(VC_EVENT_WRITE_READY, nullptr); diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index d5004fe..e3891b8 100644 --- a/iocore/net/UnixUDPNet.cc +++ b/iocore/net/UnixUDPNet.cc @@ -86,7 +86,7 @@ initialize_thread_for_udp_net(EThread *thread) REC_ReadConfigInt32(g_udp_numSendRetries, "proxy.config.udp.send_retries"); g_udp_numSendRetries = g_udp_numSendRetries < 0 ? 0 : g_udp_numSendRetries; - thread->schedule_every(get_UDPPollCont(thread), -UDP_PERIOD); + thread->schedule_every(get_UDPPollCont(thread), -HRTIME_MSECONDS(UDP_PERIOD)); thread->schedule_imm(get_UDPNetHandler(thread)); } -- To stop receiving notification emails like this one, please contact [email protected].
