aboutsummaryrefslogtreecommitdiff
path: root/src/regex/gnunet-regex-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex/gnunet-regex-profiler.c')
-rw-r--r--src/regex/gnunet-regex-profiler.c1324
1 files changed, 667 insertions, 657 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index 4262107d7..16b7a7f0e 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -37,12 +37,13 @@
37#include "gnunet_testbed_service.h" 37#include "gnunet_testbed_service.h"
38 38
39#define FIND_TIMEOUT \ 39#define FIND_TIMEOUT \
40 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) 40 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90)
41 41
42/** 42/**
43 * DLL of operations 43 * DLL of operations
44 */ 44 */
45struct DLLOperation { 45struct DLLOperation
46{
46 /** 47 /**
47 * The testbed operation handle 48 * The testbed operation handle
48 */ 49 */
@@ -68,7 +69,8 @@ struct DLLOperation {
68/** 69/**
69 * Available states during profiling 70 * Available states during profiling
70 */ 71 */
71enum State { 72enum State
73{
72 /** 74 /**
73 * Initial state 75 * Initial state
74 */ 76 */
@@ -110,7 +112,8 @@ enum State {
110/** 112/**
111 * Peer handles. 113 * Peer handles.
112 */ 114 */
113struct RegexPeer { 115struct RegexPeer
116{
114 /** 117 /**
115 * Peer id. 118 * Peer id.
116 */ 119 */
@@ -167,7 +170,7 @@ struct RegexPeer {
167 /** 170 /**
168 * Operation timeout 171 * Operation timeout
169 */ 172 */
170 struct GNUNET_SCHEDULER_Task * timeout; 173 struct GNUNET_SCHEDULER_Task *timeout;
171 174
172 /** 175 /**
173 * Deamon start 176 * Deamon start
@@ -208,12 +211,12 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
208/** 211/**
209 * Abort task identifier 212 * Abort task identifier
210 */ 213 */
211static struct GNUNET_SCHEDULER_Task * abort_task; 214static struct GNUNET_SCHEDULER_Task *abort_task;
212 215
213/** 216/**
214 * Host registration task identifier 217 * Host registration task identifier
215 */ 218 */
216static struct GNUNET_SCHEDULER_Task * register_hosts_task; 219static struct GNUNET_SCHEDULER_Task *register_hosts_task;
217 220
218/** 221/**
219 * Global event mask for all testbed events 222 * Global event mask for all testbed events
@@ -248,7 +251,7 @@ enum State state;
248/** 251/**
249 * Folder where policy files are stored. 252 * Folder where policy files are stored.
250 */ 253 */
251static char * policy_dir; 254static char *policy_dir;
252 255
253/** 256/**
254 * File with hostnames where to execute the test. 257 * File with hostnames where to execute the test.
@@ -288,7 +291,7 @@ static unsigned int next_search;
288/** 291/**
289 * Search timeout task identifier. 292 * Search timeout task identifier.
290 */ 293 */
291static struct GNUNET_SCHEDULER_Task * search_timeout_task; 294static struct GNUNET_SCHEDULER_Task *search_timeout_task;
292 295
293/** 296/**
294 * Search timeout in seconds. 297 * Search timeout in seconds.
@@ -309,7 +312,7 @@ static char *data_filename;
309 * Prefix used for regex announcing. We need to prefix the search 312 * Prefix used for regex announcing. We need to prefix the search
310 * strings with it, in order to find something. 313 * strings with it, in order to find something.
311 */ 314 */
312static char * regex_prefix; 315static char *regex_prefix;
313 316
314/** 317/**
315 * What's the maximum regex reannounce period. 318 * What's the maximum regex reannounce period.
@@ -330,8 +333,8 @@ static struct GNUNET_TIME_Relative reannounce_period_max;
330 * @param emsg error message. 333 * @param emsg error message.
331 */ 334 */
332static void 335static void
333dht_connect_cb(void *cls, struct GNUNET_TESTBED_Operation *op, 336dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
334 void *ca_result, const char *emsg); 337 void *ca_result, const char *emsg);
335 338
336/** 339/**
337 * DHT connect adapter. 340 * DHT connect adapter.
@@ -342,7 +345,7 @@ dht_connect_cb(void *cls, struct GNUNET_TESTBED_Operation *op,
342 * @return 345 * @return
343 */ 346 */
344static void * 347static void *
345dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg); 348dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg);
346 349
347 350
348/** 351/**
@@ -353,7 +356,7 @@ dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg);
353 * @param op_result service handle returned from the connect adapter 356 * @param op_result service handle returned from the connect adapter
354 */ 357 */
355static void 358static void
356dht_da(void *cls, void *op_result); 359dht_da (void *cls, void *op_result);
357 360
358 361
359/** 362/**
@@ -366,10 +369,10 @@ dht_da(void *cls, void *op_result);
366 * @param emsg error message on failure 369 * @param emsg error message on failure
367 */ 370 */
368static void 371static void
369stats_connect_cb(void *cls, 372stats_connect_cb (void *cls,
370 struct GNUNET_TESTBED_Operation *op, 373 struct GNUNET_TESTBED_Operation *op,
371 void *ca_result, 374 void *ca_result,
372 const char *emsg); 375 const char *emsg);
373 376
374 377
375/** 378/**
@@ -378,7 +381,7 @@ stats_connect_cb(void *cls,
378 * @param cls Index of the next peer in the peers array. 381 * @param cls Index of the next peer in the peers array.
379 */ 382 */
380static void 383static void
381announce_next_regex(void *cls); 384announce_next_regex (void *cls);
382 385
383 386
384/******************************************************************************/ 387/******************************************************************************/
@@ -392,7 +395,7 @@ announce_next_regex(void *cls);
392 * @param cls NULL 395 * @param cls NULL
393 */ 396 */
394static void 397static void
395do_shutdown(void *cls) 398do_shutdown (void *cls)
396{ 399{
397 struct RegexPeer *peer; 400 struct RegexPeer *peer;
398 unsigned int peer_cnt; 401 unsigned int peer_cnt;
@@ -401,75 +404,75 @@ do_shutdown(void *cls)
401 size_t size; 404 size_t size;
402 405
403 if (NULL != abort_task) 406 if (NULL != abort_task)
404 { 407 {
405 GNUNET_SCHEDULER_cancel(abort_task); 408 GNUNET_SCHEDULER_cancel (abort_task);
406 abort_task = NULL; 409 abort_task = NULL;
407 } 410 }
408 if (NULL != register_hosts_task) 411 if (NULL != register_hosts_task)
409 { 412 {
410 GNUNET_SCHEDULER_cancel(register_hosts_task); 413 GNUNET_SCHEDULER_cancel (register_hosts_task);
411 register_hosts_task = NULL; 414 register_hosts_task = NULL;
412 } 415 }
413 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) 416 for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++)
417 {
418 peer = &peers[peer_cnt];
419
420 if ((GNUNET_YES != peer->search_str_matched) &&(NULL != data_file) )
414 { 421 {
415 peer = &peers[peer_cnt]; 422 prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time);
416 423 size =
417 if (GNUNET_YES != peer->search_str_matched && NULL != data_file) 424 GNUNET_snprintf (output_buffer,
418 { 425 sizeof(output_buffer),
419 prof_time = GNUNET_TIME_absolute_get_duration(peer->prof_start_time); 426 "%p Search string not found: %s (%d)\n"
420 size = 427 "%p On peer: %u (%p)\n"
421 GNUNET_snprintf(output_buffer, 428 "%p After: %s\n",
422 sizeof(output_buffer), 429 peer, peer->search_str, peer->search_str_matched,
423 "%p Search string not found: %s (%d)\n" 430 peer, peer->id, peer,
424 "%p On peer: %u (%p)\n" 431 peer,
425 "%p After: %s\n", 432 GNUNET_STRINGS_relative_time_to_string (prof_time,
426 peer, peer->search_str, peer->search_str_matched, 433 GNUNET_NO));
427 peer, peer->id, peer, 434 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
428 peer, 435 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
429 GNUNET_STRINGS_relative_time_to_string(prof_time,
430 GNUNET_NO));
431 if (size != GNUNET_DISK_file_write(data_file, output_buffer, size))
432 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
433 }
434
435 if (NULL != peers[peer_cnt].op_handle)
436 GNUNET_TESTBED_operation_done(peers[peer_cnt].op_handle);
437 } 436 }
438 437
438 if (NULL != peers[peer_cnt].op_handle)
439 GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle);
440 }
441
439 if (NULL != data_file) 442 if (NULL != data_file)
440 { 443 {
441 GNUNET_DISK_file_close(data_file); 444 GNUNET_DISK_file_close (data_file);
442 data_file = NULL; 445 data_file = NULL;
443 } 446 }
444 for (search_str_cnt = 0; 447 for (search_str_cnt = 0;
445 search_str_cnt < num_peers && NULL != search_strings; 448 search_str_cnt < num_peers && NULL != search_strings;
446 search_str_cnt++) 449 search_str_cnt++)
447 { 450 {
448 GNUNET_free_non_null(search_strings[search_str_cnt]); 451 GNUNET_free_non_null (search_strings[search_str_cnt]);
449 } 452 }
450 GNUNET_free_non_null(search_strings); 453 GNUNET_free_non_null (search_strings);
451 search_strings = NULL; 454 search_strings = NULL;
452 455
453 if (NULL != reg_handle) 456 if (NULL != reg_handle)
454 { 457 {
455 GNUNET_TESTBED_cancel_registration(reg_handle); 458 GNUNET_TESTBED_cancel_registration (reg_handle);
456 reg_handle = NULL; 459 reg_handle = NULL;
457 } 460 }
458 if (NULL != mc) 461 if (NULL != mc)
459 { 462 {
460 GNUNET_TESTBED_controller_disconnect(mc); 463 GNUNET_TESTBED_controller_disconnect (mc);
461 mc = NULL; 464 mc = NULL;
462 } 465 }
463 if (NULL != mc_proc) 466 if (NULL != mc_proc)
464 { 467 {
465 GNUNET_TESTBED_controller_stop(mc_proc); 468 GNUNET_TESTBED_controller_stop (mc_proc);
466 mc_proc = NULL; 469 mc_proc = NULL;
467 } 470 }
468 if (NULL != cfg) 471 if (NULL != cfg)
469 { 472 {
470 GNUNET_CONFIGURATION_destroy(cfg); 473 GNUNET_CONFIGURATION_destroy (cfg);
471 cfg = NULL; 474 cfg = NULL;
472 } 475 }
473} 476}
474 477
475 478
@@ -479,15 +482,15 @@ do_shutdown(void *cls)
479 * @param cls NULL 482 * @param cls NULL
480 */ 483 */
481static void 484static void
482do_abort(void *cls) 485do_abort (void *cls)
483{ 486{
484 unsigned long i = (unsigned long)cls; 487 unsigned long i = (unsigned long) cls;
485 488
486 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 489 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
487 "Aborting from line %lu...\n", i); 490 "Aborting from line %lu...\n", i);
488 abort_task = NULL; 491 abort_task = NULL;
489 result = GNUNET_SYSERR; 492 result = GNUNET_SYSERR;
490 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 493 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
491} 494}
492 495
493 496
@@ -506,10 +509,10 @@ do_abort(void *cls)
506 * @return service handle to return in 'op_result', NULL on error 509 * @return service handle to return in 'op_result', NULL on error
507 */ 510 */
508static void * 511static void *
509stats_ca(void *cls, 512stats_ca (void *cls,
510 const struct GNUNET_CONFIGURATION_Handle *cfg) 513 const struct GNUNET_CONFIGURATION_Handle *cfg)
511{ 514{
512 return GNUNET_STATISTICS_create("<driver>", cfg); 515 return GNUNET_STATISTICS_create ("<driver>", cfg);
513} 516}
514 517
515 518
@@ -521,13 +524,13 @@ stats_ca(void *cls,
521 * @param op_result service handle returned from the connect adapter 524 * @param op_result service handle returned from the connect adapter
522 */ 525 */
523static void 526static void
524stats_da(void *cls, void *op_result) 527stats_da (void *cls, void *op_result)
525{ 528{
526 struct RegexPeer *peer = cls; 529 struct RegexPeer *peer = cls;
527 530
528 GNUNET_assert(op_result == peer->stats_handle); 531 GNUNET_assert (op_result == peer->stats_handle);
529 532
530 GNUNET_STATISTICS_destroy(peer->stats_handle, GNUNET_NO); 533 GNUNET_STATISTICS_destroy (peer->stats_handle, GNUNET_NO);
531 peer->stats_handle = NULL; 534 peer->stats_handle = NULL;
532} 535}
533 536
@@ -543,34 +546,34 @@ stats_da(void *cls, void *op_result)
543 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration 546 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
544 */ 547 */
545static int 548static int
546stats_iterator(void *cls, 549stats_iterator (void *cls,
547 const char *subsystem, 550 const char *subsystem,
548 const char *name, 551 const char *name,
549 uint64_t value, int is_persistent) 552 uint64_t value, int is_persistent)
550{ 553{
551 struct RegexPeer *peer = cls; 554 struct RegexPeer *peer = cls;
552 char output_buffer[512]; 555 char output_buffer[512];
553 size_t size; 556 size_t size;
554 557
555 if (NULL == data_file) 558 if (NULL == data_file)
556 { 559 {
557 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 560 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
558 "%p -> %s [%s]: %llu\n", 561 "%p -> %s [%s]: %llu\n",
559 peer, 562 peer,
560 subsystem, 563 subsystem,
561 name, 564 name,
562 (unsigned long long)value); 565 (unsigned long long) value);
563 return GNUNET_OK; 566 return GNUNET_OK;
564 } 567 }
565 size = 568 size =
566 GNUNET_snprintf(output_buffer, 569 GNUNET_snprintf (output_buffer,
567 sizeof(output_buffer), 570 sizeof(output_buffer),
568 "%p [%s] %llu %s\n", 571 "%p [%s] %llu %s\n",
569 peer, 572 peer,
570 subsystem, value, name); 573 subsystem, value, name);
571 if (size != GNUNET_DISK_file_write(data_file, output_buffer, size)) 574 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
572 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 575 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
573 "Unable to write to file!\n"); 576 "Unable to write to file!\n");
574 577
575 return GNUNET_OK; 578 return GNUNET_OK;
576} 579}
@@ -585,48 +588,48 @@ stats_iterator(void *cls,
585 * successfully obtained, GNUNET_SYSERR if not. 588 * successfully obtained, GNUNET_SYSERR if not.
586 */ 589 */
587static void 590static void
588stats_cb(void *cls, 591stats_cb (void *cls,
589 int success) 592 int success)
590{ 593{
591 static unsigned int peer_cnt; 594 static unsigned int peer_cnt;
592 struct RegexPeer *peer = cls; 595 struct RegexPeer *peer = cls;
593 596
594 if (GNUNET_OK != success) 597 if (GNUNET_OK != success)
595 { 598 {
596 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 599 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
597 "Getting statistics for peer %u failed!\n", 600 "Getting statistics for peer %u failed!\n",
598 peer->id); 601 peer->id);
599 return; 602 return;
600 } 603 }
601 604
602 GNUNET_assert(NULL != peer->op_handle); 605 GNUNET_assert (NULL != peer->op_handle);
603 606
604 GNUNET_TESTBED_operation_done(peer->op_handle); 607 GNUNET_TESTBED_operation_done (peer->op_handle);
605 peer->op_handle = NULL; 608 peer->op_handle = NULL;
606 609
607 peer_cnt++; 610 peer_cnt++;
608 peer = &peers[peer_cnt]; 611 peer = &peers[peer_cnt];
609 612
610 fprintf(stderr, "s"); 613 fprintf (stderr, "s");
611 if (peer_cnt == num_peers) 614 if (peer_cnt == num_peers)
612 { 615 {
613 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 616 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
614 "\nCollecting stats finished. Shutting down.\n"); 617 "\nCollecting stats finished. Shutting down.\n");
615 GNUNET_SCHEDULER_shutdown(); 618 GNUNET_SCHEDULER_shutdown ();
616 result = GNUNET_OK; 619 result = GNUNET_OK;
617 } 620 }
618 else 621 else
619 { 622 {
620 peer->op_handle = 623 peer->op_handle =
621 GNUNET_TESTBED_service_connect(NULL, 624 GNUNET_TESTBED_service_connect (NULL,
622 peer->peer_handle, 625 peer->peer_handle,
623 "statistics", 626 "statistics",
624 &stats_connect_cb, 627 &stats_connect_cb,
625 peer, 628 peer,
626 &stats_ca, 629 &stats_ca,
627 &stats_da, 630 &stats_da,
628 peer); 631 peer);
629 } 632 }
630} 633}
631 634
632 635
@@ -640,32 +643,32 @@ stats_cb(void *cls,
640 * @param emsg error message on failure 643 * @param emsg error message on failure
641 */ 644 */
642static void 645static void
643stats_connect_cb(void *cls, 646stats_connect_cb (void *cls,
644 struct GNUNET_TESTBED_Operation *op, 647 struct GNUNET_TESTBED_Operation *op,
645 void *ca_result, 648 void *ca_result,
646 const char *emsg) 649 const char *emsg)
647{ 650{
648 struct RegexPeer *peer = cls; 651 struct RegexPeer *peer = cls;
649 652
650 if (NULL == ca_result || NULL != emsg) 653 if ((NULL == ca_result)||(NULL != emsg))
651 { 654 {
652 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 655 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
653 "Failed to connect to statistics service on peer %u: %s\n", 656 "Failed to connect to statistics service on peer %u: %s\n",
654 peer->id, emsg); 657 peer->id, emsg);
655 658
656 peer->stats_handle = NULL; 659 peer->stats_handle = NULL;
657 return; 660 return;
658 } 661 }
659 662
660 peer->stats_handle = ca_result; 663 peer->stats_handle = ca_result;
661 664
662 if (NULL == GNUNET_STATISTICS_get(peer->stats_handle, NULL, NULL, 665 if (NULL == GNUNET_STATISTICS_get (peer->stats_handle, NULL, NULL,
663 &stats_cb, 666 &stats_cb,
664 &stats_iterator, peer)) 667 &stats_iterator, peer))
665 { 668 {
666 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 669 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
667 "Could not get statistics of peer %u!\n", peer->id); 670 "Could not get statistics of peer %u!\n", peer->id);
668 } 671 }
669} 672}
670 673
671 674
@@ -676,21 +679,21 @@ stats_connect_cb(void *cls,
676 * @param cls NULL 679 * @param cls NULL
677 */ 680 */
678static void 681static void
679do_collect_stats(void *cls) 682do_collect_stats (void *cls)
680{ 683{
681 struct RegexPeer *peer = &peers[0]; 684 struct RegexPeer *peer = &peers[0];
682 685
683 GNUNET_assert(NULL != peer->peer_handle); 686 GNUNET_assert (NULL != peer->peer_handle);
684 687
685 peer->op_handle = 688 peer->op_handle =
686 GNUNET_TESTBED_service_connect(NULL, 689 GNUNET_TESTBED_service_connect (NULL,
687 peer->peer_handle, 690 peer->peer_handle,
688 "statistics", 691 "statistics",
689 &stats_connect_cb, 692 &stats_connect_cb,
690 peer, 693 peer,
691 &stats_ca, 694 &stats_ca,
692 &stats_da, 695 &stats_da,
693 peer); 696 peer);
694} 697}
695 698
696 699
@@ -705,7 +708,7 @@ do_collect_stats(void *cls)
705 * @param cls Index of the next peer in the peers array. 708 * @param cls Index of the next peer in the peers array.
706 */ 709 */
707static void 710static void
708find_string(void *cls); 711find_string (void *cls);
709 712
710 713
711/** 714/**
@@ -720,94 +723,94 @@ find_string(void *cls);
720 * @param put_path_length Length of the put_path. 723 * @param put_path_length Length of the put_path.
721 */ 724 */
722static void 725static void
723regex_found_handler(void *cls, 726regex_found_handler (void *cls,
724 const struct GNUNET_PeerIdentity *id, 727 const struct GNUNET_PeerIdentity *id,
725 const struct GNUNET_PeerIdentity *get_path, 728 const struct GNUNET_PeerIdentity *get_path,
726 unsigned int get_path_length, 729 unsigned int get_path_length,
727 const struct GNUNET_PeerIdentity *put_path, 730 const struct GNUNET_PeerIdentity *put_path,
728 unsigned int put_path_length) 731 unsigned int put_path_length)
729{ 732{
730 struct RegexPeer *peer = cls; 733 struct RegexPeer *peer = cls;
731 char output_buffer[512]; 734 char output_buffer[512];
732 size_t size; 735 size_t size;
733 736
734 if (GNUNET_YES == peer->search_str_matched) 737 if (GNUNET_YES == peer->search_str_matched)
735 { 738 {
736 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 739 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
737 "String %s on peer %u already matched!\n", 740 "String %s on peer %u already matched!\n",
738 peer->search_str, peer->id); 741 peer->search_str, peer->id);
739 return; 742 return;
740 } 743 }
741 744
742 strings_found++; 745 strings_found++;
743 parallel_searches--; 746 parallel_searches--;
744 747
745 if (NULL != peer->timeout) 748 if (NULL != peer->timeout)
746 { 749 {
747 GNUNET_SCHEDULER_cancel(peer->timeout); 750 GNUNET_SCHEDULER_cancel (peer->timeout);
748 peer->timeout = NULL; 751 peer->timeout = NULL;
749 if (GNUNET_NO == in_shutdown) 752 if (GNUNET_NO == in_shutdown)
750 GNUNET_SCHEDULER_add_now(&announce_next_regex, NULL); 753 GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL);
751 } 754 }
752 755
753 if (NULL == id) 756 if (NULL == id)
754 { 757 {
755 // FIXME not possible right now 758 // FIXME not possible right now
756 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 759 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
757 "String matching timed out for string %s on peer %u (%i/%i)\n", 760 "String matching timed out for string %s on peer %u (%i/%i)\n",
758 peer->search_str, peer->id, strings_found, num_peers); 761 peer->search_str, peer->id, strings_found, num_peers);
759 peer->search_str_matched = GNUNET_SYSERR; 762 peer->search_str_matched = GNUNET_SYSERR;
760 } 763 }
761 else 764 else
765 {
766 prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time);
767
768 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
769 "String %s found on peer %u after %s (%i/%i) (%u||)\n",
770 peer->search_str, peer->id,
771 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
772 strings_found, num_peers, parallel_searches);
773
774 peer->search_str_matched = GNUNET_YES;
775
776 if (NULL != data_file)
762 { 777 {
763 prof_time = GNUNET_TIME_absolute_get_duration(peer->prof_start_time); 778 size =
764 779 GNUNET_snprintf (output_buffer,
765 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 780 sizeof(output_buffer),
766 "String %s found on peer %u after %s (%i/%i) (%u||)\n", 781 "%p Peer: %u\n"
767 peer->search_str, peer->id, 782 "%p Search string: %s\n"
768 GNUNET_STRINGS_relative_time_to_string(prof_time, GNUNET_NO), 783 "%p Search duration: %s\n\n",
769 strings_found, num_peers, parallel_searches); 784 peer, peer->id,
770 785 peer, peer->search_str,
771 peer->search_str_matched = GNUNET_YES; 786 peer,
772 787 GNUNET_STRINGS_relative_time_to_string (prof_time,
773 if (NULL != data_file) 788 GNUNET_NO));
774 { 789
775 size = 790 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
776 GNUNET_snprintf(output_buffer, 791 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
777 sizeof(output_buffer),
778 "%p Peer: %u\n"
779 "%p Search string: %s\n"
780 "%p Search duration: %s\n\n",
781 peer, peer->id,
782 peer, peer->search_str,
783 peer,
784 GNUNET_STRINGS_relative_time_to_string(prof_time,
785 GNUNET_NO));
786
787 if (size != GNUNET_DISK_file_write(data_file, output_buffer, size))
788 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
789 }
790 } 792 }
793 }
791 794
792 GNUNET_TESTBED_operation_done(peer->op_handle); 795 GNUNET_TESTBED_operation_done (peer->op_handle);
793 peer->op_handle = NULL; 796 peer->op_handle = NULL;
794 797
795 if (strings_found == num_peers) 798 if (strings_found == num_peers)
796 { 799 {
797 prof_time = GNUNET_TIME_absolute_get_duration(prof_start_time); 800 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
798 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 801 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
799 "All strings successfully matched in %s\n", 802 "All strings successfully matched in %s\n",
800 GNUNET_STRINGS_relative_time_to_string(prof_time, GNUNET_NO)); 803 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
801
802 if (NULL != search_timeout_task)
803 {
804 GNUNET_SCHEDULER_cancel(search_timeout_task);
805 search_timeout_task = NULL;
806 }
807 804
808 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n"); 805 if (NULL != search_timeout_task)
809 GNUNET_SCHEDULER_add_now(&do_collect_stats, NULL); 806 {
807 GNUNET_SCHEDULER_cancel (search_timeout_task);
808 search_timeout_task = NULL;
810 } 809 }
810
811 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n");
812 GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
813 }
811} 814}
812 815
813 816
@@ -818,33 +821,33 @@ regex_found_handler(void *cls,
818 * @param cls NULL 821 * @param cls NULL
819 */ 822 */
820static void 823static void
821search_timed_out(void *cls) 824search_timed_out (void *cls)
822{ 825{
823 unsigned int i; 826 unsigned int i;
824 827
825 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 828 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
826 "Finding matches to all strings did not succeed after %s.\n", 829 "Finding matches to all strings did not succeed after %s.\n",
827 GNUNET_STRINGS_relative_time_to_string(search_timeout_time, 830 GNUNET_STRINGS_relative_time_to_string (search_timeout_time,
828 GNUNET_NO)); 831 GNUNET_NO));
829 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 832 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
830 "Found %i of %i strings\n", strings_found, num_peers); 833 "Found %i of %i strings\n", strings_found, num_peers);
831 834
832 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 835 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
833 "Search timed out after %s." 836 "Search timed out after %s."
834 "Collecting stats and shutting down.\n", 837 "Collecting stats and shutting down.\n",
835 GNUNET_STRINGS_relative_time_to_string(search_timeout_time, 838 GNUNET_STRINGS_relative_time_to_string (search_timeout_time,
836 GNUNET_NO)); 839 GNUNET_NO));
837 840
838 in_shutdown = GNUNET_YES; 841 in_shutdown = GNUNET_YES;
839 for (i = 0; i < num_peers; i++) 842 for (i = 0; i < num_peers; i++)
843 {
844 if (NULL != peers[i].op_handle)
840 { 845 {
841 if (NULL != peers[i].op_handle) 846 GNUNET_TESTBED_operation_done (peers[i].op_handle);
842 { 847 peers[i].op_handle = NULL;
843 GNUNET_TESTBED_operation_done(peers[i].op_handle);
844 peers[i].op_handle = NULL;
845 }
846 } 848 }
847 GNUNET_SCHEDULER_add_now(&do_collect_stats, NULL); 849 }
850 GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
848} 851}
849 852
850 853
@@ -855,17 +858,17 @@ search_timed_out(void *cls)
855 * @param cls Index of the next peer in the peers array. 858 * @param cls Index of the next peer in the peers array.
856 */ 859 */
857static void 860static void
858find_timed_out(void *cls) 861find_timed_out (void *cls)
859{ 862{
860 struct RegexPeer *p = cls; 863 struct RegexPeer *p = cls;
861 864
862 p->timeout = NULL; 865 p->timeout = NULL;
863 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 866 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
864 "Searching for string \"%s\" on peer %d timed out.\n", 867 "Searching for string \"%s\" on peer %d timed out.\n",
865 p->search_str, 868 p->search_str,
866 p->id); 869 p->id);
867 if (GNUNET_NO == in_shutdown) 870 if (GNUNET_NO == in_shutdown)
868 GNUNET_SCHEDULER_add_now(&announce_next_regex, NULL); 871 GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL);
869} 872}
870 873
871 874
@@ -875,34 +878,34 @@ find_timed_out(void *cls)
875 * @param cls Index of the next peer in the peers array. 878 * @param cls Index of the next peer in the peers array.
876 */ 879 */
877static void 880static void
878find_string(void *cls) 881find_string (void *cls)
879{ 882{
880 unsigned int search_peer = (unsigned int)(long)cls; 883 unsigned int search_peer = (unsigned int) (long) cls;
881 884
882 if ((search_peer >= num_peers) || 885 if ((search_peer >= num_peers) ||
883 (GNUNET_YES == in_shutdown)) 886 (GNUNET_YES == in_shutdown))
884 return; 887 return;
885 888
886 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 889 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
887 "Searching for string \"%s\" on peer %d (%u||)\n", 890 "Searching for string \"%s\" on peer %d (%u||)\n",
888 peers[search_peer].search_str, 891 peers[search_peer].search_str,
889 search_peer, 892 search_peer,
890 parallel_searches); 893 parallel_searches);
891 894
892 peers[search_peer].op_handle = 895 peers[search_peer].op_handle =
893 GNUNET_TESTBED_service_connect(NULL, 896 GNUNET_TESTBED_service_connect (NULL,
894 peers[search_peer].peer_handle, 897 peers[search_peer].peer_handle,
895 "dht", 898 "dht",
896 &dht_connect_cb, 899 &dht_connect_cb,
897 &peers[search_peer], 900 &peers[search_peer],
898 &dht_ca, 901 &dht_ca,
899 &dht_da, 902 &dht_da,
900 &peers[search_peer]); 903 &peers[search_peer]);
901 GNUNET_assert(NULL != peers[search_peer].op_handle); 904 GNUNET_assert (NULL != peers[search_peer].op_handle);
902 peers[search_peer].timeout 905 peers[search_peer].timeout
903 = GNUNET_SCHEDULER_add_delayed(FIND_TIMEOUT, 906 = GNUNET_SCHEDULER_add_delayed (FIND_TIMEOUT,
904 &find_timed_out, 907 &find_timed_out,
905 &peers[search_peer]); 908 &peers[search_peer]);
906} 909}
907 910
908 911
@@ -914,44 +917,44 @@ find_string(void *cls)
914 * @param emsg NULL on success; otherwise an error description 917 * @param emsg NULL on success; otherwise an error description
915 */ 918 */
916static void 919static void
917daemon_started(void *cls, 920daemon_started (void *cls,
918 struct GNUNET_TESTBED_Operation *op, 921 struct GNUNET_TESTBED_Operation *op,
919 const char *emsg) 922 const char *emsg)
920{ 923{
921 struct RegexPeer *peer = (struct RegexPeer *)cls; 924 struct RegexPeer *peer = (struct RegexPeer *) cls;
922 unsigned long search_peer; 925 unsigned long search_peer;
923 unsigned int i; 926 unsigned int i;
924 927
925 GNUNET_TESTBED_operation_done(peer->daemon_op); 928 GNUNET_TESTBED_operation_done (peer->daemon_op);
926 peer->daemon_op = NULL; 929 peer->daemon_op = NULL;
927 if (NULL != emsg) 930 if (NULL != emsg)
928 { 931 {
929 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 932 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
930 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg); 933 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
931 GNUNET_assert(0); 934 GNUNET_assert (0);
932 } 935 }
933 else 936 else
934 { 937 {
935 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 938 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
936 "Deamon %u started successfully\n", peer->id); 939 "Deamon %u started successfully\n", peer->id);
937 } 940 }
938 941
939 /* Find a peer to look for a string matching the regex announced */ 942 /* Find a peer to look for a string matching the regex announced */
940 search_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 943 search_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
941 num_peers); 944 num_peers);
942 for (i = 0; peers[search_peer].search_str != NULL; i++) 945 for (i = 0; peers[search_peer].search_str != NULL; i++)
943 { 946 {
944 search_peer = (search_peer + 1) % num_peers; 947 search_peer = (search_peer + 1) % num_peers;
945 if (i > num_peers) 948 if (i > num_peers)
946 GNUNET_assert(0); /* we ran out of peers, must be a bug */ 949 GNUNET_assert (0); /* we ran out of peers, must be a bug */
947 } 950 }
948 peers[search_peer].search_str = search_strings[peer->id]; 951 peers[search_peer].search_str = search_strings[peer->id];
949 peers[search_peer].search_str_matched = GNUNET_NO; 952 peers[search_peer].search_str_matched = GNUNET_NO;
950 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_saturating_multiply( 953 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_saturating_multiply (
951 reannounce_period_max, 954 reannounce_period_max,
952 2), 955 2),
953 &find_string, 956 &find_string,
954 (void *)search_peer); 957 (void *) search_peer);
955} 958}
956 959
957 960
@@ -963,21 +966,21 @@ daemon_started(void *cls,
963 * @param tc the task context 966 * @param tc the task context
964 */ 967 */
965static void 968static void
966do_announce(void *cls) 969do_announce (void *cls)
967{ 970{
968 unsigned int i; 971 unsigned int i;
969 972
970 if (GNUNET_YES == in_shutdown) 973 if (GNUNET_YES == in_shutdown)
971 return; 974 return;
972 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 975 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
973 "Starting announce.\n"); 976 "Starting announce.\n");
974 for (i = 0; i < init_parallel_searches; i++) 977 for (i = 0; i < init_parallel_searches; i++)
975 { 978 {
976 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 979 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
977 " scheduling announce %u\n", 980 " scheduling announce %u\n",
978 i); 981 i);
979 (void)GNUNET_SCHEDULER_add_now(&announce_next_regex, NULL); 982 (void) GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL);
980 } 983 }
981} 984}
982 985
983 986
@@ -987,36 +990,36 @@ do_announce(void *cls)
987 * @param cls Closure (unused). 990 * @param cls Closure (unused).
988 */ 991 */
989static void 992static void
990announce_next_regex(void *cls) 993announce_next_regex (void *cls)
991{ 994{
992 struct RegexPeer *peer; 995 struct RegexPeer *peer;
993 996
994 if (GNUNET_YES == in_shutdown) 997 if (GNUNET_YES == in_shutdown)
995 return; 998 return;
996 if (next_search >= num_peers) 999 if (next_search >= num_peers)
1000 {
1001 if (strings_found != num_peers)
997 { 1002 {
998 if (strings_found != num_peers) 1003 struct GNUNET_TIME_Relative new_delay;
999 { 1004 if (NULL != search_timeout_task)
1000 struct GNUNET_TIME_Relative new_delay; 1005 GNUNET_SCHEDULER_cancel (search_timeout_task);
1001 if (NULL != search_timeout_task) 1006 new_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
1002 GNUNET_SCHEDULER_cancel(search_timeout_task); 1007 search_timeout_task = GNUNET_SCHEDULER_add_delayed (new_delay,
1003 new_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 15); 1008 &search_timed_out,
1004 search_timeout_task = GNUNET_SCHEDULER_add_delayed(new_delay, 1009 NULL);
1005 &search_timed_out,
1006 NULL);
1007 }
1008 return;
1009 } 1010 }
1011 return;
1012 }
1010 1013
1011 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search); 1014 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search);
1012 peer = &peers[next_search]; 1015 peer = &peers[next_search];
1013 peer->daemon_op = 1016 peer->daemon_op =
1014 GNUNET_TESTBED_peer_manage_service(NULL, 1017 GNUNET_TESTBED_peer_manage_service (NULL,
1015 peer->peer_handle, 1018 peer->peer_handle,
1016 "regexprofiler", 1019 "regexprofiler",
1017 &daemon_started, 1020 &daemon_started,
1018 peer, 1021 peer,
1019 1); 1022 1);
1020 next_search++; 1023 next_search++;
1021 parallel_searches++; 1024 parallel_searches++;
1022} 1025}
@@ -1033,29 +1036,29 @@ announce_next_regex(void *cls)
1033 * @param emsg error message. 1036 * @param emsg error message.
1034 */ 1037 */
1035static void 1038static void
1036dht_connect_cb(void *cls, 1039dht_connect_cb (void *cls,
1037 struct GNUNET_TESTBED_Operation *op, 1040 struct GNUNET_TESTBED_Operation *op,
1038 void *ca_result, 1041 void *ca_result,
1039 const char *emsg) 1042 const char *emsg)
1040{ 1043{
1041 struct RegexPeer *peer = (struct RegexPeer *)cls; 1044 struct RegexPeer *peer = (struct RegexPeer *) cls;
1042 1045
1043 if (NULL != emsg || NULL == op || NULL == ca_result) 1046 if ((NULL != emsg)||(NULL == op)||(NULL == ca_result))
1044 { 1047 {
1045 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg); 1048 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg);
1046 GNUNET_assert(0); 1049 GNUNET_assert (0);
1047 } 1050 }
1048 1051
1049 GNUNET_assert(NULL != peer->dht_handle); 1052 GNUNET_assert (NULL != peer->dht_handle);
1050 GNUNET_assert(peer->op_handle == op); 1053 GNUNET_assert (peer->op_handle == op);
1051 GNUNET_assert(peer->dht_handle == ca_result); 1054 GNUNET_assert (peer->dht_handle == ca_result);
1052 1055
1053 peer->search_str_matched = GNUNET_NO; 1056 peer->search_str_matched = GNUNET_NO;
1054 peer->search_handle = REGEX_INTERNAL_search(peer->dht_handle, 1057 peer->search_handle = REGEX_INTERNAL_search (peer->dht_handle,
1055 peer->search_str, 1058 peer->search_str,
1056 &regex_found_handler, peer, 1059 &regex_found_handler, peer,
1057 NULL); 1060 NULL);
1058 peer->prof_start_time = GNUNET_TIME_absolute_get(); 1061 peer->prof_start_time = GNUNET_TIME_absolute_get ();
1059} 1062}
1060 1063
1061 1064
@@ -1068,11 +1071,11 @@ dht_connect_cb(void *cls,
1068 * @return 1071 * @return
1069 */ 1072 */
1070static void * 1073static void *
1071dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) 1074dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
1072{ 1075{
1073 struct RegexPeer *peer = cls; 1076 struct RegexPeer *peer = cls;
1074 1077
1075 peer->dht_handle = GNUNET_DHT_connect(cfg, 32); 1078 peer->dht_handle = GNUNET_DHT_connect (cfg, 32);
1076 1079
1077 return peer->dht_handle; 1080 return peer->dht_handle;
1078} 1081}
@@ -1085,23 +1088,23 @@ dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
1085 * @param op_result Service handle returned from the connect adapter. 1088 * @param op_result Service handle returned from the connect adapter.
1086 */ 1089 */
1087static void 1090static void
1088dht_da(void *cls, void *op_result) 1091dht_da (void *cls, void *op_result)
1089{ 1092{
1090 struct RegexPeer *peer = (struct RegexPeer *)cls; 1093 struct RegexPeer *peer = (struct RegexPeer *) cls;
1091 1094
1092 GNUNET_assert(peer->dht_handle == op_result); 1095 GNUNET_assert (peer->dht_handle == op_result);
1093 1096
1094 if (NULL != peer->search_handle) 1097 if (NULL != peer->search_handle)
1095 { 1098 {
1096 REGEX_INTERNAL_search_cancel(peer->search_handle); 1099 REGEX_INTERNAL_search_cancel (peer->search_handle);
1097 peer->search_handle = NULL; 1100 peer->search_handle = NULL;
1098 } 1101 }
1099 1102
1100 if (NULL != peer->dht_handle) 1103 if (NULL != peer->dht_handle)
1101 { 1104 {
1102 GNUNET_DHT_disconnect(peer->dht_handle); 1105 GNUNET_DHT_disconnect (peer->dht_handle);
1103 peer->dht_handle = NULL; 1106 peer->dht_handle = NULL;
1104 } 1107 }
1105} 1108}
1106 1109
1107 1110
@@ -1119,51 +1122,52 @@ dht_da(void *cls, void *op_result)
1119 * failed 1122 * failed
1120 */ 1123 */
1121static void 1124static void
1122test_master(void *cls, 1125test_master (void *cls,
1123 struct GNUNET_TESTBED_RunHandle *h, 1126 struct GNUNET_TESTBED_RunHandle *h,
1124 unsigned int num_peers_, 1127 unsigned int num_peers_,
1125 struct GNUNET_TESTBED_Peer **testbed_peers, 1128 struct GNUNET_TESTBED_Peer **testbed_peers,
1126 unsigned int links_succeeded, 1129 unsigned int links_succeeded,
1127 unsigned int links_failed) 1130 unsigned int links_failed)
1128{ 1131{
1129 unsigned int i; 1132 unsigned int i;
1130 1133
1131 GNUNET_assert(num_peers_ == num_peers); 1134 GNUNET_assert (num_peers_ == num_peers);
1132 1135
1133 prof_time = GNUNET_TIME_absolute_get_duration(prof_start_time); 1136 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
1134 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1137 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1135 "Testbed started in %s\n", 1138 "Testbed started in %s\n",
1136 GNUNET_STRINGS_relative_time_to_string(prof_time, GNUNET_NO)); 1139 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
1137 1140
1138 if (NULL != abort_task) 1141 if (NULL != abort_task)
1139 { 1142 {
1140 GNUNET_SCHEDULER_cancel(abort_task); 1143 GNUNET_SCHEDULER_cancel (abort_task);
1141 abort_task = NULL; 1144 abort_task = NULL;
1142 } 1145 }
1143 1146
1144 for (i = 0; i < num_peers; i++) 1147 for (i = 0; i < num_peers; i++)
1145 { 1148 {
1146 peers[i].peer_handle = testbed_peers[i]; 1149 peers[i].peer_handle = testbed_peers[i];
1147 } 1150 }
1148 if (GNUNET_NO == 1151 if (GNUNET_NO ==
1149 GNUNET_CONFIGURATION_get_value_yesno(cfg, "DHT", "DISABLE_TRY_CONNECT")) 1152 GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "DISABLE_TRY_CONNECT"))
1150 { 1153 {
1151 struct GNUNET_TIME_Relative settle_time; 1154 struct GNUNET_TIME_Relative settle_time;
1152 1155
1153 settle_time = 1156 settle_time =
1154 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1157 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1155 10 * num_peers); 1158 10 * num_peers);
1156 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1159 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1157 "Waiting for DHT for %s to settle new connections.\n\n", 1160 "Waiting for DHT for %s to settle new connections.\n\n",
1158 GNUNET_STRINGS_relative_time_to_string(settle_time, GNUNET_NO)); 1161 GNUNET_STRINGS_relative_time_to_string (settle_time,
1159 GNUNET_SCHEDULER_add_delayed(settle_time, &do_announce, NULL); 1162 GNUNET_NO));
1160 } 1163 GNUNET_SCHEDULER_add_delayed (settle_time, &do_announce, NULL);
1164 }
1161 else 1165 else
1162 { 1166 {
1163 GNUNET_SCHEDULER_add_now(&do_announce, NULL); 1167 GNUNET_SCHEDULER_add_now (&do_announce, NULL);
1164 } 1168 }
1165 search_timeout_task = 1169 search_timeout_task =
1166 GNUNET_SCHEDULER_add_delayed(search_timeout_time, &search_timed_out, NULL); 1170 GNUNET_SCHEDULER_add_delayed (search_timeout_time, &search_timed_out, NULL);
1167} 1171}
1168 1172
1169/** 1173/**
@@ -1173,23 +1177,23 @@ test_master(void *cls,
1173 * @param event information on what is happening 1177 * @param event information on what is happening
1174 */ 1178 */
1175static void 1179static void
1176master_controller_cb(void *cls, 1180master_controller_cb (void *cls,
1177 const struct GNUNET_TESTBED_EventInformation *event) 1181 const struct GNUNET_TESTBED_EventInformation *event)
1178{ 1182{
1179 switch (event->type) 1183 switch (event->type)
1180 { 1184 {
1181 case GNUNET_TESTBED_ET_CONNECT: 1185 case GNUNET_TESTBED_ET_CONNECT:
1182 printf("."); 1186 printf (".");
1183 break; 1187 break;
1184 1188
1185 case GNUNET_TESTBED_ET_PEER_START: 1189 case GNUNET_TESTBED_ET_PEER_START:
1186 printf("#"); 1190 printf ("#");
1187 break; 1191 break;
1188 1192
1189 default: 1193 default:
1190 break; 1194 break;
1191 } 1195 }
1192 fflush(stdout); 1196 fflush (stdout);
1193} 1197}
1194 1198
1195 1199
@@ -1208,9 +1212,9 @@ master_controller_cb(void *cls,
1208 * #GNUNET_SYSERR otherwise. 1212 * #GNUNET_SYSERR otherwise.
1209 */ 1213 */
1210static int 1214static int
1211count_and_separate_strings(char *data, 1215count_and_separate_strings (char *data,
1212 uint64_t data_size, 1216 uint64_t data_size,
1213 unsigned int str_max) 1217 unsigned int str_max)
1214{ 1218{
1215 char *buf; // Keep track of last string to skip blank lines 1219 char *buf; // Keep track of last string to skip blank lines
1216 unsigned int offset; 1220 unsigned int offset;
@@ -1220,19 +1224,19 @@ count_and_separate_strings(char *data,
1220 offset = 0; 1224 offset = 0;
1221 str_cnt = 0; 1225 str_cnt = 0;
1222 while ((offset < (data_size - 1)) && (str_cnt < str_max)) 1226 while ((offset < (data_size - 1)) && (str_cnt < str_max))
1227 {
1228 offset++;
1229 if (((data[offset] == '\n')) &&
1230 (buf != &data[offset]))
1223 { 1231 {
1224 offset++; 1232 data[offset] = '\0';
1225 if (((data[offset] == '\n')) && 1233 str_cnt++;
1226 (buf != &data[offset])) 1234 buf = &data[offset + 1];
1227 {
1228 data[offset] = '\0';
1229 str_cnt++;
1230 buf = &data[offset + 1];
1231 }
1232 else if ((data[offset] == '\n') ||
1233 (data[offset] == '\0'))
1234 buf = &data[offset + 1];
1235 } 1235 }
1236 else if ((data[offset] == '\n') ||
1237 (data[offset] == '\0'))
1238 buf = &data[offset + 1];
1239 }
1236 return str_cnt; 1240 return str_cnt;
1237} 1241}
1238 1242
@@ -1251,37 +1255,37 @@ count_and_separate_strings(char *data,
1251 * In case of error @a strings must not be freed. 1255 * In case of error @a strings must not be freed.
1252 */ 1256 */
1253static int 1257static int
1254create_string_array(char *data, uint64_t data_size, 1258create_string_array (char *data, uint64_t data_size,
1255 char ***strings, unsigned int str_cnt) 1259 char ***strings, unsigned int str_cnt)
1256{ 1260{
1257 uint64_t offset; 1261 uint64_t offset;
1258 uint64_t len; 1262 uint64_t len;
1259 unsigned int i; 1263 unsigned int i;
1260 1264
1261 *strings = GNUNET_malloc(sizeof(char *) * str_cnt); 1265 *strings = GNUNET_malloc (sizeof(char *) * str_cnt);
1262 offset = 0; 1266 offset = 0;
1263 for (i = 0; i < str_cnt; i++) 1267 for (i = 0; i < str_cnt; i++)
1268 {
1269 len = strlen (&data[offset]);
1270 if (offset + len >= data_size)
1271 {
1272 GNUNET_free (*strings);
1273 *strings = NULL;
1274 return GNUNET_SYSERR;
1275 }
1276 if (0 == len) // empty line
1264 { 1277 {
1265 len = strlen(&data[offset]); 1278 offset++;
1266 if (offset + len >= data_size) 1279 i--;
1267 { 1280 continue;
1268 GNUNET_free(*strings);
1269 *strings = NULL;
1270 return GNUNET_SYSERR;
1271 }
1272 if (0 == len) // empty line
1273 {
1274 offset++;
1275 i--;
1276 continue;
1277 }
1278
1279 GNUNET_asprintf(&(*strings)[i],
1280 "%s%s",
1281 regex_prefix,
1282 &data[offset]);
1283 offset += len + 1;
1284 } 1281 }
1282
1283 GNUNET_asprintf (&(*strings)[i],
1284 "%s%s",
1285 regex_prefix,
1286 &data[offset]);
1287 offset += len + 1;
1288 }
1285 return GNUNET_OK; 1289 return GNUNET_OK;
1286} 1290}
1287 1291
@@ -1296,9 +1300,9 @@ create_string_array(char *data, uint64_t data_size,
1296 * @return number of strings found in the file. #GNUNET_SYSERR on error. 1300 * @return number of strings found in the file. #GNUNET_SYSERR on error.
1297 */ 1301 */
1298static int 1302static int
1299load_search_strings(const char *filename, 1303load_search_strings (const char *filename,
1300 char ***strings, 1304 char ***strings,
1301 unsigned int limit) 1305 unsigned int limit)
1302{ 1306{
1303 char *data; 1307 char *data;
1304 uint64_t filesize; 1308 uint64_t filesize;
@@ -1306,54 +1310,54 @@ load_search_strings(const char *filename,
1306 1310
1307 /* Sanity checks */ 1311 /* Sanity checks */
1308 if (NULL == filename) 1312 if (NULL == filename)
1309 { 1313 {
1310 return GNUNET_SYSERR; 1314 return GNUNET_SYSERR;
1311 } 1315 }
1312 if (GNUNET_YES != GNUNET_DISK_file_test(filename)) 1316 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
1313 { 1317 {
1314 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1318 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1315 "Could not find search strings file %s\n", filename); 1319 "Could not find search strings file %s\n", filename);
1316 return GNUNET_SYSERR; 1320 return GNUNET_SYSERR;
1317 } 1321 }
1318 if (GNUNET_OK != 1322 if (GNUNET_OK !=
1319 GNUNET_DISK_file_size(filename, 1323 GNUNET_DISK_file_size (filename,
1320 &filesize, 1324 &filesize,
1321 GNUNET_YES, 1325 GNUNET_YES,
1322 GNUNET_YES)) 1326 GNUNET_YES))
1323 { 1327 {
1324 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1328 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1325 "Search strings file %s cannot be read.\n", 1329 "Search strings file %s cannot be read.\n",
1326 filename); 1330 filename);
1327 return GNUNET_SYSERR; 1331 return GNUNET_SYSERR;
1328 } 1332 }
1329 if (0 == filesize) 1333 if (0 == filesize)
1330 { 1334 {
1331 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1335 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1332 "Search strings file %s is empty.\n", 1336 "Search strings file %s is empty.\n",
1333 filename); 1337 filename);
1334 return GNUNET_SYSERR; 1338 return GNUNET_SYSERR;
1335 } 1339 }
1336 1340
1337 /* Read data into memory */ 1341 /* Read data into memory */
1338 data = GNUNET_malloc(filesize + 1); 1342 data = GNUNET_malloc (filesize + 1);
1339 if (filesize != GNUNET_DISK_fn_read(filename, 1343 if (filesize != GNUNET_DISK_fn_read (filename,
1340 data, 1344 data,
1341 filesize)) 1345 filesize))
1342 { 1346 {
1343 GNUNET_free(data); 1347 GNUNET_free (data);
1344 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1348 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1345 "Could not read search strings file %s.\n", 1349 "Could not read search strings file %s.\n",
1346 filename); 1350 filename);
1347 return GNUNET_SYSERR; 1351 return GNUNET_SYSERR;
1348 } 1352 }
1349 1353
1350 /* Process buffer and build array */ 1354 /* Process buffer and build array */
1351 str_cnt = count_and_separate_strings(data, filesize, limit); 1355 str_cnt = count_and_separate_strings (data, filesize, limit);
1352 if (GNUNET_OK != create_string_array(data, filesize, strings, str_cnt)) 1356 if (GNUNET_OK != create_string_array (data, filesize, strings, str_cnt))
1353 { 1357 {
1354 str_cnt = GNUNET_SYSERR; 1358 str_cnt = GNUNET_SYSERR;
1355 } 1359 }
1356 GNUNET_free(data); 1360 GNUNET_free (data);
1357 return str_cnt; 1361 return str_cnt;
1358} 1362}
1359 1363
@@ -1367,10 +1371,10 @@ load_search_strings(const char *filename,
1367 * @param config configuration 1371 * @param config configuration
1368 */ 1372 */
1369static void 1373static void
1370run(void *cls, 1374run (void *cls,
1371 char *const *args, 1375 char *const *args,
1372 const char *cfgfile, 1376 const char *cfgfile,
1373 const struct GNUNET_CONFIGURATION_Handle *config) 1377 const struct GNUNET_CONFIGURATION_Handle *config)
1374{ 1378{
1375 unsigned int nsearchstrs; 1379 unsigned int nsearchstrs;
1376 unsigned int i; 1380 unsigned int i;
@@ -1380,161 +1384,163 @@ run(void *cls,
1380 1384
1381 /* Check config */ 1385 /* Check config */
1382 if (NULL == config) 1386 if (NULL == config)
1383 { 1387 {
1384 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1388 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1385 _("No configuration file given. Exiting\n")); 1389 _ ("No configuration file given. Exiting\n"));
1386 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1390 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1387 return; 1391 return;
1388 } 1392 }
1389 cfg = GNUNET_CONFIGURATION_dup(config); 1393 cfg = GNUNET_CONFIGURATION_dup (config);
1390 if (GNUNET_OK != 1394 if (GNUNET_OK !=
1391 GNUNET_CONFIGURATION_get_value_string(cfg, "REGEXPROFILER", 1395 GNUNET_CONFIGURATION_get_value_string (cfg, "REGEXPROFILER",
1392 "REGEX_PREFIX", 1396 "REGEX_PREFIX",
1393 &regex_prefix)) 1397 &regex_prefix))
1394 { 1398 {
1395 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, 1399 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
1396 "regexprofiler", 1400 "regexprofiler",
1397 "regex_prefix"); 1401 "regex_prefix");
1398 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1402 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1399 return; 1403 return;
1400 } 1404 }
1401 if (GNUNET_OK != 1405 if (GNUNET_OK !=
1402 GNUNET_CONFIGURATION_get_value_number(cfg, "REGEXPROFILER", 1406 GNUNET_CONFIGURATION_get_value_number (cfg, "REGEXPROFILER",
1403 "PARALLEL_SEARCHES", 1407 "PARALLEL_SEARCHES",
1404 &init_parallel_searches)) 1408 &init_parallel_searches))
1405 { 1409 {
1406 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1410 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1407 "Configuration option \"PARALLEL_SEARCHES\" missing." 1411 "Configuration option \"PARALLEL_SEARCHES\" missing."
1408 " Using default (%d)\n", 10); 1412 " Using default (%d)\n", 10);
1409 init_parallel_searches = 10; 1413 init_parallel_searches = 10;
1410 } 1414 }
1411 if (GNUNET_OK != 1415 if (GNUNET_OK !=
1412 GNUNET_CONFIGURATION_get_value_time(cfg, "REGEXPROFILER", 1416 GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER",
1413 "REANNOUNCE_PERIOD_MAX", 1417 "REANNOUNCE_PERIOD_MAX",
1414 &reannounce_period_max)) 1418 &reannounce_period_max))
1415 { 1419 {
1416 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1420 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1417 "reannounce_period_max not given. Using 10 minutes.\n"); 1421 "reannounce_period_max not given. Using 10 minutes.\n");
1418 reannounce_period_max = 1422 reannounce_period_max =
1419 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 10); 1423 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
1420 } 1424 }
1421 1425
1422 /* Check arguments */ 1426 /* Check arguments */
1423 if (NULL == policy_dir) 1427 if (NULL == policy_dir)
1424 { 1428 {
1425 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1429 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1426 _("No policy directory specified on command line. Exiting.\n")); 1430 _ (
1427 return; 1431 "No policy directory specified on command line. Exiting.\n"));
1428 } 1432 return;
1429 if (GNUNET_YES != GNUNET_DISK_directory_test(policy_dir, GNUNET_YES)) 1433 }
1430 { 1434 if (GNUNET_YES != GNUNET_DISK_directory_test (policy_dir, GNUNET_YES))
1431 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1435 {
1432 _("Specified policies directory does not exist. Exiting.\n")); 1436 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1433 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1437 _ ("Specified policies directory does not exist. Exiting.\n"));
1434 return; 1438 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1435 } 1439 return;
1436 if (0 >= (int)(num_peers = GNUNET_DISK_directory_scan(policy_dir, NULL, NULL))) 1440 }
1437 { 1441 if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL,
1438 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1442 NULL)))
1439 _("No files found in `%s'\n"), 1443 {
1440 policy_dir); 1444 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1441 return; 1445 _ ("No files found in `%s'\n"),
1442 } 1446 policy_dir);
1443 GNUNET_CONFIGURATION_set_value_string(cfg, "REGEXPROFILER", 1447 return;
1444 "POLICY_DIR", policy_dir); 1448 }
1445 if (GNUNET_YES != GNUNET_DISK_file_test(strings_file)) 1449 GNUNET_CONFIGURATION_set_value_string (cfg, "REGEXPROFILER",
1446 { 1450 "POLICY_DIR", policy_dir);
1447 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1451 if (GNUNET_YES != GNUNET_DISK_file_test (strings_file))
1448 _("No search strings file given. Exiting.\n")); 1452 {
1449 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1453 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1450 return; 1454 _ ("No search strings file given. Exiting.\n"));
1451 } 1455 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1452 nsearchstrs = load_search_strings(strings_file, 1456 return;
1453 &search_strings, 1457 }
1454 num_peers); 1458 nsearchstrs = load_search_strings (strings_file,
1459 &search_strings,
1460 num_peers);
1455 if (num_peers != nsearchstrs) 1461 if (num_peers != nsearchstrs)
1456 { 1462 {
1457 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1463 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1458 "Error loading search strings.\n"); 1464 "Error loading search strings.\n");
1459 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1465 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1460 "File (%s) does not contain enough strings (%u/%u).\n", 1466 "File (%s) does not contain enough strings (%u/%u).\n",
1461 strings_file, nsearchstrs, num_peers); 1467 strings_file, nsearchstrs, num_peers);
1462 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1468 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1463 return; 1469 return;
1464 } 1470 }
1465 if ((0 == num_peers) || (NULL == search_strings)) 1471 if ((0 == num_peers) || (NULL == search_strings))
1466 { 1472 {
1467 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 1473 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1468 _("Error loading search strings. Exiting.\n")); 1474 _ ("Error loading search strings. Exiting.\n"));
1469 GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 1475 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1470 return; 1476 return;
1471 } 1477 }
1472 for (i = 0; i < num_peers; i++) 1478 for (i = 0; i < num_peers; i++)
1473 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1474 "search string: %s\n", 1480 "search string: %s\n",
1475 search_strings[i]); 1481 search_strings[i]);
1476 1482
1477 /* Check logfile */ 1483 /* Check logfile */
1478 if ((NULL != data_filename) && 1484 if ((NULL != data_filename) &&
1479 (NULL == (data_file = 1485 (NULL == (data_file =
1480 GNUNET_DISK_file_open(data_filename, 1486 GNUNET_DISK_file_open (data_filename,
1481 GNUNET_DISK_OPEN_READWRITE | 1487 GNUNET_DISK_OPEN_READWRITE
1482 GNUNET_DISK_OPEN_TRUNCATE | 1488 | GNUNET_DISK_OPEN_TRUNCATE
1483 GNUNET_DISK_OPEN_CREATE, 1489 | GNUNET_DISK_OPEN_CREATE,
1484 GNUNET_DISK_PERM_USER_READ | 1490 GNUNET_DISK_PERM_USER_READ
1485 GNUNET_DISK_PERM_USER_WRITE)))) 1491 | GNUNET_DISK_PERM_USER_WRITE))))
1486 { 1492 {
1487 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, 1493 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
1488 "open", 1494 "open",
1489 data_filename); 1495 data_filename);
1490 return; 1496 return;
1491 } 1497 }
1492 1498
1493 /* Initialize peers */ 1499 /* Initialize peers */
1494 peers = GNUNET_malloc(sizeof(struct RegexPeer) * num_peers); 1500 peers = GNUNET_malloc (sizeof(struct RegexPeer) * num_peers);
1495 for (i = 0; i < num_peers; i++) 1501 for (i = 0; i < num_peers; i++)
1496 peers[i].id = i; 1502 peers[i].id = i;
1497 1503
1498 GNUNET_CONFIGURATION_set_value_number(cfg, 1504 GNUNET_CONFIGURATION_set_value_number (cfg,
1499 "TESTBED", "OVERLAY_RANDOM_LINKS", 1505 "TESTBED", "OVERLAY_RANDOM_LINKS",
1500 num_peers * 20); 1506 num_peers * 20);
1501 GNUNET_CONFIGURATION_set_value_number(cfg, 1507 GNUNET_CONFIGURATION_set_value_number (cfg,
1502 "DHT", "FORCE_NSE", 1508 "DHT", "FORCE_NSE",
1503 (long long unsigned) 1509 (long long unsigned)
1504 (log(num_peers) / log(2.0))); 1510 (log (num_peers) / log (2.0)));
1505 event_mask = 0LL; 1511 event_mask = 0LL;
1506/* For feedback about the start process activate these and pass master_cb */ 1512/* For feedback about the start process activate these and pass master_cb */
1507 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); 1513 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
1508// event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); 1514// event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
1509 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 1515 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1510// event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT); 1516// event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
1511 prof_start_time = GNUNET_TIME_absolute_get(); 1517 prof_start_time = GNUNET_TIME_absolute_get ();
1512 GNUNET_TESTBED_run(hosts_file, 1518 GNUNET_TESTBED_run (hosts_file,
1513 cfg, 1519 cfg,
1514 num_peers, 1520 num_peers,
1515 event_mask, 1521 event_mask,
1516 &master_controller_cb, 1522 &master_controller_cb,
1517 NULL, /* master_controller_cb cls */ 1523 NULL, /* master_controller_cb cls */
1518 &test_master, 1524 &test_master,
1519 NULL); /* test_master cls */ 1525 NULL); /* test_master cls */
1520 if (GNUNET_OK != 1526 if (GNUNET_OK !=
1521 GNUNET_CONFIGURATION_get_value_time(cfg, "TESTBED", 1527 GNUNET_CONFIGURATION_get_value_time (cfg, "TESTBED",
1522 "SETUP_TIMEOUT", 1528 "SETUP_TIMEOUT",
1523 &abort_time)) 1529 &abort_time))
1524 { 1530 {
1525 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1531 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1526 "SETUP_TIMEOUT not given. Using 15 minutes.\n"); 1532 "SETUP_TIMEOUT not given. Using 15 minutes.\n");
1527 abort_time = 1533 abort_time =
1528 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 15); 1534 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
1529 } 1535 }
1530 abort_time = GNUNET_TIME_relative_add(abort_time, GNUNET_TIME_UNIT_MINUTES); 1536 abort_time = GNUNET_TIME_relative_add (abort_time, GNUNET_TIME_UNIT_MINUTES);
1531 abort_task = 1537 abort_task =
1532 GNUNET_SCHEDULER_add_delayed(abort_time, 1538 GNUNET_SCHEDULER_add_delayed (abort_time,
1533 &do_abort, 1539 &do_abort,
1534 (void*)__LINE__); 1540 (void*) __LINE__);
1535 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 1541 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1536 "setup_timeout: %s\n", 1542 "setup_timeout: %s\n",
1537 GNUNET_STRINGS_relative_time_to_string(abort_time, GNUNET_YES)); 1543 GNUNET_STRINGS_relative_time_to_string (abort_time, GNUNET_YES));
1538} 1544}
1539 1545
1540 1546
@@ -1546,52 +1552,56 @@ run(void *cls,
1546 * @return 0 on success 1552 * @return 0 on success
1547 */ 1553 */
1548int 1554int
1549main(int argc, char *const *argv) 1555main (int argc, char *const *argv)
1550{ 1556{
1551 struct GNUNET_GETOPT_CommandLineOption options[] = { 1557 struct GNUNET_GETOPT_CommandLineOption options[] = {
1552 GNUNET_GETOPT_option_filename('o', 1558 GNUNET_GETOPT_option_filename ('o',
1553 "output-file", 1559 "output-file",
1554 "FILENAME", 1560 "FILENAME",
1555 gettext_noop("name of the file for writing statistics"), 1561 gettext_noop (
1556 &data_filename), 1562 "name of the file for writing statistics"),
1557 1563 &data_filename),
1558 GNUNET_GETOPT_option_relative_time('t', 1564
1559 "matching-timeout", 1565 GNUNET_GETOPT_option_relative_time ('t',
1560 "TIMEOUT", 1566 "matching-timeout",
1561 gettext_noop("wait TIMEOUT before ending the experiment"), 1567 "TIMEOUT",
1562 &search_timeout_time), 1568 gettext_noop (
1563 1569 "wait TIMEOUT before ending the experiment"),
1564 GNUNET_GETOPT_option_filename('p', 1570 &search_timeout_time),
1565 "policy-dir", 1571
1566 "DIRECTORY", 1572 GNUNET_GETOPT_option_filename ('p',
1567 gettext_noop("directory with policy files"), 1573 "policy-dir",
1568 &policy_dir), 1574 "DIRECTORY",
1569 1575 gettext_noop ("directory with policy files"),
1570 1576 &policy_dir),
1571 GNUNET_GETOPT_option_filename('s', 1577
1572 "strings-file", 1578
1573 "FILENAME", 1579 GNUNET_GETOPT_option_filename ('s',
1574 gettext_noop("name of file with input strings"), 1580 "strings-file",
1575 &strings_file), 1581 "FILENAME",
1576 1582 gettext_noop (
1577 GNUNET_GETOPT_option_filename('H', 1583 "name of file with input strings"),
1578 "hosts-file", 1584 &strings_file),
1579 "FILENAME", 1585
1580 gettext_noop("name of file with hosts' names"), 1586 GNUNET_GETOPT_option_filename ('H',
1581 &hosts_file), 1587 "hosts-file",
1588 "FILENAME",
1589 gettext_noop (
1590 "name of file with hosts' names"),
1591 &hosts_file),
1582 1592
1583 GNUNET_GETOPT_OPTION_END 1593 GNUNET_GETOPT_OPTION_END
1584 }; 1594 };
1585 int ret; 1595 int ret;
1586 1596
1587 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 1597 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1588 return 2; 1598 return 2;
1589 result = GNUNET_SYSERR; 1599 result = GNUNET_SYSERR;
1590 ret = 1600 ret =
1591 GNUNET_PROGRAM_run(argc, argv, 1601 GNUNET_PROGRAM_run (argc, argv,
1592 "gnunet-regex-profiler", 1602 "gnunet-regex-profiler",
1593 _("Profiler for regex"), 1603 _ ("Profiler for regex"),
1594 options, &run, NULL); 1604 options, &run, NULL);
1595 if (GNUNET_OK != ret) 1605 if (GNUNET_OK != ret)
1596 return ret; 1606 return ret;
1597 if (GNUNET_OK != result) 1607 if (GNUNET_OK != result)