X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Ftest_gnunet_service_fs_p2p.c;h=7ca786ed2a97c3dd6924da917b3e2072c715798f;hb=99c66999a525b2783982ffa7590c988529184482;hp=aece0e80ac72eec626aa01b9e23b27e7cadd6afc;hpb=5746309cb4be2073d550ad7a6885e918631dbc38;p=oweals%2Fgnunet.git diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index aece0e80a..7ca786ed2 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -48,14 +48,21 @@ static int ok; static struct GNUNET_TIME_Absolute start_time; +static struct GNUNET_FS_TEST_ConnectContext *cc; + static void do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TIME_Relative del; char *fancy; + if (NULL != cc) + { + GNUNET_FS_TEST_daemons_connect_cancel (cc); + cc = NULL; + } GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) + if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) { del = GNUNET_TIME_absolute_get_duration (start_time); if (del.rel_value == 0) @@ -63,7 +70,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fancy = GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) * 1000LL / del.rel_value); - fprintf (stdout, "Download speed was %s/s\n", fancy); + FPRINTF (stdout, "Download speed was %s/s\n", fancy); GNUNET_free (fancy); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); @@ -99,6 +106,7 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) static void do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + cc = NULL; if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); @@ -120,8 +128,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, - NULL); + cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, + &do_publish, NULL); }