From: Matthias Wachs Date: Wed, 28 Apr 2010 08:55:59 +0000 (+0000) Subject: - Implemented download limit on client side X-Git-Tag: initial-import-from-subversion-38251~21985 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=43bb2e8d1def0d823a876e30f50bca941e351da0;p=oweals%2Fgnunet.git - Implemented download limit on client side - Disabled verbose --- diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 82f4b78ac..d5cd4ac79 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -36,7 +36,7 @@ #include "gnunet_common.h" #include "gnunet_bio_lib.h" -#define DEBUG_HOSTLIST_CLIENT GNUNET_YES +#define DEBUG_HOSTLIST_CLIENT GNUNET_NO /** @@ -151,7 +151,7 @@ static CURLM *multi; /** * */ -static uint32_t bytes_downloaded; +static uint32_t stat_bytes_downloaded; /** * Amount of time we wait between hostlist downloads. */ @@ -280,16 +280,12 @@ callback_download (void *ptr, uint16_t msize; total = size * nmemb; - bytes_downloaded = total; + stat_bytes_downloaded += total; if ( (total == 0) || (stat_bogus_url) ) { return total; /* ok, no data or bogus data */ } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Total: %u, nmeb: %u, size %u \n"), - total, nmemb, size); - GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes downloaded from hostlist servers"), (int64_t) total, @@ -711,7 +707,7 @@ clean_up () } GNUNET_free_non_null (current_url); current_url = NULL; - bytes_downloaded = 0; + stat_bytes_downloaded = 0; stat_download_in_progress = GNUNET_NO; } @@ -808,7 +804,6 @@ task_download (void *cls, struct CURLMsg *msg; CURLMcode mret; - bytes_downloaded = 0; ti_download = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) { @@ -838,7 +833,7 @@ task_download (void *cls, do { running = 0; - if (bytes_downloaded > MAX_BYTES_PER_HOSTLISTS) + if (stat_bytes_downloaded > MAX_BYTES_PER_HOSTLISTS) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Download limit of %u bytes exceeded, stopping download\n"),MAX_BYTES_PER_HOSTLISTS); @@ -937,6 +932,7 @@ download_hostlist () stat_download_in_progress = GNUNET_YES; stat_download_successful = GNUNET_NO; stat_hellos_obtained = 0; + stat_bytes_downloaded = 0; GNUNET_STATISTICS_update (stats, gettext_noop ("# hostlist downloads initiated"), diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/hostlist-client.h index ad4b59223..def2c633e 100644 --- a/src/hostlist/hostlist-client.h +++ b/src/hostlist/hostlist-client.h @@ -33,7 +33,7 @@ #include "gnunet_time_lib.h" #define MAX_NUMBER_HOSTLISTS 30 -#define MAX_BYTES_PER_HOSTLISTS 50000 +#define MAX_BYTES_PER_HOSTLISTS 100000 #define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) #define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) #define WAITING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index cd22226f1..ab7465dc1 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -30,7 +30,7 @@ #include "gnunet_resolver_service.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO #define START_ARM GNUNET_YES #define MAX_URL_LEN 1000 @@ -43,14 +43,10 @@ static int timeout; static int adv_sent; +static int adv_arrived; -static int adv_arrived_p1; -static int learned_hostlist_saved_p1; -static int learned_hostlist_downloaded_p1; - -static int adv_arrived_p2; -static int learned_hostlist_saved_p2; -static int learned_hostlist_downloaded_p2; +static int learned_hostlist_saved; +static int learned_hostlist_downloaded; static char * current_adv_uri; @@ -76,9 +72,6 @@ static struct PeerContext adv_peer; static struct PeerContext learn_peer; -static struct PeerContext learn_peer2; - - static void waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -144,12 +137,6 @@ static void shutdown_testcase() GNUNET_TRANSPORT_disconnect (learn_peer.th); learn_peer.th = NULL; } - /* - if (learn_peer2.th != NULL) - { - GNUNET_TRANSPORT_disconnect (learn_peer2.th); - learn_peer2.th = NULL; - }*/ if (adv_peer.core != NULL) { GNUNET_CORE_disconnect (adv_peer.core); @@ -160,20 +147,11 @@ static void shutdown_testcase() GNUNET_CORE_disconnect (learn_peer.core); learn_peer.core = NULL; } - /* - if (learn_peer2.core != NULL) - { - GNUNET_CORE_disconnect (learn_peer2.core); - learn_peer2.core = NULL; - }*/ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core services\n"); learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL); GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, &stop_cb, &learn_peer); - /* learn_peer2.arm = GNUNET_ARM_connect (learn_peer2.cfg, sched, NULL); - GNUNET_ARM_stop_service (learn_peer2.arm, "core", GNUNET_TIME_UNIT_SECONDS, - &stop_cb, &learn_peer2);*/ adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL); GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, &stop_cb, &adv_peer); @@ -203,20 +181,13 @@ process_downloads (void *cls, { - if ( ((struct PeerContext *) cls == &learn_peer) && (value == 2) && (learned_hostlist_downloaded_p1 == GNUNET_NO) ) + if ( ((struct PeerContext *) cls == &learn_peer) && (value == 2) && (learned_hostlist_downloaded == GNUNET_NO) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Peer1 has successfully downloaded advertised URI \n")); - learned_hostlist_downloaded_p1 = GNUNET_YES; + _("Peer has successfully downloaded advertised URI \n")); + learned_hostlist_downloaded = GNUNET_YES; } - /* - if ( ((struct PeerContext *) cls == &learn_peer2) && (value == 2) && (learned_hostlist_downloaded_p2 == GNUNET_NO) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Peer2 has successfully downloaded advertised URI \n")); - learned_hostlist_downloaded_p2 = GNUNET_YES; - }*/ - if ( (GNUNET_NO != learned_hostlist_downloaded_p1) /*&& (GNUNET_NO != learned_hostlist_downloaded_p2)*/ ) + if (GNUNET_NO != learned_hostlist_downloaded) shutdown_testcase(); return GNUNET_OK; } @@ -228,19 +199,12 @@ process_uris_recv (void *cls, uint64_t value, int is_persistent) { - if ( ((struct PeerContext *) cls == &learn_peer) && (value == 1) && (learned_hostlist_saved_p1 == GNUNET_NO)) + if ( ((struct PeerContext *) cls == &learn_peer) && (value == 1) && (learned_hostlist_saved == GNUNET_NO)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Peer1 has successfully saved advertised URI \n")); - learned_hostlist_saved_p1 = GNUNET_YES; + _("Peer has successfully saved advertised URI \n")); + learned_hostlist_saved = GNUNET_YES; } - /* - if ( ((struct PeerContext *) cls == &learn_peer2) && (value == 1) && (learned_hostlist_saved_p2 == GNUNET_NO)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Peer2 has successfully saved advertised URI \n")); - learned_hostlist_saved_p2 = GNUNET_YES; - }*/ return GNUNET_OK; } @@ -278,13 +242,6 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) NULL, &process_downloads, &learn_peer); - /*GNUNET_STATISTICS_get (learn_peer2.stats, - "hostlist", - stat, - GNUNET_TIME_UNIT_MINUTES, - NULL, - &process_downloads, - &learn_peer2);*/ GNUNET_free (stat); GNUNET_STATISTICS_get (learn_peer.stats, @@ -294,13 +251,6 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) NULL, &process_uris_recv, &learn_peer); - /*GNUNET_STATISTICS_get (learn_peer2.stats, - "hostlist", - gettext_noop("# advertised hostlist URIs"), - GNUNET_TIME_UNIT_MINUTES, - NULL, - &process_uris_recv, - &learn_peer2);*/ GNUNET_STATISTICS_get (adv_peer.stats, "hostlist", gettext_noop("# hostlist advertisements send"), @@ -363,8 +313,7 @@ static int ad_arrive_handler (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); - adv_arrived_p1 = GNUNET_YES; - adv_arrived_p2 = GNUNET_YES; + adv_arrived = GNUNET_YES; } else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -456,13 +405,9 @@ run (void *cls, timeout = GNUNET_NO; adv_sent =GNUNET_NO; - adv_arrived_p1 = GNUNET_NO; - learned_hostlist_downloaded_p1 = GNUNET_NO; - learned_hostlist_saved_p1 = GNUNET_NO; - - /*adv_arrived_p2 = GNUNET_NO; - learned_hostlist_downloaded_p2 = GNUNET_NO; - learned_hostlist_saved_p2 = GNUNET_NO;*/ + adv_arrived = 0; + learned_hostlist_saved = GNUNET_NO; + learned_hostlist_downloaded = GNUNET_NO; sched = s; timeout_task = GNUNET_SCHEDULER_add_delayed (sched, @@ -476,8 +421,6 @@ run (void *cls, setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); - // setup_learn_peer (&learn_peer2, "test_learning_learn_peer2.conf"); - } @@ -508,44 +451,24 @@ check () "Testcase could not set up two communicating peers, timeout\n"); failed = GNUNET_YES; } - if (adv_arrived_p1 == GNUNET_NO) + if (adv_arrived != GNUNET_YES) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Peer1: Learning peer did not recieve advertisement from server\n"); + "Learning peer did not receive advertisement from server\n"); failed = GNUNET_YES; } - if ( learned_hostlist_saved_p1 == GNUNET_NO ) + if ( learned_hostlist_saved == GNUNET_NO ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer1: Advertised hostlist was not saved in datastore\n"); failed = GNUNET_YES; } - if (learned_hostlist_downloaded_p1 == GNUNET_NO) + if (learned_hostlist_downloaded == GNUNET_NO) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer1: Advertised hostlist could not be downloaded from server\n"); failed = GNUNET_YES; } - /* - if (adv_arrived_p2 == GNUNET_NO) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Peer2: Learning peer did not recieve advertisement from server\n"); - failed = GNUNET_YES; - } - if ( learned_hostlist_saved_p2 == GNUNET_NO ) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Peer2: Advertised hostlist was not saved in datastore\n"); - failed = GNUNET_YES; - } - if (learned_hostlist_downloaded_p2 == GNUNET_NO) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Peer2: Advertised hostlist could not be downloaded from server\n"); - failed = GNUNET_YES; - }*/ - if (adv_sent == GNUNET_NO) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/hostlist/test_learning_adv_peer.conf b/src/hostlist/test_learning_adv_peer.conf index 3423af138..8a26c585a 100644 --- a/src/hostlist/test_learning_adv_peer.conf +++ b/src/hostlist/test_learning_adv_peer.conf @@ -36,7 +36,7 @@ WEAKRANDOM = YES [hostlist] HTTPPORT = 12981 SERVERS = http://localhost:12981/ -OPTIONS = -p -a -b -e +OPTIONS = -p -a #OPTIONS = -b -p -a #DEBUG = YES HOSTLISTFILE = hostlists_adv_peer.file