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 04dfc12f56e034d041789a3d2ebbbdf069a10f44 Author: scw00 <[email protected]> AuthorDate: Sat Feb 3 08:59:27 2018 +0800 Add syscall into EventIO for qvc to avoid system call --- iocore/net/P_UDPNet.h | 2 ++ iocore/net/P_UnixNet.h | 33 ++++++++++++++++----------------- iocore/net/QUICNet.cc | 2 +- iocore/net/QUICNetProcessor.cc | 2 ++ iocore/net/QUICNetVConnection.cc | 1 + iocore/net/UnixUDPNet.cc | 4 ++-- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h index 599b6af..52de3b8 100644 --- a/iocore/net/P_UDPNet.h +++ b/iocore/net/P_UDPNet.h @@ -59,6 +59,8 @@ extern UDPNetProcessorInternal udpNetInternal; #define SLOT_TIME HRTIME_MSECONDS(SLOT_TIME_MSEC) #define N_SLOTS 2048 +constexpr int UDP_PERIOD = 9; + class PacketQueue { public: diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h index 6b9ad5f..ab45b66 100644 --- a/iocore/net/P_UnixNet.h +++ b/iocore/net/P_UnixNet.h @@ -83,6 +83,7 @@ struct EventIO { int events = 0; #endif EventLoop event_loop = nullptr; + bool syscall = true; int type = 0; union { Continuation *c; @@ -575,15 +576,8 @@ EventIO::start(EventLoop l, NetAccept *vc, int events) TS_INLINE int EventIO::start(EventLoop l, UnixNetVConnection *vc, int events) { - int r; type = EVENTIO_READWRITE_VC; - r = start(l, vc->con.fd, (Continuation *)vc, events); - if (r < 0 && vc->options.ip_proto == NetVCOptions::USE_UDP) { - // Hack for QUICNetVC - return 0; - } else { - return r; - } + return start(l, vc->con.fd, (Continuation *)vc, events); } TS_INLINE int EventIO::start(EventLoop l, UnixUDPConnection *vc, int events) @@ -594,6 +588,10 @@ EventIO::start(EventLoop l, UnixUDPConnection *vc, int events) TS_INLINE int EventIO::close() { + if (!this->syscall) { + return 0; + } + stop(); switch (type) { default: @@ -615,15 +613,13 @@ EventIO::close() TS_INLINE int EventIO::start(EventLoop l, int afd, Continuation *c, int e) { + if (!this->syscall) { + return 0; + } + data.c = c; fd = afd; event_loop = l; - // Hack for QUICNetVC: - // quicnetvc->con.fd == NO_FD - // quicnetvc->options.ip_proto == NetVCOptions::USE_UDP - if (afd == NO_FD) { - return -1; - } #if TS_USE_EPOLL struct epoll_event ev; memset(&ev, 0, sizeof(ev)); @@ -656,9 +652,10 @@ EventIO::start(EventLoop l, int afd, Continuation *c, int e) TS_INLINE int EventIO::modify(int e) { - if (fd == NO_FD) { + if (!this->syscall) { return 0; } + ink_assert(event_loop); #if TS_USE_EPOLL && !defined(USE_EDGE_TRIGGER) struct epoll_event ev; @@ -738,9 +735,10 @@ EventIO::modify(int e) TS_INLINE int EventIO::refresh(int e) { - if (fd == NO_FD) { + if (!this->syscall) { return 0; } + ink_assert(event_loop); #if TS_USE_KQUEUE && defined(USE_EDGE_TRIGGER) e = e & events; @@ -782,9 +780,10 @@ EventIO::refresh(int e) TS_INLINE int EventIO::stop() { - if (fd == NO_FD) { + if (!this->syscall) { return 0; } + if (event_loop) { int retval = 0; #if TS_USE_EPOLL diff --git a/iocore/net/QUICNet.cc b/iocore/net/QUICNet.cc index 3e730af..33763b8 100644 --- a/iocore/net/QUICNet.cc +++ b/iocore/net/QUICNet.cc @@ -154,5 +154,5 @@ initialize_thread_for_quic_net(EThread *thread) new ((ink_dummy_for_new *)quicpc) QUICPollCont(thread->mutex, nh); - thread->schedule_every(quicpc, -9); + thread->schedule_every(quicpc, -UDP_PERIOD); } diff --git a/iocore/net/QUICNetProcessor.cc b/iocore/net/QUICNetProcessor.cc index da372c6..1064bd7 100644 --- a/iocore/net/QUICNetProcessor.cc +++ b/iocore/net/QUICNetProcessor.cc @@ -181,6 +181,8 @@ 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); + vc->start(this->_ssl_ctx); vc->connectUp(t, NO_FD); diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index e71c109..ee1d16f 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -70,6 +70,7 @@ 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; diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index 5a68206..d5004fe 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), -9); + thread->schedule_every(get_UDPPollCont(thread), -UDP_PERIOD); thread->schedule_imm(get_UDPNetHandler(thread)); } @@ -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(9)); + e->schedule_every(-HRTIME_MSECONDS(UDP_PERIOD)); return EVENT_CONT; } -- To stop receiving notification emails like this one, please contact [email protected].
