diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index b7e195832..b8558503d 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -263,7 +263,6 @@ struct ValidationEntry | |||
263 | */ | 263 | */ |
264 | int expecting_pong; | 264 | int expecting_pong; |
265 | 265 | ||
266 | |||
267 | /* FIXME: DEBUGGING */ | 266 | /* FIXME: DEBUGGING */ |
268 | int last_line_set_to_no; | 267 | int last_line_set_to_no; |
269 | int last_line_set_to_yes; | 268 | int last_line_set_to_yes; |
@@ -324,6 +323,16 @@ static struct GNUNET_PEERINFO_NotifyContext *pnc; | |||
324 | static struct GNUNET_TIME_Relative validation_delay; | 323 | static struct GNUNET_TIME_Relative validation_delay; |
325 | 324 | ||
326 | /** | 325 | /** |
326 | * Number of validations running | ||
327 | */ | ||
328 | static unsigned int validations_running; | ||
329 | |||
330 | /** | ||
331 | * Validition fast start threshold | ||
332 | */ | ||
333 | static unsigned int validations_fast_start_threshold; | ||
334 | |||
335 | /** | ||
327 | * When is next validation allowed | 336 | * When is next validation allowed |
328 | */ | 337 | */ |
329 | static struct GNUNET_TIME_Absolute validation_next; | 338 | static struct GNUNET_TIME_Absolute validation_next; |
@@ -402,6 +411,14 @@ cleanup_validation_entry (void *cls, const struct GNUNET_HashCode * key, void *v | |||
402 | GNUNET_SCHEDULER_cancel (ve->revalidation_task); | 411 | GNUNET_SCHEDULER_cancel (ve->revalidation_task); |
403 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; | 412 | ve->revalidation_task = GNUNET_SCHEDULER_NO_TASK; |
404 | } | 413 | } |
414 | if ((GNUNET_YES == ve->expecting_pong) && | ||
415 | (validations_running > 0)) | ||
416 | { | ||
417 | validations_running --; | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
419 | "Validation finished, %u validation processes running\n", | ||
420 | validations_running); | ||
421 | } | ||
405 | GNUNET_free (ve); | 422 | GNUNET_free (ve); |
406 | return GNUNET_OK; | 423 | return GNUNET_OK; |
407 | } | 424 | } |
@@ -473,7 +490,7 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s %s\n", | 490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s %s\n", |
474 | GNUNET_i2s (pid), GST_plugins_a2s (ve->address), ve->address->transport_name); | 491 | GNUNET_i2s (pid), GST_plugins_a2s (ve->address), ve->address->transport_name); |
475 | 492 | ||
476 | next = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), validation_delay); | 493 | next = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), validation_delay); |
477 | if (next.abs_value > validation_next.abs_value) | 494 | if (next.abs_value > validation_next.abs_value) |
478 | validation_next = next; /* We're going to send a PING so delay next validation */ | 495 | validation_next = next; /* We're going to send a PING so delay next validation */ |
479 | 496 | ||
@@ -547,6 +564,10 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, | |||
547 | ("# PING without HELLO messages sent"), 1, | 564 | ("# PING without HELLO messages sent"), 1, |
548 | GNUNET_NO); | 565 | GNUNET_NO); |
549 | ve->expecting_pong = GNUNET_YES; | 566 | ve->expecting_pong = GNUNET_YES; |
567 | validations_running ++; | ||
568 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
569 | "Validation started, %u validation processes running\n", | ||
570 | validations_running); | ||
550 | } | 571 | } |
551 | } | 572 | } |
552 | 573 | ||
@@ -589,7 +610,10 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
589 | return; | 610 | return; |
590 | } | 611 | } |
591 | blocked_for = GNUNET_TIME_absolute_get_remaining(validation_next); | 612 | blocked_for = GNUNET_TIME_absolute_get_remaining(validation_next); |
592 | if ((blocked_for.rel_value) > 0) | 613 | if (validations_running > validations_fast_start_threshold) |
614 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"Throttle!\n"); | ||
615 | if ((validations_running > validations_fast_start_threshold) && | ||
616 | (blocked_for.rel_value > 0)) | ||
593 | { | 617 | { |
594 | /* Validations are blocked, have to wait for blocked_for time */ | 618 | /* Validations are blocked, have to wait for blocked_for time */ |
595 | ve->revalidation_task = | 619 | ve->revalidation_task = |
@@ -758,9 +782,24 @@ process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
758 | void | 782 | void |
759 | GST_validation_start (unsigned int max_fds) | 783 | GST_validation_start (unsigned int max_fds) |
760 | { | 784 | { |
785 | /** | ||
786 | * Initialization for validation throttling | ||
787 | * | ||
788 | * We have a maximum number max_fds of connections we can use for validation | ||
789 | * We monitor the number of validations in parallel and start to throttle it | ||
790 | * when doing to many validations in parallel: | ||
791 | * if (running validations < (max_fds / 2)) | ||
792 | * - "fast start": run validation immediately | ||
793 | * - have delay of (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / (max_fds / 2) | ||
794 | * (300 sec / ~150 == ~2 sec.) between two validations | ||
795 | */ | ||
796 | |||
761 | validation_next = GNUNET_TIME_absolute_get(); | 797 | validation_next = GNUNET_TIME_absolute_get(); |
762 | validation_delay.rel_value = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / max_fds; | 798 | validation_delay.rel_value = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value) / (max_fds / 2); |
763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Delay between validations: %u ms\n ", validation_delay.rel_value); | 799 | validations_fast_start_threshold = (max_fds / 2); |
800 | validations_running = 0; | ||
801 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Validation uses a fast start threshold of %u connections and a delay between of %u ms\n ", | ||
802 | validations_fast_start_threshold, validation_delay.rel_value); | ||
764 | validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE, | 803 | validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE, |
765 | GNUNET_NO); | 804 | GNUNET_NO); |
766 | pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL); | 805 | pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL); |
@@ -1204,6 +1243,16 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1204 | ats.value = htonl ((uint32_t) ve->latency.rel_value); | 1243 | ats.value = htonl ((uint32_t) ve->latency.rel_value); |
1205 | GNUNET_ATS_address_add (GST_ats, ve->address, NULL, &ats, 1); | 1244 | GNUNET_ATS_address_add (GST_ats, ve->address, NULL, &ats, 1); |
1206 | } | 1245 | } |
1246 | if (validations_running > 0) | ||
1247 | { | ||
1248 | validations_running --; | ||
1249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1250 | "Validation finished, %u validation processes running\n", | ||
1251 | validations_running); | ||
1252 | } | ||
1253 | else | ||
1254 | GNUNET_break (0); | ||
1255 | |||
1207 | /* build HELLO to store in PEERINFO */ | 1256 | /* build HELLO to store in PEERINFO */ |
1208 | ve->copied = GNUNET_NO; | 1257 | ve->copied = GNUNET_NO; |
1209 | hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve); | 1258 | hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve); |