diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-08 15:04:27 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-08 15:04:27 +0000 |
commit | 02842f3f05e1cd5030bb56541645581a75f7b788 (patch) | |
tree | 14b35153df7a0560df061230b6a267bf2796fddd /src/transport/gnunet-transport.c | |
parent | cc87f4c8038dd68ad00743490cf71728ed3b1cba (diff) | |
download | gnunet-02842f3f05e1cd5030bb56541645581a75f7b788.tar.gz gnunet-02842f3f05e1cd5030bb56541645581a75f7b788.zip |
fixed -b semantics: receive from all peers
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 521433467..d83e9638f 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -510,20 +510,6 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
510 | GNUNET_break (0); | 510 | GNUNET_break (0); |
511 | return; | 511 | return; |
512 | } | 512 | } |
513 | if (benchmark_receive) | ||
514 | { | ||
515 | if (verbosity > 0) | ||
516 | FPRINTF (stdout, _("Successfully connected to `%s', starting to receive benchmark data\n"), | ||
517 | GNUNET_i2s (&pid)); | ||
518 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | ||
519 | { | ||
520 | GNUNET_SCHEDULER_cancel (op_timeout); | ||
521 | op_timeout = GNUNET_SCHEDULER_NO_TASK; | ||
522 | } | ||
523 | |||
524 | start_time = GNUNET_TIME_absolute_get (); | ||
525 | return; | ||
526 | } | ||
527 | } | 513 | } |
528 | 514 | ||
529 | 515 | ||
@@ -622,15 +608,9 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
622 | { | 608 | { |
623 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) | 609 | if (GNUNET_MESSAGE_TYPE_DUMMY != ntohs (message->type)) |
624 | return; | 610 | return; |
625 | 611 | if (verbosity > 0) | |
626 | if (0 == memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity))) | 612 | FPRINTF (stdout, _("Received %u bytes from %s\n"), |
627 | { | 613 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); |
628 | if (verbosity > 0) | ||
629 | FPRINTF (stdout, _("Received %u bytes from %s\n"), | ||
630 | (unsigned int) ntohs (message->size), GNUNET_i2s (peer)); | ||
631 | } | ||
632 | else | ||
633 | /* Received data from other peer*/ return; | ||
634 | 614 | ||
635 | if (traffic_received == 0) | 615 | if (traffic_received == 0) |
636 | start_time = GNUNET_TIME_absolute_get (); | 616 | start_time = GNUNET_TIME_absolute_get (); |
@@ -753,7 +733,7 @@ testservice_task (void *cls, | |||
753 | return; | 733 | return; |
754 | } | 734 | } |
755 | 735 | ||
756 | if (try_connect) | 736 | if (try_connect) /* -C: Connect to peer */ |
757 | { | 737 | { |
758 | if (NULL == cpid) | 738 | if (NULL == cpid) |
759 | { | 739 | { |
@@ -777,7 +757,7 @@ testservice_task (void *cls, | |||
777 | &operation_timeout, NULL); | 757 | &operation_timeout, NULL); |
778 | 758 | ||
779 | } | 759 | } |
780 | else if (benchmark_send) /* Benchmark sending */ | 760 | else if (benchmark_send) /* -s: Benchmark sending */ |
781 | { | 761 | { |
782 | if (NULL == cpid) | 762 | if (NULL == cpid) |
783 | { | 763 | { |
@@ -801,28 +781,21 @@ testservice_task (void *cls, | |||
801 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, | 781 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, |
802 | &operation_timeout, NULL); | 782 | &operation_timeout, NULL); |
803 | } | 783 | } |
804 | else if (benchmark_receive) /* Benchmark receiving */ | 784 | else if (benchmark_receive) /* -b: Benchmark receiving */ |
805 | { | 785 | { |
806 | if (NULL == cpid) | ||
807 | { | ||
808 | FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), | ||
809 | "-b", "-p"); | ||
810 | ret = 1; | ||
811 | return; | ||
812 | } | ||
813 | handle = | 786 | handle = |
814 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, | 787 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, ¬ify_receive, |
815 | ¬ify_connect, ¬ify_disconnect); | 788 | NULL, NULL); |
816 | if (NULL == handle) | 789 | if (NULL == handle) |
817 | { | 790 | { |
818 | FPRINTF (stderr, _("Failed to connect to transport service\n")); | 791 | FPRINTF (stderr, _("Failed to connect to transport service\n")); |
819 | ret = 1; | 792 | ret = 1; |
820 | return; | 793 | return; |
821 | } | 794 | } |
822 | GNUNET_TRANSPORT_try_connect (handle, &pid); | 795 | if (verbosity > 0) |
796 | FPRINTF (stdout, _("Starting to receive benchmark data\n")); | ||
823 | start_time = GNUNET_TIME_absolute_get (); | 797 | start_time = GNUNET_TIME_absolute_get (); |
824 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, | 798 | |
825 | &operation_timeout, NULL); | ||
826 | } | 799 | } |
827 | else if (iterate_connections) /* -i: List all active addresses once */ | 800 | else if (iterate_connections) /* -i: List all active addresses once */ |
828 | { | 801 | { |
@@ -900,7 +873,7 @@ main (int argc, char *const *argv) | |||
900 | int res; | 873 | int res; |
901 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 874 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
902 | {'b', "benchmark", NULL, | 875 | {'b', "benchmark", NULL, |
903 | gettext_noop ("measure how fast we are receiving data (until CTRL-C)"), | 876 | gettext_noop ("measure how fast we are receiving data from all peers (until CTRL-C)"), |
904 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive}, | 877 | 0, &GNUNET_GETOPT_set_one, &benchmark_receive}, |
905 | {'C', "connect", NULL, | 878 | {'C', "connect", NULL, |
906 | gettext_noop ("connect to a peer"), | 879 | gettext_noop ("connect to a peer"), |