gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32718 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r32718 - gnunet/src/mesh
Date: Fri, 21 Mar 2014 19:44:15 +0100

Author: bartpolot
Date: 2014-03-21 19:44:15 +0100 (Fri, 21 Mar 2014)
New Revision: 32718

Modified:
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_peer.h
Log:
- add message pop from transmission queue

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2014-03-21 18:44:13 UTC (rev 
32717)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2014-03-21 18:44:15 UTC (rev 
32718)
@@ -1220,6 +1220,50 @@
 }
 
 
+/**
+ * Get the first message for a connection and unqueue it.
+ *
+ * @param peer Neighboring peer.
+ * @param c Connection.
+ *
+ * @return First message for this connection.
+ */
+struct GNUNET_MessageHeader *
+GMP_connection_pop (struct MeshPeer *peer, struct MeshConnection *c)
+{
+  struct MeshPeerQueue *q;
+  struct GNUNET_MessageHeader *msg;
+
+  for (q = peer->queue_head; NULL != q; q = q->next)
+  {
+    if (q->c != c)
+      continue;
+    switch (q->type)
+    {
+      case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
+      case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
+      case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
+      case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
+      case GNUNET_MESSAGE_TYPE_MESH_ACK:
+      case GNUNET_MESSAGE_TYPE_MESH_POLL:
+        GMP_queue_destroy (q, GNUNET_YES);
+        continue;
+
+      case GNUNET_MESSAGE_TYPE_MESH_KX:
+      case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
+        msg = (struct GNUNET_MessageHeader *) q->cls;
+        GMP_queue_destroy (q, GNUNET_NO);
+        return msg;
+
+      default:
+        GNUNET_break (0);
+    }
+  }
+
+  return NULL;
+}
+
+
 void
 GMP_queue_unlock (struct MeshPeer *peer, struct MeshConnection *c)
 {

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2014-03-21 18:44:13 UTC (rev 
32717)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2014-03-21 18:44:15 UTC (rev 
32718)
@@ -160,6 +160,17 @@
 void
 GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c);
 
+/**
+ * Get the first message for a connection and unqueue it.
+ *
+ * @param peer Neighboring peer.
+ * @param c Connection.
+ *
+ * @return First message for this connection.
+ */
+struct GNUNET_MessageHeader *
+GMP_connection_pop (struct MeshPeer *peer, struct MeshConnection *c);
+
 void
 GMP_queue_unlock (struct MeshPeer *peer, struct MeshConnection *c);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]