diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-29 20:47:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-29 20:47:18 +0000 |
commit | 71ea5bd2d05058008e604ffd42993be9c7250e04 (patch) | |
tree | a5074671ddfaa9d1621a4182fc95a91a98b3d536 /src/fs/gnunet-service-fs_pe.c | |
parent | b335777fd435142c16eb05e86c8a64a4b1a45447 (diff) | |
download | gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.tar.gz gnunet-71ea5bd2d05058008e604ffd42993be9c7250e04.zip |
-fixing indentation
Diffstat (limited to 'src/fs/gnunet-service-fs_pe.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 200d7a0e4..0a40065cc 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c | |||
@@ -265,7 +265,7 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
265 | gettext_noop ("# average retransmission delay (ms)"), | 265 | gettext_noop ("# average retransmission delay (ms)"), |
266 | total_delay * 1000LL / plan_count, GNUNET_NO); | 266 | total_delay * 1000LL / plan_count, GNUNET_NO); |
267 | prd = GSF_pending_request_get_data_ (rp->prl_head->pr); | 267 | prd = GSF_pending_request_get_data_ (rp->prl_head->pr); |
268 | 268 | ||
269 | if (rp->transmission_counter < 8) | 269 | if (rp->transmission_counter < 8) |
270 | delay = | 270 | delay = |
271 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 271 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
@@ -283,30 +283,32 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
283 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 283 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
284 | delay.rel_value + 1); | 284 | delay.rel_value + 1); |
285 | /* Add 0.01 to avg_delay to avoid division-by-zero later */ | 285 | /* Add 0.01 to avg_delay to avoid division-by-zero later */ |
286 | avg_delay = (((avg_delay * (N-1.0)) + delay.rel_value) / N) + 0.01; | 286 | avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value) / N) + 0.01; |
287 | 287 | ||
288 | /* | 288 | /* |
289 | For the priority, we need to consider a few basic rules: | 289 | * For the priority, we need to consider a few basic rules: |
290 | 1) if we just started requesting (delay is small), we should | 290 | * 1) if we just started requesting (delay is small), we should |
291 | virtually always have a priority of zero. | 291 | * virtually always have a priority of zero. |
292 | 2) for requests with average latency, our priority should match | 292 | * 2) for requests with average latency, our priority should match |
293 | the average priority observed on the network | 293 | * the average priority observed on the network |
294 | 3) even the longest-running requests should not be WAY out of | 294 | * 3) even the longest-running requests should not be WAY out of |
295 | the observed average (thus we bound by a factor of 2) | 295 | * the observed average (thus we bound by a factor of 2) |
296 | 4) we add +1 to the observed average priority to avoid everyone | 296 | * 4) we add +1 to the observed average priority to avoid everyone |
297 | staying put at zero (2 * 0 = 0...). | 297 | * staying put at zero (2 * 0 = 0...). |
298 | 298 | * | |
299 | Using the specific calculation below, we get: | 299 | * Using the specific calculation below, we get: |
300 | 300 | * | |
301 | delay = 0 => priority = 0; | 301 | * delay = 0 => priority = 0; |
302 | delay = avg delay => priority = running-average-observed-priority; | 302 | * delay = avg delay => priority = running-average-observed-priority; |
303 | delay >> avg_delay => priority = 2 * running-average-observed-priority; | 303 | * delay >> avg_delay => priority = 2 * running-average-observed-priority; |
304 | 304 | * | |
305 | which satisfies all of the rules above. | 305 | * which satisfies all of the rules above. |
306 | 306 | * | |
307 | Note: M_PI_4 = PI/4 = arctan(1) | 307 | * Note: M_PI_4 = PI/4 = arctan(1) |
308 | */ | 308 | */ |
309 | rp->priority = round ((GSF_current_priorities + 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4; | 309 | rp->priority = |
310 | round ((GSF_current_priorities + | ||
311 | 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4; | ||
310 | /* Note: usage of 'round' and 'atan' requires -lm */ | 312 | /* Note: usage of 'round' and 'atan' requires -lm */ |
311 | 313 | ||
312 | if (rp->transmission_counter != 0) | 314 | if (rp->transmission_counter != 0) |