static void do_download (void *cls, const char *emsg) { struct DownloadContext *dc = cls; struct GNUNET_FS_Uri *uri = dc->uri; GNUNET_TESTBED_operation_done (op); op = NULL; if (NULL != dc->fn) { GNUNET_DISK_directory_remove (dc->fn); GNUNET_free (dc->fn); } GNUNET_free (dc); if (NULL != emsg) { GNUNET_SCHEDULER_shutdown (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n", emsg); GNUNET_FS_uri_destroy (uri); ok = 1; return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); GNUNET_FS_uri_destroy (uri); }
static void do_downloads (void *cls, const struct GNUNET_FS_Uri *u2, const char *fn) { int anonymity; unsigned int i; if (NULL == u2) { cleanup (); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during upload attempt, shutting down with error\n"); ok = 1; return; } if (NULL != fn) fn2 = GNUNET_strdup (fn); uri2 = GNUNET_FS_uri_dup (u2); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); if (NULL != strstr (progname, "dht")) anonymity = 0; else anonymity = 1; /* (semi) leach-download(s); not true leaches since * these peers do participate in sharing, they just * don't have to offer anything *initially*. */ for (i = 0; i < NUM_DAEMONS - 2; i++) GNUNET_FS_TEST_download (daemons[i], TIMEOUT, anonymity, 0 == (i % 2) ? SEED1 : SEED2, 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report, "leach"); /* mutual downloads of (primary) sharing peers */ GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1, uri1, VERBOSE, &do_report, "seeder 2"); GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2, uri2, VERBOSE, &do_report, "seeder 1"); }
static void do_download (void *cls, const struct GNUNET_FS_Uri *uri, const char *fn) { if (NULL == uri) { GNUNET_break (0); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, (NULL == fn) ? NULL : GNUNET_strdup (fn)); }