TS-1067 Replace G_inkPipeInfo with a member variable in UDPQueue
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a544466d Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a544466d Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a544466d Branch: refs/heads/3.3.x Commit: a544466d3db83d221df45442a297e46be8b14fd1 Parents: 20dacb0 Author: Leif Hedstrom <zw...@apache.org> Authored: Wed Mar 27 10:13:09 2013 -0700 Committer: Leif Hedstrom <zw...@apache.org> Committed: Tue Apr 2 13:53:42 2013 -0600 ---------------------------------------------------------------------- iocore/net/I_UDPNet.h | 10 +---- iocore/net/P_UDPNet.h | 74 ++++++++++++++++++++-------------------- iocore/net/UnixUDPNet.cc | 16 ++++----- 3 files changed, 46 insertions(+), 54 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a544466d/iocore/net/I_UDPNet.h ---------------------------------------------------------------------- diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h index 847e2c1..159e93b 100644 --- a/iocore/net/I_UDPNet.h +++ b/iocore/net/I_UDPNet.h @@ -49,14 +49,8 @@ public: //this function was interanal intially.. this is required for public and //interface probably should change. - bool CreateUDPSocket( - int *resfd, - sockaddr const* remote_addr, - sockaddr* local_addr, - int* local_addr_len, - Action ** status, - int send_bufsize = 0, int recv_bufsize = 0 - ); + bool CreateUDPSocket(int *resfd, sockaddr const* remote_addr, sockaddr* local_addr, int* local_addr_len, + Action ** status, int send_bufsize = 0, int recv_bufsize = 0); /** create UDPConnection http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a544466d/iocore/net/P_UDPNet.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h index 9cba1b3..e695383 100644 --- a/iocore/net/P_UDPNet.h +++ b/iocore/net/P_UDPNet.h @@ -56,29 +56,7 @@ struct UDPNetProcessorInternal : public UDPNetProcessor extern UDPNetProcessorInternal udpNetInternal; -class PacketQueue; -class UDPQueue -{ -public: - - void service(UDPNetHandler *); - - void SendPackets(); - void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen); - - // Interface exported to the outside world - void send(UDPPacket * p); - - InkAtomicList atomicQueue; - ink_hrtime last_report; - ink_hrtime last_service; - int packets; - int added; - - UDPQueue(); - ~UDPQueue(); -}; // 20 ms slots; 2048 slots => 40 sec. into the future #define SLOT_TIME_MSEC 20 @@ -87,16 +65,16 @@ public: class PacketQueue { -public: - PacketQueue() - : nPackets(0), now_slot(0) - { - lastPullLongTermQ = 0; - init(); - } + public: + PacketQueue() + : nPackets(0), now_slot(0) + { + lastPullLongTermQ = 0; + init(); + } virtual ~ PacketQueue() - { } + { } int nPackets; ink_hrtime lastPullLongTermQ; @@ -250,7 +228,7 @@ public: now_slot = s; } -private: + private: void remove(UDPPacketInternal * e) { nPackets--; @@ -259,7 +237,7 @@ private: bucket[e->in_heap].remove(e); } -public: + public: UDPPacketInternal *dequeue_ready(ink_hrtime t) { (void) t; @@ -289,11 +267,37 @@ public: return HRTIME_FOREVER; } -private: + private: void kill_cancelled_events() { } }; + +class UDPQueue +{ + PacketQueue pipeInfo; + ink_hrtime last_report; + ink_hrtime last_service; + int packets; + int added; + + +public: + InkAtomicList atomicQueue; + + void service(UDPNetHandler *); + + void SendPackets(); + void SendUDPPacket(UDPPacketInternal * p, int32_t pktLen); + + // Interface exported to the outside world + void send(UDPPacket * p); + + UDPQueue(); + ~UDPQueue(); +}; + + void initialize_thread_for_udp_net(EThread * thread); struct UDPNetHandler: public Continuation @@ -334,8 +338,4 @@ get_UDPNetHandler(EThread * t) return (UDPNetHandler *)ETHREAD_GET_PTR(t, udpNetInternal.udpNetHandler_offset); } -// All of this stuff is for UDP egress b/w management -// ToDo: It'd be nice to eliminate this entirely.... But we have no working use of UDPNet afaik. /leif -extern PacketQueue G_inkPipeInfo; - #endif //__P_UDPNET_H_ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a544466d/iocore/net/UnixUDPNet.cc ---------------------------------------------------------------------- diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index 446e349..ca428cb 100644 --- a/iocore/net/UnixUDPNet.cc +++ b/iocore/net/UnixUDPNet.cc @@ -58,8 +58,6 @@ int32_t g_udp_numSendRetries; // Public functions // See header for documentation // -PacketQueue G_inkPipeInfo; - int G_bwGrapherFd; sockaddr_in6 G_bwGrapherLoc; @@ -677,11 +675,11 @@ UDPQueue::service(UDPNetHandler * nh) p->conn->lastPktStartTime = pktSendStartTime; p->delivery_time = pktSendStartTime; - G_inkPipeInfo.addPacket(p, now); + pipeInfo.addPacket(p, now); } } - G_inkPipeInfo.advanceNow(now); + pipeInfo.advanceNow(now); SendPackets(); timeSpent = ink_hrtime_to_msec(now - last_report); @@ -715,8 +713,8 @@ sendPackets: send_threshold_time = now + SLOT_TIME; bytesThisPipe = (int32_t)bytesThisSlot; - while ((bytesThisPipe > 0) && (G_inkPipeInfo.firstPacket(send_threshold_time))) { - p = G_inkPipeInfo.getFirstPacket(); + while ((bytesThisPipe > 0) && (pipeInfo.firstPacket(send_threshold_time))) { + p = pipeInfo.getFirstPacket(); pktLen = p->getPktLength(); if (p->conn->shouldDestroy()) @@ -740,14 +738,14 @@ sendPackets: if ((bytesThisSlot > 0) && sentOne) { // redistribute the slack... now = ink_get_hrtime_internal(); - if (G_inkPipeInfo.firstPacket(now) == NULL) { - G_inkPipeInfo.advanceNow(now); + if (pipeInfo.firstPacket(now) == NULL) { + pipeInfo.advanceNow(now); } goto sendPackets; } if ((g_udp_periodicFreeCancelledPkts) && (now - lastCleanupTime > ink_hrtime_from_sec(g_udp_periodicFreeCancelledPkts))) { - G_inkPipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots); + pipeInfo.FreeCancelledPackets(g_udp_periodicCleanupSlots); lastCleanupTime = now; } }