gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17262 - gnunet/src/mesh
Date: Thu, 6 Oct 2011 19:38:50 +0200

Author: bartpolot
Date: 2011-10-06 19:38:50 +0200 (Thu, 06 Oct 2011)
New Revision: 17262

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
   gnunet/src/mesh/test_mesh_small.conf
   gnunet/src/mesh/test_mesh_small_unicast.c
Log:
Stop all DHT get requests before disconnecting

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-10-06 16:46:13 UTC (rev 
17261)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-10-06 17:38:50 UTC (rev 
17262)
@@ -1187,6 +1187,9 @@
     /* TODO cancel core transmit ready in case it was active */
   }
   tree_destroy(t->tree);
+  if (NULL != t->dht_get_type)
+    GNUNET_DHT_get_stop(t->dht_get_type);
+  t->dht_get_type = NULL;
   GNUNET_free (t);
   return r;
 }
@@ -3240,6 +3243,24 @@
 
/******************************************************************************/
 
 /**
+ * Iterator over hash map entries.
+ *
+ * @param cls closure
+ * @param key current key code
+ * @param value value in the hash map
+ * @return GNUNET_YES if we should continue to
+ *         iterate,
+ *         GNUNET_NO if not.
+ */
+int
+shutdown_tunnel (void *cls, const GNUNET_HashCode * key, void *value)
+{
+  struct MeshTunnel *t = value;
+  tunnel_destroy(t);
+  return GNUNET_YES;
+}
+
+/**
  * Task run during shutdown.
  *
  * @param cls unused
@@ -3255,6 +3276,7 @@
     GNUNET_CORE_disconnect (core_handle);
     core_handle = NULL;
   }
+  GNUNET_CONTAINER_multihashmap_iterate(tunnels, &shutdown_tunnel, NULL);
   if (dht_handle != NULL)
   {
     GNUNET_DHT_disconnect (dht_handle);

Modified: gnunet/src/mesh/test_mesh_small.conf
===================================================================
--- gnunet/src/mesh/test_mesh_small.conf        2011-10-06 16:46:13 UTC (rev 
17261)
+++ gnunet/src/mesh/test_mesh_small.conf        2011-10-06 17:38:50 UTC (rev 
17262)
@@ -49,6 +49,10 @@
 [mesh]
 PORT = 10005
 DEBUG=YES
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+# PREFIX = valgrind --leak-check=full
+# PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
 
 [testing]
 NUM_PEERS = 16

Modified: gnunet/src/mesh/test_mesh_small_unicast.c
===================================================================
--- gnunet/src/mesh/test_mesh_small_unicast.c   2011-10-06 16:46:13 UTC (rev 
17261)
+++ gnunet/src/mesh/test_mesh_small_unicast.c   2011-10-06 17:38:50 UTC (rev 
17262)
@@ -122,16 +122,18 @@
 
 static char *data_filename;
 
-struct GNUNET_TESTING_Daemon *d1;
+static struct GNUNET_TESTING_Daemon *d1;
 
-struct GNUNET_TESTING_Daemon *d2;
+static struct GNUNET_TESTING_Daemon *d2;
 
-struct GNUNET_MESH_Handle *h1;
+static struct GNUNET_MESH_Handle *h1;
 
-struct GNUNET_MESH_Handle *h2;
+static struct GNUNET_MESH_Handle *h2;
 
-struct GNUNET_MESH_Tunnel *t;
+static struct GNUNET_MESH_Tunnel *t;
 
+static uint16_t mesh_peers[16];
+
 /**
  * Check whether peers successfully shut down.
  */
@@ -289,6 +291,53 @@
 
 
 /**
+ * Prototype of a callback function indicating that two peers
+ * are currently connected.
+ *
+ * @param cls closure
+ * @param first peer id for first daemon
+ * @param second peer id for the second daemon
+ * @param distance distance between the connected peers
+ * @param emsg error message (NULL on success)
+ */
+void
+topo_cb (void *cls,
+         const struct GNUNET_PeerIdentity* first,
+         const struct GNUNET_PeerIdentity* second,
+         const char *emsg)
+{
+  GNUNET_PEER_Id p1;
+  GNUNET_PEER_Id p2;
+  struct GNUNET_PeerIdentity id;
+
+  GNUNET_PEER_resolve(1, &id);
+  p1 = GNUNET_PEER_search(first);
+  if (p1 == 1)
+  {
+    p2 = GNUNET_PEER_search(second);
+    GNUNET_assert(p2 < num_peers);
+    if (0 == p2) return;
+    mesh_peers[p2]++;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: %s IS a neighbor\n",
+                GNUNET_i2s(second));
+    return;
+  }
+  p1 = GNUNET_PEER_search(second);
+  if (p1 == 1)
+  {
+    p2 = GNUNET_PEER_search(first);
+    GNUNET_assert(p2 < num_peers);
+    if (0 == p2) return;
+    mesh_peers[p2]++;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test: %s IS a neighbor\n",
+                GNUNET_i2s(first));
+    return;
+  }
+}
+
+/**
  * connect_mesh_service: connect to the mesh service of one of the peers
  *
  */
@@ -296,20 +345,26 @@
 connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_MESH_ApplicationType app;
+  unsigned int i;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connect_mesh_service\n");
 
-  d1 = GNUNET_TESTING_daemon_get (pg, 1);
-  d2 = GNUNET_TESTING_daemon_get (pg, 3);
+  for (i = 1; i < num_peers; i++)
+    if (mesh_peers[i] == 0)
+      break;
+  GNUNET_assert (i < num_peers);
+  d2 = GNUNET_TESTING_daemon_get (pg, i);
   app = (GNUNET_MESH_ApplicationType) 0;
 
 #if VERBOSE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: connecting to mesh service of peer %s\n",
-              GNUNET_i2s (&d1->id));
+              "test: connecting to mesh service of peer %s (%u)\n",
+              GNUNET_i2s (&d1->id),
+              mesh_peers[0]);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: connecting to mesh service of peer %s\n",
-              GNUNET_i2s (&d2->id));
+              "test: connecting to mesh service of peer %s (%u)\n",
+              GNUNET_i2s (&d2->id),
+              i);
 #endif
   h1 = GNUNET_MESH_connect (d1->cfg,
                             10,
@@ -352,6 +407,7 @@
 {
   char *buf;
   int buf_len;
+  unsigned int i;
 
   if (emsg != NULL)
   {
@@ -382,10 +438,20 @@
     GNUNET_free (buf);
   }
   peers_running = GNUNET_TESTING_daemons_running (pg);
+  for (i = 0; i < num_peers; i++)
+  {
+    d1 = GNUNET_TESTING_daemon_get (pg, i);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "test:   %u: %s\n",
+                GNUNET_PEER_intern(&d1->id),
+                GNUNET_i2s (&d1->id));
+    mesh_peers[i] = 0;
+  }
+  GNUNET_TESTING_get_topology(pg, &topo_cb, NULL);
 
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
                                     GNUNET_TIME_UNIT_SECONDS,
-                                    2),
+                                    4),
                                 &connect_mesh_service,
                                 NULL);
   disconnect_task =




reply via email to

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