diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-06-05 21:33:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-06-05 21:33:58 +0000 |
commit | a998e0abbd220035bdb333388da229852980e2cc (patch) | |
tree | addf062abb3cc68ab1103a415fbdec315dd54a63 /src/transport/gnunet-transport.c | |
parent | 4ce2d673d41ad8a8b9e5389b5b97ecb5e77f190d (diff) | |
download | gnunet-a998e0abbd220035bdb333388da229852980e2cc.tar.gz gnunet-a998e0abbd220035bdb333388da229852980e2cc.zip |
-cleaning up client api to test for service availability
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 1c3b5e59c..c03d6a388 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -792,23 +792,32 @@ void try_connect_cb (void *cls, | |||
792 | } | 792 | } |
793 | 793 | ||
794 | 794 | ||
795 | /** | ||
796 | * Function called with the result of the check if the 'transport' | ||
797 | * service is running. | ||
798 | * | ||
799 | * @param cls closure with our configuration | ||
800 | * @param result GNUNET_YES if transport is running | ||
801 | */ | ||
795 | static void | 802 | static void |
796 | testservice_task (void *cls, | 803 | testservice_task (void *cls, |
797 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 804 | int result) |
798 | { | 805 | { |
799 | int counter = 0; | 806 | int counter = 0; |
800 | ret = 1; | 807 | ret = 1; |
801 | 808 | ||
802 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 809 | if (GNUNET_YES != result) |
803 | { | 810 | { |
804 | FPRINTF (stderr, _("Service `%s' is not running\n"), "transport"); | 811 | FPRINTF (stderr, |
805 | return; | 812 | _("Service `%s' is not running\n"), "transport"); |
813 | return; | ||
806 | } | 814 | } |
807 | 815 | ||
808 | if ((NULL != cpid) && (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))) | 816 | if ( (NULL != cpid) && |
817 | (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey))) | ||
809 | { | 818 | { |
810 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); | 819 | FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid); |
811 | return; | 820 | return; |
812 | } | 821 | } |
813 | 822 | ||
814 | counter = benchmark_send + benchmark_receive + iterate_connections + | 823 | counter = benchmark_send + benchmark_receive + iterate_connections + |
@@ -970,11 +979,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
970 | do_test_configuration (cfg); | 979 | do_test_configuration (cfg); |
971 | return; | 980 | return; |
972 | } | 981 | } |
973 | |||
974 | GNUNET_CLIENT_service_test ("transport", cfg, | 982 | GNUNET_CLIENT_service_test ("transport", cfg, |
975 | GNUNET_TIME_UNIT_SECONDS, | 983 | GNUNET_TIME_UNIT_SECONDS, |
976 | &testservice_task, | 984 | &testservice_task, |
977 | (void *) cfg); | 985 | (void *) cfg); |
978 | } | 986 | } |
979 | 987 | ||
980 | 988 | ||