diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-31 11:59:05 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-31 11:59:05 +0000 |
commit | 693ed6b98d115da771975506c1433df6885c6232 (patch) | |
tree | c28ff2e20b96bc8398ad60f1622fad729ca9fa1e | |
parent | ecb3d401547e9db3fabe6762ef7bf1c6f4ac8a3f (diff) | |
download | gnunet-693ed6b98d115da771975506c1433df6885c6232.tar.gz gnunet-693ed6b98d115da771975506c1433df6885c6232.zip |
centralized function to start solution
-rw-r--r-- | src/ats/libgnunet_plugin_ats_proportional.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/ats/libgnunet_plugin_ats_proportional.c b/src/ats/libgnunet_plugin_ats_proportional.c index 9f60f426f..225485476 100644 --- a/src/ats/libgnunet_plugin_ats_proportional.c +++ b/src/ats/libgnunet_plugin_ats_proportional.c | |||
@@ -530,7 +530,7 @@ is_bandwidth_available_in_network (struct Network *net) | |||
530 | * this address | 530 | * this address |
531 | */ | 531 | */ |
532 | static void | 532 | static void |
533 | distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s, | 533 | distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, |
534 | struct Network *net, struct ATS_Address *address_except) | 534 | struct Network *net, struct ATS_Address *address_except) |
535 | { | 535 | { |
536 | unsigned long long remaining_quota_in = 0; | 536 | unsigned long long remaining_quota_in = 0; |
@@ -803,16 +803,25 @@ find_best_address_it (void *cls, | |||
803 | */ | 803 | */ |
804 | 804 | ||
805 | /** | 805 | /** |
806 | * Update bandwidth assignment for all networks | 806 | * Distribibute bandwidth |
807 | * | 807 | * |
808 | * @param s the solver handle | 808 | * @param n the network, can be NULL for all networksa |
809 | */ | 809 | */ |
810 | static void | 810 | |
811 | distribute_bandwidth_in_all_networks (struct GAS_PROPORTIONAL_Handle *s) | 811 | static void distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s, |
812 | struct Network *n, | ||
813 | struct ATS_Address *address_except) | ||
812 | { | 814 | { |
813 | int i; | 815 | if (NULL != n) |
814 | for (i = 0; i < s->network_count; i++) | 816 | { |
815 | distribute_bandwidth_in_network (s, &s->network_entries[i], NULL ); | 817 | distribute_bandwidth (s, n, address_except); |
818 | } | ||
819 | else | ||
820 | { | ||
821 | int i; | ||
822 | for (i = 0; i < s->network_count; i++) | ||
823 | distribute_bandwidth (s, &s->network_entries[i], NULL ); | ||
824 | } | ||
816 | } | 825 | } |
817 | 826 | ||
818 | /** | 827 | /** |
@@ -990,7 +999,7 @@ GAS_proportional_address_change_preference (void *solver, | |||
990 | GNUNET_assert(NULL != solver); | 999 | GNUNET_assert(NULL != solver); |
991 | GNUNET_assert(NULL != peer); | 1000 | GNUNET_assert(NULL != peer); |
992 | 1001 | ||
993 | distribute_bandwidth_in_all_networks (s); | 1002 | distribute_bandwidth_in_network (s, NULL, NULL); |
994 | } | 1003 | } |
995 | 1004 | ||
996 | 1005 | ||
@@ -1092,7 +1101,7 @@ GAS_proportional_get_preferred_address (void *solver, | |||
1092 | prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1101 | prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ |
1093 | if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES)) | 1102 | if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES)) |
1094 | GNUNET_break(0); | 1103 | GNUNET_break(0); |
1095 | distribute_bandwidth_in_network (s, net_prev, NULL ); | 1104 | distribute_bandwidth_in_network (s, net_prev, NULL); |
1096 | } | 1105 | } |
1097 | 1106 | ||
1098 | if (GNUNET_NO == (is_bandwidth_available_in_network (fba_ctx.best->solver_information))) | 1107 | if (GNUNET_NO == (is_bandwidth_available_in_network (fba_ctx.best->solver_information))) |
@@ -1212,7 +1221,7 @@ GAS_proportional_address_delete (void *solver, struct ATS_Address *address, | |||
1212 | 1221 | ||
1213 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) | 1222 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) |
1214 | GNUNET_break(0); | 1223 | GNUNET_break(0); |
1215 | distribute_bandwidth_in_network (s, net, NULL ); | 1224 | distribute_bandwidth_in_network (s, net, NULL); |
1216 | if (NULL == (new_address = GAS_proportional_get_preferred_address (s, &address->peer))) | 1225 | if (NULL == (new_address = GAS_proportional_get_preferred_address (s, &address->peer))) |
1217 | { | 1226 | { |
1218 | /* No alternative address found, disconnect peer */ | 1227 | /* No alternative address found, disconnect peer */ |
@@ -1265,7 +1274,7 @@ GAS_proportional_bulk_stop (void *solver) | |||
1265 | if ((0 == s->bulk_lock) && (0 < s->bulk_requests)) | 1274 | if ((0 == s->bulk_lock) && (0 < s->bulk_requests)) |
1266 | { | 1275 | { |
1267 | LOG(GNUNET_ERROR_TYPE_DEBUG, "No lock pending, recalculating\n"); | 1276 | LOG(GNUNET_ERROR_TYPE_DEBUG, "No lock pending, recalculating\n"); |
1268 | distribute_bandwidth_in_all_networks (s); | 1277 | distribute_bandwidth_in_network (s, NULL, NULL); |
1269 | s->bulk_requests = 0; | 1278 | s->bulk_requests = 0; |
1270 | } | 1279 | } |
1271 | } | 1280 | } |
@@ -1326,7 +1335,7 @@ GAS_proportional_address_property_changed (void *solver, | |||
1326 | case GNUNET_ATS_COST_WAN: | 1335 | case GNUNET_ATS_COST_WAN: |
1327 | case GNUNET_ATS_COST_LAN: | 1336 | case GNUNET_ATS_COST_LAN: |
1328 | case GNUNET_ATS_COST_WLAN: | 1337 | case GNUNET_ATS_COST_WLAN: |
1329 | distribute_bandwidth_in_network (s, n, GNUNET_NO); | 1338 | distribute_bandwidth_in_network (s, n, NULL); |
1330 | break; | 1339 | break; |
1331 | } | 1340 | } |
1332 | } | 1341 | } |
@@ -1438,7 +1447,7 @@ GAS_proportional_address_change_network (void *solver, | |||
1438 | /* Assign bandwidth to updated address */ | 1447 | /* Assign bandwidth to updated address */ |
1439 | address->active = GNUNET_YES; | 1448 | address->active = GNUNET_YES; |
1440 | addresse_increment (s, new_net, GNUNET_NO, GNUNET_YES); | 1449 | addresse_increment (s, new_net, GNUNET_NO, GNUNET_YES); |
1441 | distribute_bandwidth_in_network (solver, new_net, NULL ); | 1450 | distribute_bandwidth_in_network (solver, new_net, NULL); |
1442 | } | 1451 | } |
1443 | else | 1452 | else |
1444 | { | 1453 | { |