diff options
Diffstat (limited to 'src/ats/plugin_ats_proportional.c')
-rw-r--r-- | src/ats/plugin_ats_proportional.c | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 69afa8a52..9ad00bbb3 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c | |||
@@ -25,8 +25,8 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_statistics_service.h" | 27 | #include "gnunet_statistics_service.h" |
28 | #include "gnunet_ats_plugin.h" | ||
29 | #include "gnunet_ats_service.h" | 28 | #include "gnunet_ats_service.h" |
29 | #include "gnunet_ats_plugin.h" | ||
30 | #include "gnunet-service-ats_addresses.h" | 30 | #include "gnunet-service-ats_addresses.h" |
31 | 31 | ||
32 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__) | 32 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__) |
@@ -308,7 +308,8 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | |||
308 | continue; | 308 | continue; |
309 | peer_relative_prefs = s->env->get_preferences (s->env->cls, | 309 | peer_relative_prefs = s->env->get_preferences (s->env->cls, |
310 | &aw->addr->peer); | 310 | &aw->addr->peer); |
311 | sum_relative_peer_prefences += peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH]; | 311 | sum_relative_peer_prefences |
312 | += peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH]; | ||
312 | count_addresses++; | 313 | count_addresses++; |
313 | } | 314 | } |
314 | if (count_addresses != net->active_addresses) | 315 | if (count_addresses != net->active_addresses) |
@@ -504,27 +505,6 @@ struct FindBestAddressCtx | |||
504 | 505 | ||
505 | 506 | ||
506 | /** | 507 | /** |
507 | * Find index of a ATS property type in the quality properties array. | ||
508 | * | ||
509 | * @param type ATS property type | ||
510 | * @return index in the quality array, #GNUNET_SYSERR if the type | ||
511 | * was not a quality property | ||
512 | */ | ||
513 | static int | ||
514 | find_quality_property_index (enum GNUNET_ATS_Property type) | ||
515 | { | ||
516 | enum GNUNET_ATS_Property existing_types[] = GNUNET_ATS_QualityProperties; | ||
517 | unsigned int c; | ||
518 | |||
519 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
520 | if (existing_types[c] == type) | ||
521 | return c; | ||
522 | GNUNET_break (0); | ||
523 | return GNUNET_SYSERR; | ||
524 | } | ||
525 | |||
526 | |||
527 | /** | ||
528 | * Find a "good" address to use for a peer by iterating over the | 508 | * Find a "good" address to use for a peer by iterating over the |
529 | * addresses for this peer. If we already have an existing address, | 509 | * addresses for this peer. If we already have an existing address, |
530 | * we stick to it. Otherwise, we pick by lowest distance and then by | 510 | * we stick to it. Otherwise, we pick by lowest distance and then by |
@@ -548,7 +528,6 @@ find_best_address_it (void *cls, | |||
548 | double best_distance; | 528 | double best_distance; |
549 | double cur_delay; | 529 | double cur_delay; |
550 | double cur_distance; | 530 | double cur_distance; |
551 | int index; | ||
552 | unsigned int con; | 531 | unsigned int con; |
553 | int bw_available; | 532 | int bw_available; |
554 | int need; | 533 | int need; |
@@ -601,12 +580,10 @@ find_best_address_it (void *cls, | |||
601 | } | 580 | } |
602 | 581 | ||
603 | /* Now compare ATS information */ | 582 | /* Now compare ATS information */ |
604 | index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE); | 583 | cur_distance = current->norm_distance.norm; |
605 | cur_distance = current->atsin[index].norm; | 584 | best_distance = ctx->best->norm_distance.norm; |
606 | best_distance = ctx->best->atsin[index].norm; | 585 | cur_delay = current->norm_delay.norm; |
607 | index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DELAY); | 586 | best_delay = ctx->best->norm_delay.norm; |
608 | cur_delay = current->atsin[index].norm; | ||
609 | best_delay = ctx->best->atsin[index].norm; | ||
610 | 587 | ||
611 | /* user shorter distance */ | 588 | /* user shorter distance */ |
612 | if (cur_distance < best_distance) | 589 | if (cur_distance < best_distance) |
@@ -1006,16 +983,10 @@ GAS_proportional_bulk_stop (void *solver) | |||
1006 | * | 983 | * |
1007 | * @param solver solver handle | 984 | * @param solver solver handle |
1008 | * @param address the address | 985 | * @param address the address |
1009 | * @param type the ATSI type | ||
1010 | * @param abs_value the absolute value of the property | ||
1011 | * @param rel_value the normalized value | ||
1012 | */ | 986 | */ |
1013 | static void | 987 | static void |
1014 | GAS_proportional_address_property_changed (void *solver, | 988 | GAS_proportional_address_property_changed (void *solver, |
1015 | struct ATS_Address *address, | 989 | struct ATS_Address *address) |
1016 | enum GNUNET_ATS_Property type, | ||
1017 | uint32_t abs_value, | ||
1018 | double rel_value) | ||
1019 | { | 990 | { |
1020 | struct GAS_PROPORTIONAL_Handle *s = solver; | 991 | struct GAS_PROPORTIONAL_Handle *s = solver; |
1021 | struct AddressWrapper *asi = address->solver_information; | 992 | struct AddressWrapper *asi = address->solver_information; |