aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-10-19 17:50:38 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-10-19 17:50:38 +0000
commit9e7ddcafa47bdf32e76c47263cb07b4de1bd3897 (patch)
tree8cb65f9c13da2685cf5498ddd538099ca65253b1 /src
parent5de8538388a4cbb8618c568469eb61837a2fcaef (diff)
downloadgnunet-9e7ddcafa47bdf32e76c47263cb07b4de1bd3897.tar.gz
gnunet-9e7ddcafa47bdf32e76c47263cb07b4de1bd3897.zip
Aborting profiler after a timeout
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-regex-profiler.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 7eeac09e5..6d2f5934a 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -250,7 +250,7 @@ static char * policy_dir;
250/** 250/**
251 * Search string. 251 * Search string.
252 */ 252 */
253static char *search_string = "GNUNETVPN0001000IPEX4000110110111101100111"; 253static char *search_string = "GNUNETVPN0001000IPEX4110010011001111001101000";
254 254
255/** 255/**
256 * Search task identifier 256 * Search task identifier
@@ -399,14 +399,28 @@ mesh_peer_connect_handler (void *cls,
399 const struct GNUNET_ATS_Information * atsi) 399 const struct GNUNET_ATS_Information * atsi)
400{ 400{
401 // struct Peer *peer = (struct Peer *)cls; 401 // struct Peer *peer = (struct Peer *)cls;
402 unsigned int peer_cnt;
403 402
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh peer connect handler.\n"); 403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh peer connect handler.\n");
404 printf ("\nString successfully matched\n");
405 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
406}
405 407
406 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) 408
407 { 409/**
408 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle); 410 * Connect by string timeout task
409 } 411 *
412 * @param cls NULL
413 * @param tc the task context
414 */
415static void
416do_connect_by_string_timeout (void *cls,
417 const struct GNUNET_SCHEDULER_TaskContext * tc)
418{
419 long sec = (long)cls;
420
421 printf ("Searching for string did not succeed after %ld seconds\n", sec);
422
423 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
410} 424}
411 425
412 426
@@ -431,6 +445,10 @@ do_connect_by_string (void *cls,
431 445
432 GNUNET_MESH_peer_request_connect_by_string (peers[0].mesh_tunnel_handle, 446 GNUNET_MESH_peer_request_connect_by_string (peers[0].mesh_tunnel_handle,
433 search_string); 447 search_string);
448
449 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
450 (GNUNET_TIME_UNIT_SECONDS, 30),
451 &do_connect_by_string_timeout, (void *)(long)30);
434} 452}
435 453
436 454
@@ -516,10 +534,9 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
516 printf ("\nAll mesh handles connected.\n"); 534 printf ("\nAll mesh handles connected.\n");
517 535
518 search_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 536 search_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
519 (GNUNET_TIME_UNIT_SECONDS, 5), 537 (GNUNET_TIME_UNIT_SECONDS, 10),
520 &do_connect_by_string, NULL); 538 &do_connect_by_string, NULL);
521 } 539 }
522
523} 540}
524 541
525 542
@@ -534,19 +551,17 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
534void * 551void *
535mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) 552mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
536{ 553{
554 GNUNET_MESH_ApplicationType app;
537 struct Peer *peer = (struct Peer *) cls; 555 struct Peer *peer = (struct Peer *) cls;
538 556
539 static struct GNUNET_MESH_MessageHandler handlers[] = { 557 static struct GNUNET_MESH_MessageHandler handlers[] = {
540 {NULL, 0, 0} 558 {NULL, 0, 0}
541 }; 559 };
542 560
543 static GNUNET_MESH_ApplicationType apptypes[] = { 561 app = (GNUNET_MESH_ApplicationType)0;
544 GNUNET_APPLICATION_TYPE_END
545 };
546 562
547 peer->mesh_handle = 563 peer->mesh_handle =
548 GNUNET_MESH_connect (cfg, cls, &mesh_inbound_tunnel_handler, 564 GNUNET_MESH_connect (cfg, cls, NULL, NULL, handlers, &app);
549 &mesh_tunnel_end_handler, handlers, apptypes);
550 565
551 return peer->mesh_handle; 566 return peer->mesh_handle;
552} 567}