diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-26 15:31:07 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-26 15:31:07 +0000 |
commit | 97c255a2ec844e63cd116f6e804b629185302e85 (patch) | |
tree | eb3691ce52e5438fe3d1127415efe741533bc6fe | |
parent | e6674963348824eb7d8bdfdc0e2d655ca9773a40 (diff) | |
download | gnunet-97c255a2ec844e63cd116f6e804b629185302e85.tar.gz gnunet-97c255a2ec844e63cd116f6e804b629185302e85.zip |
-rw-r--r-- | src/hostlist/hostlist-client.c | 27 | ||||
-rw-r--r-- | src/hostlist/hostlist-client.h | 2 | ||||
-rw-r--r-- | src/hostlist/hostlist-server.c | 12 | ||||
-rw-r--r-- | src/hostlist/hostlists_adv_peer.file | 0 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 17 | ||||
-rw-r--r-- | src/hostlist/test_learning_adv_peer.conf | 9 | ||||
-rw-r--r-- | src/hostlist/test_learning_learn_peer.conf | 5 | ||||
-rw-r--r-- | src/hostlist/test_learning_learn_peer2.conf | 47 |
8 files changed, 102 insertions, 17 deletions
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; | |||
252 | */ | 252 | */ |
253 | static unsigned int stat_connection_count; | 253 | static unsigned int stat_connection_count; |
254 | 254 | ||
255 | unsigned int downloaded_hellos; | ||
255 | 256 | ||
256 | /** | 257 | /** |
257 | * Process downloaded bits by calling callback on each HELLO. | 258 | * Process downloaded bits by calling callback on each HELLO. |
@@ -280,6 +281,15 @@ callback_download (void *ptr, | |||
280 | { | 281 | { |
281 | return total; /* ok, no data or bogus data */ | 282 | return total; /* ok, no data or bogus data */ |
282 | } | 283 | } |
284 | |||
285 | if ( downloaded_hellos >= MAX_HELLO_PER_HOSTLISTS ) | ||
286 | { | ||
287 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
288 | _("Maximum number of HELLO Messages per download reached: %u'\n"), | ||
289 | MAX_HELLO_PER_HOSTLISTS ); | ||
290 | return total; | ||
291 | |||
292 | } | ||
283 | GNUNET_STATISTICS_update (stats, | 293 | GNUNET_STATISTICS_update (stats, |
284 | gettext_noop ("# bytes downloaded from hostlist servers"), | 294 | gettext_noop ("# bytes downloaded from hostlist servers"), |
285 | (int64_t) total, | 295 | (int64_t) total, |
@@ -311,7 +321,9 @@ callback_download (void *ptr, | |||
311 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 321 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
312 | _("Invalid `%s' message received from hostlist at `%s'\n"), | 322 | _("Invalid `%s' message received from hostlist at `%s'\n"), |
313 | "HELLO", | 323 | "HELLO", |
314 | current_url); | 324 | current_url); |
325 | stat_hellos_obtained++; | ||
326 | downloaded_hellos++; | ||
315 | stat_bogus_url = 1; | 327 | stat_bogus_url = 1; |
316 | return total; | 328 | return total; |
317 | } | 329 | } |
@@ -332,6 +344,7 @@ callback_download (void *ptr, | |||
332 | 1, | 344 | 1, |
333 | GNUNET_NO); | 345 | GNUNET_NO); |
334 | stat_hellos_obtained++; | 346 | stat_hellos_obtained++; |
347 | downloaded_hellos++; | ||
335 | GNUNET_TRANSPORT_offer_hello (transport, msg); | 348 | GNUNET_TRANSPORT_offer_hello (transport, msg); |
336 | } | 349 | } |
337 | else | 350 | else |
@@ -345,6 +358,8 @@ callback_download (void *ptr, | |||
345 | "HELLO", | 358 | "HELLO", |
346 | current_url); | 359 | current_url); |
347 | stat_bogus_url = GNUNET_YES; | 360 | stat_bogus_url = GNUNET_YES; |
361 | stat_hellos_obtained++; | ||
362 | downloaded_hellos++; | ||
348 | return total; | 363 | return total; |
349 | } | 364 | } |
350 | memmove (download_buffer, | 365 | memmove (download_buffer, |
@@ -674,7 +689,6 @@ clean_up () | |||
674 | hostlist_to_test = NULL; | 689 | hostlist_to_test = NULL; |
675 | } | 690 | } |
676 | 691 | ||
677 | |||
678 | if (multi != NULL) | 692 | if (multi != NULL) |
679 | { | 693 | { |
680 | mret = curl_multi_remove_handle (multi, curl); | 694 | mret = curl_multi_remove_handle (multi, curl); |
@@ -700,7 +714,7 @@ clean_up () | |||
700 | } | 714 | } |
701 | GNUNET_free_non_null (current_url); | 715 | GNUNET_free_non_null (current_url); |
702 | current_url = NULL; | 716 | current_url = NULL; |
703 | 717 | downloaded_hellos = 0; | |
704 | stat_download_in_progress = GNUNET_NO; | 718 | stat_download_in_progress = GNUNET_NO; |
705 | } | 719 | } |
706 | 720 | ||
@@ -792,7 +806,7 @@ static void | |||
792 | task_download (void *cls, | 806 | task_download (void *cls, |
793 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 807 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
794 | { | 808 | { |
795 | unsigned int counter; | 809 | |
796 | int running; | 810 | int running; |
797 | struct CURLMsg *msg; | 811 | struct CURLMsg *msg; |
798 | CURLMcode mret; | 812 | CURLMcode mret; |
@@ -823,7 +837,6 @@ task_download (void *cls, | |||
823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 837 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
824 | "Ready for processing hostlist client request\n"); | 838 | "Ready for processing hostlist client request\n"); |
825 | #endif | 839 | #endif |
826 | counter = 0; | ||
827 | do | 840 | do |
828 | { | 841 | { |
829 | running = 0; | 842 | running = 0; |
@@ -834,7 +847,6 @@ task_download (void *cls, | |||
834 | { | 847 | { |
835 | 848 | ||
836 | msg = curl_multi_info_read (multi, &running); | 849 | msg = curl_multi_info_read (multi, &running); |
837 | counter ++; | ||
838 | GNUNET_break (msg != NULL); | 850 | GNUNET_break (msg != NULL); |
839 | if (msg == NULL) | 851 | if (msg == NULL) |
840 | break; | 852 | break; |
@@ -855,6 +867,8 @@ task_download (void *cls, | |||
855 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 867 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
856 | _("Download of hostlist `%s' completed.\n"), | 868 | _("Download of hostlist `%s' completed.\n"), |
857 | current_url); | 869 | current_url); |
870 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
871 | _("HELLOs recieved: %u \n"),downloaded_hellos); | ||
858 | stat_download_successful = GNUNET_YES; | 872 | stat_download_successful = GNUNET_YES; |
859 | update_hostlist(); | 873 | update_hostlist(); |
860 | if (GNUNET_YES == stat_testing_hostlist) | 874 | if (GNUNET_YES == stat_testing_hostlist) |
@@ -918,6 +932,7 @@ download_hostlist () | |||
918 | stat_download_in_progress = GNUNET_YES; | 932 | stat_download_in_progress = GNUNET_YES; |
919 | stat_download_successful = GNUNET_NO; | 933 | stat_download_successful = GNUNET_NO; |
920 | stat_hellos_obtained = 0; | 934 | stat_hellos_obtained = 0; |
935 | downloaded_hellos = 0; | ||
921 | 936 | ||
922 | GNUNET_STATISTICS_update (stats, | 937 | GNUNET_STATISTICS_update (stats, |
923 | gettext_noop ("# hostlist downloads initiated"), | 938 | 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 @@ | |||
33 | #include "gnunet_time_lib.h" | 33 | #include "gnunet_time_lib.h" |
34 | 34 | ||
35 | #define MAX_NUMBER_HOSTLISTS 30 | 35 | #define MAX_NUMBER_HOSTLISTS 30 |
36 | #define MAX_HELLO_PER_HOSTLISTS 0 | 36 | #define MAX_HELLO_PER_HOSTLISTS 50 |
37 | #define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) | 37 | #define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) |
38 | #define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 38 | #define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
39 | #define WAITING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 39 | #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 @@ | |||
32 | #include "gnunet-daemon-hostlist.h" | 32 | #include "gnunet-daemon-hostlist.h" |
33 | #include "gnunet_resolver_service.h" | 33 | #include "gnunet_resolver_service.h" |
34 | 34 | ||
35 | #define DEBUG_HOSTLIST_SERVER GNUNET_NO | 35 | #define DEBUG_HOSTLIST_SERVER GNUNET_YES |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * How often should we recalculate our response to hostlist requests? | 38 | * How often should we recalculate our response to hostlist requests? |
@@ -282,7 +282,6 @@ update_response (void *cls, | |||
282 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 282 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
283 | { | 283 | { |
284 | struct HostSet *results; | 284 | struct HostSet *results; |
285 | |||
286 | response_task = GNUNET_SCHEDULER_NO_TASK; | 285 | response_task = GNUNET_SCHEDULER_NO_TASK; |
287 | results = GNUNET_malloc(sizeof(struct HostSet)); | 286 | results = GNUNET_malloc(sizeof(struct HostSet)); |
288 | GNUNET_assert (peerinfo != NULL); | 287 | GNUNET_assert (peerinfo != NULL); |
@@ -438,6 +437,11 @@ connect_handler (void *cls, | |||
438 | { | 437 | { |
439 | size_t size; | 438 | size_t size; |
440 | 439 | ||
440 | /* FIXME: Change this way to update the list to peerinfo_notify */ | ||
441 | response_task = GNUNET_SCHEDULER_add_now (sched, | ||
442 | &update_response, | ||
443 | NULL); | ||
444 | |||
441 | if ( !advertising ) | 445 | if ( !advertising ) |
442 | return; | 446 | return; |
443 | if (hostlist_uri == NULL) | 447 | if (hostlist_uri == NULL) |
@@ -455,8 +459,8 @@ connect_handler (void *cls, | |||
455 | return; | 459 | return; |
456 | } | 460 | } |
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
458 | "Asked core to transmit advertisement message with a size of %u bytes\n", | 462 | "Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n", |
459 | size); | 463 | size,GNUNET_i2s(peer)); |
460 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, | 464 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, |
461 | 0, | 465 | 0, |
462 | GNUNET_ADV_TIMEOUT, | 466 | 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 --- /dev/null +++ b/src/hostlist/hostlists_adv_peer.file | |||
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; | |||
71 | 71 | ||
72 | static struct PeerContext learn_peer; | 72 | static struct PeerContext learn_peer; |
73 | 73 | ||
74 | static struct PeerContext learn_peer2; | ||
75 | |||
74 | 76 | ||
75 | static void | 77 | static void |
76 | waitpid_task (void *cls, | 78 | waitpid_task (void *cls, |
@@ -137,6 +139,11 @@ static void shutdown_testcase() | |||
137 | GNUNET_TRANSPORT_disconnect (learn_peer.th); | 139 | GNUNET_TRANSPORT_disconnect (learn_peer.th); |
138 | learn_peer.th = NULL; | 140 | learn_peer.th = NULL; |
139 | } | 141 | } |
142 | if (learn_peer2.th != NULL) | ||
143 | { | ||
144 | GNUNET_TRANSPORT_disconnect (learn_peer2.th); | ||
145 | learn_peer2.th = NULL; | ||
146 | } | ||
140 | if (adv_peer.core != NULL) | 147 | if (adv_peer.core != NULL) |
141 | { | 148 | { |
142 | GNUNET_CORE_disconnect (adv_peer.core); | 149 | GNUNET_CORE_disconnect (adv_peer.core); |
@@ -147,11 +154,19 @@ static void shutdown_testcase() | |||
147 | GNUNET_CORE_disconnect (learn_peer.core); | 154 | GNUNET_CORE_disconnect (learn_peer.core); |
148 | learn_peer.core = NULL; | 155 | learn_peer.core = NULL; |
149 | } | 156 | } |
157 | if (learn_peer2.core != NULL) | ||
158 | { | ||
159 | GNUNET_CORE_disconnect (learn_peer2.core); | ||
160 | learn_peer2.core = NULL; | ||
161 | } | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
151 | "Asking ARM to stop core services\n"); | 163 | "Asking ARM to stop core services\n"); |
152 | learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL); | 164 | learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL); |
153 | GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, | 165 | GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, |
154 | &stop_cb, &learn_peer); | 166 | &stop_cb, &learn_peer); |
167 | learn_peer2.arm = GNUNET_ARM_connect (learn_peer2.cfg, sched, NULL); | ||
168 | GNUNET_ARM_stop_service (learn_peer2.arm, "core", GNUNET_TIME_UNIT_SECONDS, | ||
169 | &stop_cb, &learn_peer2); | ||
155 | adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL); | 170 | adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL); |
156 | GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, | 171 | GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, |
157 | &stop_cb, &adv_peer); | 172 | &stop_cb, &adv_peer); |
@@ -415,6 +430,8 @@ run (void *cls, | |||
415 | 430 | ||
416 | setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); | 431 | setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); |
417 | setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); | 432 | setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); |
433 | setup_learn_peer (&learn_peer2, "test_learning_learn_peer2.conf"); | ||
434 | |||
418 | } | 435 | } |
419 | 436 | ||
420 | 437 | ||
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 | |||
34 | WEAKRANDOM = YES | 34 | WEAKRANDOM = YES |
35 | 35 | ||
36 | [hostlist] | 36 | [hostlist] |
37 | HTTPPORT = 12981s | 37 | HTTPPORT = 12981 |
38 | SERVERS = http://localhost:12980/ | 38 | SERVERS = http://localhost:12981/ |
39 | OPTIONS = -b -p -a | 39 | OPTIONS = -p -a -b -e |
40 | DEBUG = NO | 40 | #OPTIONS = -b -p -a |
41 | DEBUG = YES | ||
41 | HOSTLISTFILE = hostlists_adv_peer.file | 42 | HOSTLISTFILE = hostlists_adv_peer.file |
42 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | 43 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist |
43 | 44 | ||
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 | |||
35 | [hostlist] | 35 | [hostlist] |
36 | HTTPPORT = 12980 | 36 | HTTPPORT = 12980 |
37 | SERVERS = http://localhost:12981/ | 37 | SERVERS = http://localhost:12981/ |
38 | OPTIONS = -b -p -e | 38 | OPTIONS = -b -e |
39 | #DEBUG = YES | 39 | #OPTIONS = -b -p |
40 | DEBUG = YES | ||
40 | HOSTLISTFILE = hostlists_learn_peer.file | 41 | HOSTLISTFILE = hostlists_learn_peer.file |
41 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | 42 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist |
42 | 43 | ||
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 @@ | |||
1 | [PATHS] | ||
2 | SERVICEHOME = /tmp/test-gnunetd-hostlist-peer-3/ | ||
3 | DEFAULTCONFIG = test_learning_learn_peer2.conf | ||
4 | [resolver] | ||
5 | PORT = 32964 | ||
6 | |||
7 | [transport] | ||
8 | PORT = 32965 | ||
9 | PLUGINS = tcp | ||
10 | #DEBUG = YES | ||
11 | |||
12 | [arm] | ||
13 | PORT = 32966 | ||
14 | DEFAULTSERVICES = resolver transport core statistics topology hostlist | ||
15 | #GLOBAL_PREFIX = xterm -e gdb -x cmd --args | ||
16 | #DEBUG=NO | ||
17 | |||
18 | [statistics] | ||
19 | PORT = 32967 | ||
20 | |||
21 | [transport-tcp] | ||
22 | PORT = 32968 | ||
23 | |||
24 | [peerinfo] | ||
25 | PORT = 32969 | ||
26 | |||
27 | [core] | ||
28 | PORT = 32970 | ||
29 | #DEBUG = YES | ||
30 | #PREFIX = valgrind --tool=memcheck | ||
31 | |||
32 | [testing] | ||
33 | WEAKRANDOM = YES | ||
34 | |||
35 | [hostlist] | ||
36 | HTTPPORT = 32980 | ||
37 | SERVERS = http://localhost:12981/ | ||
38 | OPTIONS = -b -e | ||
39 | #OPTIONS = -b -p | ||
40 | DEBUG = YES | ||
41 | HOSTLISTFILE = hostlists_learn_peer2.file | ||
42 | #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist | ||
43 | |||
44 | |||
45 | [topology] | ||
46 | #DEBUG = YES | ||
47 | #PREFIX = valgrind --tool=memcheck | ||