You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ok...@apache.org on 2017/10/28 01:33:33 UTC

[trafficserver] branch master updated: Optimize: define UnixUDPConnection::inQueue by ASLL macro

This is an automated email from the ASF dual-hosted git repository.

oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 4df19d2  Optimize: define UnixUDPConnection::inQueue by ASLL macro
4df19d2 is described below

commit 4df19d22fa7f9fbd9866684cf2e09a8975d2d704
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Fri Oct 27 14:30:11 2017 +0800

    Optimize: define UnixUDPConnection::inQueue by ASLL macro
---
 iocore/net/P_UnixUDPConnection.h |  7 ++-----
 iocore/net/UnixUDPConnection.cc  | 45 +++++++++++++++++-----------------------
 iocore/net/UnixUDPNet.cc         |  2 +-
 3 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/iocore/net/P_UnixUDPConnection.h b/iocore/net/P_UnixUDPConnection.h
index 6c71d46..29b6d82 100644
--- a/iocore/net/P_UnixUDPConnection.h
+++ b/iocore/net/P_UnixUDPConnection.h
@@ -46,7 +46,8 @@ public:
   LINK(UnixUDPConnection, callback_link);
   SLINK(UnixUDPConnection, newconn_alink);
 
-  InkAtomicList inQueue;
+  // Incoming UDP Packet Queue
+  ASLL(UDPPacketInternal, alink) inQueue;
   int onCallbackQueue;
   Action *callbackAction;
   EThread *ethread;
@@ -64,8 +65,6 @@ TS_INLINE
 UnixUDPConnection::UnixUDPConnection(int the_fd) : onCallbackQueue(0), callbackAction(nullptr), ethread(nullptr), m_errno(0)
 {
   fd = the_fd;
-  UDPPacketInternal p;
-  ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *)&p.alink.next - (char *)&p);
   SET_HANDLER(&UnixUDPConnection::callbackHandler);
 }
 
@@ -78,8 +77,6 @@ UnixUDPConnection::init(int the_fd)
   ethread         = nullptr;
   m_errno         = 0;
 
-  UDPPacketInternal p;
-  ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *)&p.alink.next - (char *)&p);
   SET_HANDLER(&UnixUDPConnection::callbackHandler);
 }
 
diff --git a/iocore/net/UnixUDPConnection.cc b/iocore/net/UnixUDPConnection.cc
index bc5ee95..d372e07 100644
--- a/iocore/net/UnixUDPConnection.cc
+++ b/iocore/net/UnixUDPConnection.cc
@@ -34,20 +34,16 @@
 
 UnixUDPConnection::~UnixUDPConnection()
 {
-  UDPPacketInternal *p = (UDPPacketInternal *)ink_atomiclist_popall(&inQueue);
+  UDPPacketInternal *p = nullptr;
+
+  SList(UDPPacketInternal, alink) aq(inQueue.popall());
 
   if (!tobedestroyed) {
     tobedestroyed = 1;
   }
 
-  if (p) {
-    UDPPacketInternal *pnext = nullptr;
-    while (p) {
-      pnext         = p->alink.next;
-      p->alink.next = nullptr;
-      p->free();
-      p = pnext;
-    }
+  while ((p = aq.pop())) {
+    p->free();
   }
   if (callbackAction) {
     callbackAction->cancel();
@@ -80,23 +76,20 @@ UnixUDPConnection::callbackHandler(int event, void *data)
     Release();
     return EVENT_CONT;
   } else {
-    UDPPacketInternal *p = (UDPPacketInternal *)ink_atomiclist_popall(&inQueue);
-    if (p) {
-      Debug("udpnet", "UDPConnection::callbackHandler");
-      UDPPacketInternal *pnext = nullptr;
-      Queue<UDPPacketInternal> result;
-      while (p) {
-        pnext         = p->alink.next;
-        p->alink.next = nullptr;
-        result.push(p);
-        p = pnext;
-      }
-      if (!shouldDestroy()) {
-        continuation->handleEvent(NET_EVENT_DATAGRAM_READ_READY, &result);
-      } else {
-        while ((p = result.dequeue())) {
-          p->free();
-        }
+    UDPPacketInternal *p = nullptr;
+    SList(UDPPacketInternal, alink) aq(inQueue.popall());
+
+    Debug("udpnet", "UDPConnection::callbackHandler");
+    Queue<UDPPacketInternal> result;
+    while ((p = aq.pop())) {
+      result.push(p);
+    }
+
+    if (!shouldDestroy()) {
+      continuation->handleEvent(NET_EVENT_DATAGRAM_READ_READY, &result);
+    } else {
+      while ((p = result.dequeue())) {
+        p->free();
       }
     }
   }
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index fb40bd4..fdd4076 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -128,7 +128,7 @@ UDPNetProcessorInternal::udp_read_from_net(UDPNetHandler *nh, UDPConnection *xuc
     UDPPacket *p = new_incoming_UDPPacket(ats_ip_sa_cast(&fromaddr), buf, r);
     p->setConnection(uc);
     // queue onto the UDPConnection
-    ink_atomiclist_push(&uc->inQueue, p);
+    uc->inQueue.push((UDPPacketInternal *)p);
     iters++;
   } while (r > 0);
   if (iters >= 1) {

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].