gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16709 - gnunet/src/mesh
Date: Tue, 6 Sep 2011 05:13:55 +0200

Author: bartpolot
Date: 2011-09-06 05:13:55 +0200 (Tue, 06 Sep 2011)
New Revision: 16709

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/mesh_api.c
   gnunet/src/mesh/mesh_api_new.c
Log:
Merged changes to destroy_tunnel, removed data pointer in th struct, cancel 
pending traffic on tunnel destroy

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-09-05 21:18:45 UTC (rev 
16708)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-09-06 03:13:55 UTC (rev 
16709)
@@ -450,7 +450,7 @@
 /**
  * Number of applications provided by this peer
  */
-static unsigned int n_applications;
+static unsigned int n_apps;
 
 /**
  * Task to periodically announce provided applications
@@ -768,6 +768,8 @@
 destroy_tunnel (struct MeshTunnel *t)
 {
   struct MeshClient *c;
+  struct MeshQueue *q;
+  struct MeshQueue *qn;
   GNUNET_HashCode hash;
   int r;
 
@@ -787,6 +789,17 @@
   {
     r = GNUNET_SYSERR;
   }
+  GNUNET_CONTAINER_multihashmap_destroy(t->peers);
+  q = t->queue_head;
+  while (NULL != q)
+  {
+    if (NULL != q->data)
+      GNUNET_free(q->data);
+    qn = q->next;
+    GNUNET_free(q);
+    q = qn;
+    /* TODO cancel core transmit ready in case it was active */
+  }
   GNUNET_free (t);
   return r;
 }
@@ -817,7 +830,7 @@
   }
   p = (unsigned int *) &buffer[8];
   GNUNET_PEER_resolve (myid, &id);
-  for (i = 0; i < n_applications; i++)
+  for (i = 0; i < n_apps; i++)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Starting PUT for app %d\n",
                 applications[i]);
@@ -1999,56 +2012,46 @@
   c = clients;
   while (NULL != c)
   {
-    if (c->handle == client)
+    if (c->handle != client)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  " matching client found, cleaning\n");
-      GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, &delete_tunnel_entry,
-                                             c);
-      GNUNET_CONTAINER_multihashmap_destroy (c->tunnels);
-      if (0 != c->app_counter)
-      {                         /* deregister clients applications */
-        for (i = 0; i < c->app_counter; i++)
-        {
-          for (j = 0; j < n_applications; j++)
-          {
-            if (c->apps[i] == applications[j])
-            {
-              if (0 == --applications_rc[j])
-              {
-                applications[j] = applications[n_applications - 1];
-                applications_rc[j] = applications_rc[n_applications - 1];
-                n_applications--;
-                applications =
-                    GNUNET_realloc (applications,
-                                    n_applications *
-                                    sizeof (GNUNET_MESH_ApplicationType));
-                applications_rc =
-                    GNUNET_realloc (applications_rc,
-                                    n_applications * sizeof (unsigned int));
-              }
-              break;
-            }
-          }
-        }
-        GNUNET_free (c->apps);
-        if (0 == n_applications)
-        {
-          GNUNET_SCHEDULER_cancel (announce_applications_task);
-        }
-      }
-      if (0 != c->type_counter)
-        GNUNET_free (c->types);
-      GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c);
-      next = c->next;
-      GNUNET_free (c);
-      c = next;
-    }
-    else
-    {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH:    ... searching\n");
       c = c->next;
+      continue;
     }
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " matching client found, cleaning\n");
+    GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, &delete_tunnel_entry, 
c);
+    GNUNET_CONTAINER_multihashmap_destroy (c->tunnels);
+    if (0 != c->app_counter)
+    {
+      /* deregister clients applications */
+      for (i = 0; i < c->app_counter; i++)
+      {
+       for (j = 0; j < n_apps; j++)
+       {
+         if (c->apps[i] == applications[j] && 0 == --applications_rc[j])
+         {
+           applications[j] = applications[n_apps - 1];
+           GNUNET_array_grow(applications, n_apps, n_apps - 1);
+           n_apps++;
+           applications_rc[j] = applications_rc[n_apps - 1];
+           GNUNET_array_grow(applications_rc, n_apps, n_apps - 1);
+
+         }
+         break;
+       }
+      }
+      GNUNET_free (c->apps);
+      if (0 == n_apps)
+      {
+       GNUNET_SCHEDULER_cancel (announce_applications_task);
+      }
+    }
+    if (0 != c->type_counter)
+      GNUNET_free (c->types);
+    GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c);
+    next = c->next;
+    GNUNET_free (c);
+    c = next;
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH:    done!\n");
@@ -2109,7 +2112,7 @@
   for (i = 0; i < apps; i++)
   {
     known = GNUNET_NO;
-    for (j = 0; i < n_applications; j++)
+    for (j = 0; i < n_apps; j++)
     {
       if (c->apps[i] == applications[j])
       {
@@ -2119,18 +2122,12 @@
       }
     }
     if (!known)
-    {                           /* Register previously unknown application */
-      n_applications++;
-      applications =
-          GNUNET_realloc (applications,
-                          n_applications *
-                          sizeof (GNUNET_MESH_ApplicationType));
-      applications_rc =
-          GNUNET_realloc (applications_rc,
-                          n_applications * sizeof (unsigned int));
-      applications[n_applications - 1] = c->apps[i];
-      applications_rc[n_applications - 1] = 1;
-      if (0 == announce_applications_task)
+    {
+      /* Register previously unknown application */
+      GNUNET_array_append(applications, n_apps, c->apps[i]);
+      n_apps--;
+      GNUNET_array_append(applications_rc, n_apps, 1);
+      if (GNUNET_SCHEDULER_NO_TASK == announce_applications_task)
       {
         announce_applications_task =
             GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME,
@@ -2480,7 +2477,7 @@
 
   /* Do WE have the service? */
   type = ntohl (connect_msg->type);
-  for (i = 0; i < n_applications; i++)
+  for (i = 0; i < n_apps; i++)
   {
     if (applications[i] == type)
     {
@@ -2872,7 +2869,7 @@
 
   applications = NULL;
   applications_rc = NULL;
-  n_applications = 0;
+  n_apps = 0;
   announce_applications_task = 0;
 
   /* Scheduled the task to clean up when shutdown is called */

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-09-05 21:18:45 UTC (rev 16708)
+++ gnunet/src/mesh/mesh_api.c  2011-09-06 03:13:55 UTC (rev 16709)
@@ -921,4 +921,4 @@
   GNUNET_free (handle);
 }
 
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c *
\ No newline at end of file

Modified: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c      2011-09-05 21:18:45 UTC (rev 16708)
+++ gnunet/src/mesh/mesh_api_new.c      2011-09-06 03:13:55 UTC (rev 16709)
@@ -24,6 +24,7 @@
  * - 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:
  * - CONSTANTS
@@ -380,6 +381,13 @@
 
   if (NULL == t)
   {
+    GNUNET_break(0);
+    return;
+  }
+  h = t->mesh;
+  th = h->th_head;
+  while (NULL != th)
+  {
     if (th->tunnel == t)
     {
       aux = th->next;
@@ -401,8 +409,6 @@
       th = th->next;
     }
   }
-  h = t->mesh;
-  /* TODO remove data packets from queue */
   GNUNET_CONTAINER_DLL_remove (h->tunnels_head, h->tunnels_tail, t);
   for (i = 0; i < t->npeers; i++)
   {




reply via email to

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