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 0b78de5 introduce init function to initailize QUICPollEvent 0b78de5 is described below commit 0b78de52fc25f8d4cd79348f894d6104faa26d17 Author: scw00 <sc...@apache.org> AuthorDate: Tue Feb 13 18:46:37 2018 +0800 introduce init function to initailize QUICPollEvent --- iocore/net/P_QUICNet.h | 17 +++++------------ iocore/net/QUICNet.cc | 31 ++++++++++++++++--------------- iocore/net/QUICPacketHandler.cc | 4 +--- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/iocore/net/P_QUICNet.h b/iocore/net/P_QUICNet.h index 297ddbe..a150cb7 100644 --- a/iocore/net/P_QUICNet.h +++ b/iocore/net/P_QUICNet.h @@ -36,16 +36,10 @@ typedef int (NetHandler::*NetContHandler)(int, void *); void initialize_thread_for_quic_net(EThread *thread); struct QUICPollEvent { - typedef union data_t { - void *ptr; - uint32_t u32; - uint64_t u64; - } data_t; - - void free(); - - data_t data; + QUICConnection *con; UDPPacketInternal *packet; + void init(QUICConnection *con, UDPPacketInternal *packet); + void free(); SLINK(QUICPollEvent, alink); LINK(QUICPollEvent, link); @@ -64,10 +58,9 @@ public: // Atomic Queue to save incoming packets ASLL(QUICPollEvent, alink) inQueue; +private: // Internal Queue to save Long Header Packet - Que(UDPPacketInternal, link) longInQueue; - // Internal Queue to save Short Header Packet - Que(UDPPacketInternal, link) shortInQueue; + Que(UDPPacketInternal, link) _longInQueue; private: void _process_short_header_packet(QUICPollEvent *e, NetHandler *nh); diff --git a/iocore/net/QUICNet.cc b/iocore/net/QUICNet.cc index 68c3bee..ecbc546 100644 --- a/iocore/net/QUICNet.cc +++ b/iocore/net/QUICNet.cc @@ -26,6 +26,13 @@ ClassAllocator<QUICPollEvent> quicPollEventAllocator("quicPollEvent"); void +QUICPollEvent::init(QUICConnection *con, UDPPacketInternal *packet) +{ + this->con = con; + this->packet = packet; +} + +void QUICPollEvent::free() { quicPollEventAllocator.free(this); @@ -52,7 +59,7 @@ QUICPollCont::_process_long_header_packet(QUICPollEvent *e, NetHandler *nh) QUICPacketType ptype; UDPPacketInternal *p = e->packet; // FIXME: VC is nullptr ? - QUICNetVConnection *vc = static_cast<QUICNetVConnection *>(e->data.ptr); + QUICNetVConnection *vc = static_cast<QUICNetVConnection *>(e->con); buf = (uint8_t *)p->getIOBlockChain()->buf(); e->free(); @@ -79,7 +86,7 @@ QUICPollCont::_process_long_header_packet(QUICPollEvent *e, NetHandler *nh) vc->read.triggered = 1; vc->handle_received_packet(p); } else { - longInQueue.push(p); + this->_longInQueue.push(p); } // Push QUICNetVC into nethandler's enabled list @@ -98,7 +105,7 @@ QUICPollCont::_process_short_header_packet(QUICPollEvent *e, NetHandler *nh) { uint8_t *buf; UDPPacketInternal *p = e->packet; - QUICNetVConnection *vc = static_cast<QUICNetVConnection *>(e->data.ptr); + QUICNetVConnection *vc = static_cast<QUICNetVConnection *>(e->con); buf = (uint8_t *)p->getIOBlockChain()->buf(); e->free(); @@ -108,19 +115,13 @@ QUICPollCont::_process_short_header_packet(QUICPollEvent *e, NetHandler *nh) return; } - if (vc) { - vc->read.triggered = 1; - vc->handle_received_packet(p); - } else { - shortInQueue.push(p); - } + vc->read.triggered = 1; + vc->handle_received_packet(p); // Push QUICNetVC into nethandler's enabled list - if (vc != nullptr) { - int isin = ink_atomic_swap(&vc->read.in_enabled_list, 1); - if (!isin) { - nh->read_enable_list.push(vc); - } + int isin = ink_atomic_swap(&vc->read.in_enabled_list, 1); + if (!isin) { + nh->read_enable_list.push(vc); } } @@ -138,7 +139,7 @@ QUICPollCont::pollEvent(int, Event *) NetHandler *nh = get_NetHandler(this->mutex->thread_holding); // Process the ASLL - SList(QUICPollEvent, link) aq(inQueue.popall()); + SList(QUICPollEvent, alink) aq(inQueue.popall()); Queue<QUICPollEvent> result; while ((e = aq.pop())) { result.push(e); diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc index 5eb9966..6bf37e7 100644 --- a/iocore/net/QUICPacketHandler.cc +++ b/iocore/net/QUICPacketHandler.cc @@ -188,9 +188,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet) qe = quicPollEventAllocator.alloc(); - qe->data.ptr = vc; - // should we use dynamic_cast ?? - qe->packet = static_cast<UDPPacketInternal *>(udp_packet); + qe->init(qc, static_cast<UDPPacketInternal *>(udp_packet)); // Push the packet into QUICPollCont get_QUICPollCont(eth)->inQueue.push(qe); } -- To stop receiving notification emails like this one, please contact sc...@apache.org.