From 97c255a2ec844e63cd116f6e804b629185302e85 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 26 Apr 2010 15:31:07 +0000 Subject: [PATCH] --- src/hostlist/hostlist-client.c | 27 ++++++++--- src/hostlist/hostlist-client.h | 2 +- src/hostlist/hostlist-server.c | 12 +++-- src/hostlist/hostlists_adv_peer.file | 0 .../test_gnunet_daemon_hostlist_learning.c | 17 +++++++ src/hostlist/test_learning_adv_peer.conf | 9 ++-- src/hostlist/test_learning_learn_peer.conf | 5 +- src/hostlist/test_learning_learn_peer2.conf | 47 +++++++++++++++++++ 8 files changed, 102 insertions(+), 17 deletions(-) create mode 100644 src/hostlist/hostlists_adv_peer.file create mode 100644 src/hostlist/test_learning_learn_peer2.conf diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 6e61586ae..8e78dd809 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -252,6 +252,7 @@ static unsigned int stat_hellos_obtained; */ static unsigned int stat_connection_count; +unsigned int downloaded_hellos; /** * Process downloaded bits by calling callback on each HELLO. @@ -280,6 +281,15 @@ callback_download (void *ptr, { return total; /* ok, no data or bogus data */ } + + if ( downloaded_hellos >= MAX_HELLO_PER_HOSTLISTS ) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("Maximum number of HELLO Messages per download reached: %u'\n"), + MAX_HELLO_PER_HOSTLISTS ); + return total; + + } GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes downloaded from hostlist servers"), (int64_t) total, @@ -311,7 +321,9 @@ callback_download (void *ptr, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Invalid `%s' message received from hostlist at `%s'\n"), "HELLO", - current_url); + current_url); + stat_hellos_obtained++; + downloaded_hellos++; stat_bogus_url = 1; return total; } @@ -332,6 +344,7 @@ callback_download (void *ptr, 1, GNUNET_NO); stat_hellos_obtained++; + downloaded_hellos++; GNUNET_TRANSPORT_offer_hello (transport, msg); } else @@ -345,6 +358,8 @@ callback_download (void *ptr, "HELLO", current_url); stat_bogus_url = GNUNET_YES; + stat_hellos_obtained++; + downloaded_hellos++; return total; } memmove (download_buffer, @@ -674,7 +689,6 @@ clean_up () hostlist_to_test = NULL; } - if (multi != NULL) { mret = curl_multi_remove_handle (multi, curl); @@ -700,7 +714,7 @@ clean_up () } GNUNET_free_non_null (current_url); current_url = NULL; - + downloaded_hellos = 0; stat_download_in_progress = GNUNET_NO; } @@ -792,7 +806,7 @@ static void task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - unsigned int counter; + int running; struct CURLMsg *msg; CURLMcode mret; @@ -823,7 +837,6 @@ task_download (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ready for processing hostlist client request\n"); #endif - counter = 0; do { running = 0; @@ -834,7 +847,6 @@ task_download (void *cls, { msg = curl_multi_info_read (multi, &running); - counter ++; GNUNET_break (msg != NULL); if (msg == NULL) break; @@ -855,6 +867,8 @@ task_download (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Download of hostlist `%s' completed.\n"), current_url); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("HELLOs recieved: %u \n"),downloaded_hellos); stat_download_successful = GNUNET_YES; update_hostlist(); if (GNUNET_YES == stat_testing_hostlist) @@ -918,6 +932,7 @@ download_hostlist () stat_download_in_progress = GNUNET_YES; stat_download_successful = GNUNET_NO; stat_hellos_obtained = 0; + downloaded_hellos = 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 745187f7c..5b0036098 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_HELLO_PER_HOSTLISTS 0 +#define MAX_HELLO_PER_HOSTLISTS 50 #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/hostlist-server.c b/src/hostlist/hostlist-server.c index 37fb4a4e1..3a2a730d1 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -32,7 +32,7 @@ #include "gnunet-daemon-hostlist.h" #include "gnunet_resolver_service.h" -#define DEBUG_HOSTLIST_SERVER GNUNET_NO +#define DEBUG_HOSTLIST_SERVER GNUNET_YES /** * How often should we recalculate our response to hostlist requests? @@ -282,7 +282,6 @@ update_response (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct HostSet *results; - response_task = GNUNET_SCHEDULER_NO_TASK; results = GNUNET_malloc(sizeof(struct HostSet)); GNUNET_assert (peerinfo != NULL); @@ -438,6 +437,11 @@ connect_handler (void *cls, { size_t size; + /* FIXME: Change this way to update the list to peerinfo_notify */ + response_task = GNUNET_SCHEDULER_add_now (sched, + &update_response, + NULL); + if ( !advertising ) return; if (hostlist_uri == NULL) @@ -455,8 +459,8 @@ connect_handler (void *cls, return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asked core to transmit advertisement message with a size of %u bytes\n", - size); + "Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n", + size,GNUNET_i2s(peer)); if (NULL == GNUNET_CORE_notify_transmit_ready (core, 0, GNUNET_ADV_TIMEOUT, diff --git a/src/hostlist/hostlists_adv_peer.file b/src/hostlist/hostlists_adv_peer.file new file mode 100644 index 000000000..e69de29bb diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index b529eb86d..8f457fa1e 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -71,6 +71,8 @@ static struct PeerContext adv_peer; static struct PeerContext learn_peer; +static struct PeerContext learn_peer2; + static void waitpid_task (void *cls, @@ -137,6 +139,11 @@ 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); @@ -147,11 +154,19 @@ 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); @@ -415,6 +430,8 @@ 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"); + } diff --git a/src/hostlist/test_learning_adv_peer.conf b/src/hostlist/test_learning_adv_peer.conf index 9af51e8f2..723111d75 100644 --- a/src/hostlist/test_learning_adv_peer.conf +++ b/src/hostlist/test_learning_adv_peer.conf @@ -34,10 +34,11 @@ PORT = 22970 WEAKRANDOM = YES [hostlist] -HTTPPORT = 12981s -SERVERS = http://localhost:12980/ -OPTIONS = -b -p -a -DEBUG = NO +HTTPPORT = 12981 +SERVERS = http://localhost:12981/ +OPTIONS = -p -a -b -e +#OPTIONS = -b -p -a +DEBUG = YES HOSTLISTFILE = hostlists_adv_peer.file #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist diff --git a/src/hostlist/test_learning_learn_peer.conf b/src/hostlist/test_learning_learn_peer.conf index 4bdb039e7..d7f512e30 100644 --- a/src/hostlist/test_learning_learn_peer.conf +++ b/src/hostlist/test_learning_learn_peer.conf @@ -35,8 +35,9 @@ WEAKRANDOM = YES [hostlist] HTTPPORT = 12980 SERVERS = http://localhost:12981/ -OPTIONS = -b -p -e -#DEBUG = YES +OPTIONS = -b -e +#OPTIONS = -b -p +DEBUG = YES HOSTLISTFILE = hostlists_learn_peer.file #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist diff --git a/src/hostlist/test_learning_learn_peer2.conf b/src/hostlist/test_learning_learn_peer2.conf new file mode 100644 index 000000000..3279fbfd7 --- /dev/null +++ b/src/hostlist/test_learning_learn_peer2.conf @@ -0,0 +1,47 @@ +[PATHS] +SERVICEHOME = /tmp/test-gnunetd-hostlist-peer-3/ +DEFAULTCONFIG = test_learning_learn_peer2.conf +[resolver] +PORT = 32964 + +[transport] +PORT = 32965 +PLUGINS = tcp +#DEBUG = YES + +[arm] +PORT = 32966 +DEFAULTSERVICES = resolver transport core statistics topology hostlist +#GLOBAL_PREFIX = xterm -e gdb -x cmd --args +#DEBUG=NO + +[statistics] +PORT = 32967 + +[transport-tcp] +PORT = 32968 + +[peerinfo] +PORT = 32969 + +[core] +PORT = 32970 +#DEBUG = YES +#PREFIX = valgrind --tool=memcheck + +[testing] +WEAKRANDOM = YES + +[hostlist] +HTTPPORT = 32980 +SERVERS = http://localhost:12981/ +OPTIONS = -b -e +#OPTIONS = -b -p +DEBUG = YES +HOSTLISTFILE = hostlists_learn_peer2.file +#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist + + +[topology] +#DEBUG = YES +#PREFIX = valgrind --tool=memcheck -- 2.25.1