aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-04 14:53:58 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-04 14:53:58 +0000
commit28a0d701d3bbfa6c53b6ff93598403b372016d72 (patch)
treeffcfa869034a05e75c4cff3820e8985eae78b78c /src/mesh
parent6018c3b6bcc6b4a9e20a5cd3f1464c837c46aa12 (diff)
downloadgnunet-28a0d701d3bbfa6c53b6ff93598403b372016d72.tar.gz
gnunet-28a0d701d3bbfa6c53b6ff93598403b372016d72.zip
Optimized timing, fixed formatting, fixed callback bug
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/test_mesh_small_unicast.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/src/mesh/test_mesh_small_unicast.c b/src/mesh/test_mesh_small_unicast.c
index 3c6f0a0cb..80ba1efc1 100644
--- a/src/mesh/test_mesh_small_unicast.c
+++ b/src/mesh/test_mesh_small_unicast.c
@@ -183,6 +183,19 @@ static struct GNUNET_MESH_MessageHandler handlers[] = {
183}; 183};
184 184
185 185
186static void
187disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
188{
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
190 "test: disconnecting mesh service of peers\n");
191 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
192 GNUNET_MESH_disconnect(h1);
193 GNUNET_MESH_disconnect(h2);
194 GNUNET_SCHEDULER_cancel (shutdown_handle);
195 shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
196}
197
198
186/** 199/**
187 * Method called whenever another peer has added us to a tunnel 200 * Method called whenever another peer has added us to a tunnel
188 * the other peer initiated. 201 * the other peer initiated.
@@ -202,8 +215,9 @@ incoming_tunnel (void *cls,
202{ 215{
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
204 "test: Incoming tunnel from %s\n", 217 "test: Incoming tunnel from %s\n",
205 GNUNET_h2s(&initiator->hashPubKey)); 218 GNUNET_i2s(initiator));
206 GNUNET_MESH_tunnel_destroy(t); 219 GNUNET_SCHEDULER_cancel (disconnect_task);
220 disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_mesh_peers, NULL);
207 ok = 0; 221 ok = 0;
208 return NULL; 222 return NULL;
209} 223}
@@ -237,7 +251,9 @@ tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
237static void 251static void
238dh (void *cls, const struct GNUNET_PeerIdentity *peer) 252dh (void *cls, const struct GNUNET_PeerIdentity *peer)
239{ 253{
240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer disconnected\n"); 254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 "test: peer %s disconnected\n",
256 GNUNET_i2s(peer));
241 return; 257 return;
242} 258}
243 259
@@ -253,21 +269,10 @@ static void
253ch (void *cls, const struct GNUNET_PeerIdentity *peer, 269ch (void *cls, const struct GNUNET_PeerIdentity *peer,
254 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 270 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
255{ 271{
256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer connected\n");
257 return;
258}
259
260
261static void
262disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
263{
264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
265 "test: disconnecting mesh service of peers\n"); 273 "test: peer %s connected\n",
266 disconnect_task = GNUNET_SCHEDULER_NO_TASK; 274 GNUNET_i2s(peer));
267 GNUNET_MESH_disconnect(h1); 275 return;
268 GNUNET_MESH_disconnect(h2);
269 GNUNET_SCHEDULER_cancel (shutdown_handle);
270 shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
271} 276}
272 277
273 278
@@ -300,12 +305,19 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
300 305
301#if VERBOSE 306#if VERBOSE
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
303 "test: connecting to mesh service of peer %s\n", GNUNET_i2s (&d1->id)); 308 "test: connecting to mesh service of peer %s\n",
309 GNUNET_i2s (&d1->id));
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
305 "test: connecting to mesh service of peer %s\n", GNUNET_i2s (&d2->id)); 311 "test: connecting to mesh service of peer %s\n",
312 GNUNET_i2s (&d2->id));
306#endif 313#endif
307 h1 = GNUNET_MESH_connect (d1->cfg, 10, NULL, NULL, &tunnel_cleaner, handlers, 314 h1 = GNUNET_MESH_connect (d1->cfg,
308 &app); 315 10,
316 NULL,
317 NULL,
318 &tunnel_cleaner,
319 handlers,
320 &app);
309 h2 = GNUNET_MESH_connect (d2->cfg, 321 h2 = GNUNET_MESH_connect (d2->cfg,
310 10, 322 10,
311 NULL, 323 NULL,
@@ -314,15 +326,17 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
314 handlers, 326 handlers,
315 &app); 327 &app);
316#if VERBOSE 328#if VERBOSE
317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connected to mesh service of peer %s\n", 329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
330 "test: connected to mesh service of peer %s\n",
318 GNUNET_i2s (&d1->id)); 331 GNUNET_i2s (&d1->id));
319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connected to mesh service of peer %s\n", 332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
333 "test: connected to mesh service of peer %s\n",
320 GNUNET_i2s (&d2->id)); 334 GNUNET_i2s (&d2->id));
321#endif 335#endif
322 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, NULL); 336 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, NULL);
323 test_task = 337 test_task =
324 GNUNET_SCHEDULER_add_delayed( 338 GNUNET_SCHEDULER_add_delayed(
325 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), 339 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3),
326 &do_test, NULL); 340 &do_test, NULL);
327} 341}
328 342
@@ -371,7 +385,7 @@ peergroup_ready (void *cls, const char *emsg)
371 385
372 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( 386 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
373 GNUNET_TIME_UNIT_SECONDS, 387 GNUNET_TIME_UNIT_SECONDS,
374 5), 388 2),
375 &connect_mesh_service, 389 &connect_mesh_service,
376 NULL); 390 NULL);
377 disconnect_task = 391 disconnect_task =