diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-26 22:58:21 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-26 22:58:30 +0200 |
commit | 28273c70836e834793cfb03b82325e38e566e65a (patch) | |
tree | 40a2e879d907e073a83e18264574f5037f392104 /src/util/time.c | |
parent | ccf16c9d0542a04a3fa175305a807d7c0a0a65db (diff) | |
download | gnunet-28273c70836e834793cfb03b82325e38e566e65a.tar.gz gnunet-28273c70836e834793cfb03b82325e38e566e65a.zip |
configurable threshold for randomized backoff
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util/time.c b/src/util/time.c index 0c177c381..b02c43c1b 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -737,13 +737,14 @@ GNUNET_TIME_year_to_time (unsigned int year) | |||
737 | /** | 737 | /** |
738 | * Randomized exponential back-off, starting at 1 ms | 738 | * Randomized exponential back-off, starting at 1 ms |
739 | * and going up by a factor of 2+r, where 0 <= r <= 0.5, up | 739 | * and going up by a factor of 2+r, where 0 <= r <= 0.5, up |
740 | * to a maximum of 15 m. | 740 | * to a maximum of the given threshold. |
741 | * | 741 | * |
742 | * @param r current backoff time, initially zero | 742 | * @param r current backoff time, initially zero |
743 | * @param threshold maximum value for backoff | ||
743 | * @return the next backoff time | 744 | * @return the next backoff time |
744 | */ | 745 | */ |
745 | struct GNUNET_TIME_Relative | 746 | struct GNUNET_TIME_Relative |
746 | GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt) | 747 | GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold) |
747 | { | 748 | { |
748 | double r = (rand() % 500) / 1000.0; | 749 | double r = (rand() % 500) / 1000.0; |
749 | struct GNUNET_TIME_Relative t; | 750 | struct GNUNET_TIME_Relative t; |
@@ -751,9 +752,11 @@ GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt) | |||
751 | t = relative_multiply_double (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, | 752 | t = relative_multiply_double (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, |
752 | rt), | 753 | rt), |
753 | 2 + r); | 754 | 2 + r); |
754 | return GNUNET_TIME_relative_min (GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD, | 755 | return GNUNET_TIME_relative_min (threshold, |
755 | t); | 756 | t); |
756 | } | 757 | } |
757 | 758 | ||
758 | 759 | ||
760 | |||
761 | |||
759 | /* end of time.c */ | 762 | /* end of time.c */ |