aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_addresses.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 865460452..096a98314 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -37,6 +37,8 @@
37 37
38#define VERBOSE GNUNET_NO 38#define VERBOSE GNUNET_NO
39 39
40#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
41
40enum ATS_Mode 42enum ATS_Mode
41{ 43{
42 /* 44 /*
@@ -169,6 +171,8 @@ create_address (const struct GNUNET_PeerIdentity *peer,
169 aa->plugin = GNUNET_strdup (plugin_name); 171 aa->plugin = GNUNET_strdup (plugin_name);
170 aa->session_id = session_id; 172 aa->session_id = session_id;
171 aa->mlp_information = NULL; 173 aa->mlp_information = NULL;
174 aa->blocked_until = GNUNET_TIME_absolute_get_zero();
175 aa->block_interval = GNUNET_TIME_relative_get_zero();
172 aa->next = NULL; 176 aa->next = NULL;
173 aa->prev = NULL; 177 aa->prev = NULL;
174 return aa; 178 return aa;
@@ -546,6 +550,26 @@ find_address_it (void *cls, const GNUNET_HashCode * key, void *value)
546 struct ATS_Address **ap = cls; 550 struct ATS_Address **ap = cls;
547 struct ATS_Address *aa = (struct ATS_Address *) value; 551 struct ATS_Address *aa = (struct ATS_Address *) value;
548 struct ATS_Address *ab = *ap; 552 struct ATS_Address *ab = *ap;
553 struct GNUNET_TIME_Absolute now;
554
555 now = GNUNET_TIME_absolute_get();
556
557 if (aa->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, aa->blocked_until).abs_value)
558 {
559 /* This address is blocked for suggestion */
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "Address %p blocked for suggestion for %llu ms \n",
562 aa,
563 GNUNET_TIME_absolute_get_difference(now, aa->blocked_until).rel_value);
564 return GNUNET_OK;
565 }
566
567
568 aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval, ATS_BLOCKING_DELTA);
569 aa->blocked_until = GNUNET_TIME_absolute_add (now, aa->block_interval);
570
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Address %p ready for suggestion, block interval now %llu \n", aa, aa->block_interval);
549 573
550 if (NULL == ab) 574 if (NULL == ab)
551 { 575 {
@@ -678,6 +702,9 @@ void request_address_simple (const struct GNUNET_PeerIdentity *peer)
678 return; 702 return;
679 } 703 }
680 704
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
706 "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
707
681 if (aa->active == GNUNET_NO) 708 if (aa->active == GNUNET_NO)
682 { 709 {
683 aa->active = GNUNET_YES; 710 aa->active = GNUNET_YES;