gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16714 - gnunet/src/mesh
Date: Tue, 6 Sep 2011 15:42:26 +0200

Author: bartpolot
Date: 2011-09-06 15:42:26 +0200 (Tue, 06 Sep 2011)
New Revision: 16714

Modified:
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_api_new.c
Log:
Added cancellation of least priority packet on notify transmit ready


Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-09-06 10:28:34 UTC (rev 16713)
+++ gnunet/src/mesh/mesh_api.c  2011-09-06 13:42:26 UTC (rev 16714)
@@ -921,4 +921,4 @@
   GNUNET_free (handle);
 }
 
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */

Modified: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c      2011-09-06 10:28:34 UTC (rev 16713)
+++ gnunet/src/mesh/mesh_api_new.c      2011-09-06 13:42:26 UTC (rev 16714)
@@ -23,7 +23,6 @@
  * TODO:
  * - callbacks to client missing on certain events
  * - processing messages from service is incomplete
- * - Check priorities to cancel traffic data
  * - Use separate message types for tunnel creation s -> c (+pi) and c -> s
  *
  * STRUCTURE:
@@ -1347,12 +1346,42 @@
                                    void *notify_cls)
 {
   struct GNUNET_MESH_TransmitHandle *th;
+  struct GNUNET_MESH_TransmitHandle *least_priority_th;
+  uint32_t least_priority;
   size_t overhead;
 
   GNUNET_assert(NULL != notify);
   if (tunnel->mesh->npackets >= tunnel->mesh->max_queue_size &&
       tunnel->npackets > 0)
-    return NULL;                /* queue full */
+  {
+    /* queue full */
+    if (0 == priority)
+      return NULL;
+    th = tunnel->mesh->th_tail;
+    least_priority = priority;
+    least_priority_th = NULL;
+    while (NULL != th)
+    {
+      if (th->priority < least_priority && th->tunnel->npackets > 1)
+      {
+        least_priority_th = th;
+        least_priority = th->priority;
+      }
+      th = th->prev;
+    }
+    if (NULL == least_priority_th)
+      return NULL;
+    GNUNET_assert(NULL != least_priority_th->notify); /* Cant be a cntrl msg */
+    least_priority_th->notify(notify_cls, 0, NULL);
+    least_priority_th->tunnel->npackets--;
+    tunnel->mesh->npackets--;
+    GNUNET_CONTAINER_DLL_remove(tunnel->mesh->th_head,
+                                tunnel->mesh->th_tail,
+                                least_priority_th);
+    if (GNUNET_SCHEDULER_NO_TASK != least_priority_th->timeout_task)
+      GNUNET_SCHEDULER_cancel(least_priority_th->timeout_task);
+    GNUNET_free(least_priority_th);
+  }
   tunnel->npackets++;
   tunnel->mesh->npackets++;
   th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle));




reply via email to

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