gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17176 - gnunet/src/mesh
Date: Tue, 4 Oct 2011 16:53:58 +0200

Author: bartpolot
Date: 2011-10-04 16:53:58 +0200 (Tue, 04 Oct 2011)
New Revision: 17176

Modified:
   gnunet/src/mesh/test_mesh_small_unicast.c
Log:
Optimized timing, fixed formatting, fixed callback bug

Modified: gnunet/src/mesh/test_mesh_small_unicast.c
===================================================================
--- gnunet/src/mesh/test_mesh_small_unicast.c   2011-10-04 14:50:16 UTC (rev 
17175)
+++ gnunet/src/mesh/test_mesh_small_unicast.c   2011-10-04 14:53:58 UTC (rev 
17176)
@@ -183,6 +183,19 @@
 };
 
 
+static void
+disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: disconnecting mesh service of peers\n");
+  disconnect_task = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_MESH_disconnect(h1);
+  GNUNET_MESH_disconnect(h2);
+  GNUNET_SCHEDULER_cancel (shutdown_handle);
+  shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
+}
+
+
 /**
  * Method called whenever another peer has added us to a tunnel
  * the other peer initiated.
@@ -202,8 +215,9 @@
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "test: Incoming tunnel from %s\n",
-              GNUNET_h2s(&initiator->hashPubKey));
-  GNUNET_MESH_tunnel_destroy(t);
+              GNUNET_i2s(initiator));
+  GNUNET_SCHEDULER_cancel (disconnect_task);
+  disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_mesh_peers, NULL);
   ok = 0;
   return NULL;
 }
@@ -237,7 +251,9 @@
 static void
 dh (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer disconnected\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: peer %s disconnected\n",
+              GNUNET_i2s(peer));
   return;
 }
 
@@ -253,25 +269,14 @@
 ch (void *cls, const struct GNUNET_PeerIdentity *peer,
     const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer connected\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: peer %s connected\n",
+              GNUNET_i2s(peer));
   return;
 }
 
 
 static void
-disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: disconnecting mesh service of peers\n");
-  disconnect_task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_MESH_disconnect(h1);
-  GNUNET_MESH_disconnect(h2);
-  GNUNET_SCHEDULER_cancel (shutdown_handle);
-  shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
-}
-
-
-static void
 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n");
@@ -300,12 +305,19 @@
 
 #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\n",
+              GNUNET_i2s (&d1->id));
   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\n",
+              GNUNET_i2s (&d2->id));
 #endif
-  h1 = GNUNET_MESH_connect (d1->cfg, 10, NULL, NULL, &tunnel_cleaner, handlers,
-                           &app);
+  h1 = GNUNET_MESH_connect (d1->cfg,
+                            10,
+                            NULL,
+                            NULL,
+                            &tunnel_cleaner,
+                            handlers,
+                            &app);
   h2 = GNUNET_MESH_connect (d2->cfg,
                             10,
                             NULL,
@@ -314,15 +326,17 @@
                             handlers,
                             &app);
 #if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connected to mesh service of 
peer %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: connected to mesh service of peer %s\n",
               GNUNET_i2s (&d1->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connected to mesh service of 
peer %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test: connected to mesh service of peer %s\n",
               GNUNET_i2s (&d2->id));
 #endif
   t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, NULL);
   test_task =
       GNUNET_SCHEDULER_add_delayed(
-          GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10),
+          GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3),
           &do_test, NULL);
 }
 
@@ -371,7 +385,7 @@
 
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
                                     GNUNET_TIME_UNIT_SECONDS,
-                                    5),
+                                    2),
                                 &connect_mesh_service,
                                 NULL);
   disconnect_task =




reply via email to

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