aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorFabian Oehlmann <oehlmann@in.tum.de>2013-09-27 15:27:40 +0000
committerFabian Oehlmann <oehlmann@in.tum.de>2013-09-27 15:27:40 +0000
commit3dec8134c10286f105073a283ca12226c31876d9 (patch)
tree7a7bf200af89075e95c4749dc6399c1df0200ed2 /src/ats
parentedf7fbbb571f712d2108b578cc9944066363c240 (diff)
downloadgnunet-3dec8134c10286f105073a283ca12226c31876d9.tar.gz
gnunet-3dec8134c10286f105073a283ca12226c31876d9.zip
ats_ril: fixed memory error
Diffstat (limited to 'src/ats')
-rwxr-xr-xsrc/ats/gnunet-service-ats-solver_ril.c175
1 files changed, 107 insertions, 68 deletions
diff --git a/src/ats/gnunet-service-ats-solver_ril.c b/src/ats/gnunet-service-ats-solver_ril.c
index 0d6368186..0a073e61f 100755
--- a/src/ats/gnunet-service-ats-solver_ril.c
+++ b/src/ats/gnunet-service-ats-solver_ril.c
@@ -33,6 +33,8 @@
33#define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__) 33#define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__)
34 34
35#define RIL_ACTION_INVALID -1 35#define RIL_ACTION_INVALID -1
36#define RIL_FEATURES_ADDRESS_COUNT (3 + GNUNET_ATS_QualityPropertiesCount)
37#define RIL_FEATURES_NETWORK_COUNT 4
36 38
37#define RIL_DEFAULT_STEP_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000) 39#define RIL_DEFAULT_STEP_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000)
38#define RIL_DEFAULT_ALGORITHM RIL_ALGO_Q 40#define RIL_DEFAULT_ALGORITHM RIL_ALGO_Q
@@ -419,16 +421,16 @@ agent_address_get (struct RIL_Peer_Agent *agent, struct ATS_Address *address)
419 } 421 }
420 } 422 }
421 423
422 return NULL; 424 return NULL ;
423} 425}
424 426
425 /** 427/**
426 * Gets the action, with the maximal estimated Q-value (i.e. the one currently estimated to bring the 428 * Gets the action, with the maximal estimated Q-value (i.e. the one currently estimated to bring the
427 * most reward in the future) 429 * most reward in the future)
428 * @param agent agent performing the calculation 430 * @param agent agent performing the calculation
429 * @param state the state from which to take the action 431 * @param state the state from which to take the action
430 * @return the action promising most future reward 432 * @return the action promising most future reward
431 */ 433 */
432static int 434static int
433agent_get_action_best (struct RIL_Peer_Agent *agent, double *state) 435agent_get_action_best (struct RIL_Peer_Agent *agent, double *state)
434{ 436{
@@ -573,19 +575,36 @@ envi_set_active_suggestion (struct GAS_RIL_Handle *solver,
573 * @return pointer to the state vector 575 * @return pointer to the state vector
574 */ 576 */
575static double * 577static double *
576envi_get_state (struct GAS_RIL_Handle *solver) 578envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
577{ 579{
578 int i; 580 int i;
581 int k;
579 struct RIL_Network *net; 582 struct RIL_Network *net;
580 double *state = GNUNET_malloc (sizeof (double) * solver->networks_count * 4); 583 double *state = GNUNET_malloc (sizeof (double) * agent->m);
584 struct RIL_Address_Wrapped *cur_address;
585 const double *properties;
581 586
582 for (i = 0; i < solver->networks_count; i++) 587 for (i = 0; i < solver->networks_count; i++)
583 { 588 {
584 net = &solver->network_entries[i]; 589 net = &solver->network_entries[i];
585 state[i * 4 + 0] = (double) net->bw_in_assigned; 590 state[i * RIL_FEATURES_NETWORK_COUNT + 0] = (double) net->bw_in_assigned;
586 state[i * 4 + 1] = (double) net->bw_in_available; 591 state[i * RIL_FEATURES_NETWORK_COUNT + 1] = (double) net->bw_in_available;
587 state[i * 4 + 2] = (double) net->bw_out_assigned; 592 state[i * RIL_FEATURES_NETWORK_COUNT + 2] = (double) net->bw_out_assigned;
588 state[i * 4 + 3] = (double) net->bw_out_available; 593 state[i * RIL_FEATURES_NETWORK_COUNT + 3] = (double) net->bw_out_available;
594 }
595
596 i = i * RIL_FEATURES_NETWORK_COUNT; //first address feature
597
598 for (cur_address = agent->addresses_head; NULL != cur_address; cur_address = cur_address->next)
599 {
600 state[i++] = cur_address->address_naked->active;
601 state[i++] = cur_address->address_naked->active ? agent->bw_in : 0;
602 state[i++] = cur_address->address_naked->active ? agent->bw_out : 0;
603 properties = solver->callbacks->get_properties (solver->callbacks->get_properties_cls, cur_address->address_naked);
604 for (k = 0; k < GNUNET_ATS_QualityPropertiesCount; k++)
605 {
606 state[i++] = properties[k];
607 }
589 } 608 }
590 609
591 return state; 610 return state;
@@ -612,11 +631,13 @@ envi_action_bw_double (struct GAS_RIL_Handle *solver,
612{ 631{
613 if (direction_in) 632 if (direction_in)
614 { 633 {
615 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in * 2, agent->bw_out); 634 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in * 2,
635 agent->bw_out);
616 } 636 }
617 else 637 else
618 { 638 {
619 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, agent->bw_out * 2); 639 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in,
640 agent->bw_out * 2);
620 } 641 }
621} 642}
622 643
@@ -693,8 +714,9 @@ envi_action_address_switch (struct GAS_RIL_Handle *solver,
693 714
694 for (cur = agent->addresses_head; NULL != cur; cur = cur->next) 715 for (cur = agent->addresses_head; NULL != cur; cur = cur->next)
695 { 716 {
696 if (i == address_index) { 717 if (i == address_index)
697 envi_set_active_suggestion(solver, agent, cur->address_naked, agent->bw_in, agent->bw_out); 718 {
719 envi_set_active_suggestion (solver, agent, cur->address_naked, agent->bw_in, agent->bw_out);
698 return; 720 return;
699 } 721 }
700 722
@@ -702,7 +724,7 @@ envi_action_address_switch (struct GAS_RIL_Handle *solver,
702 } 724 }
703 725
704 //no address with address_index exists 726 //no address with address_index exists
705 GNUNET_assert (GNUNET_NO); 727 GNUNET_assert(GNUNET_NO);
706} 728}
707 729
708/** 730/**
@@ -748,8 +770,9 @@ envi_do_action (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, int
748 { 770 {
749 address_index = agent->n - RIL_ACTION_TYPE_NUM; 771 address_index = agent->n - RIL_ACTION_TYPE_NUM;
750 772
751 GNUNET_assert (address_index >= 0); 773 GNUNET_assert(address_index >= 0);
752 GNUNET_assert (address_index <= agent_address_get_index (agent, agent->addresses_tail->address_naked)); 774 GNUNET_assert(
775 address_index <= agent_address_get_index (agent, agent->addresses_tail->address_naked));
753 776
754 envi_action_address_switch (solver, agent, address_index); 777 envi_action_address_switch (solver, agent, address_index);
755 break; 778 break;
@@ -773,7 +796,7 @@ agent_step (struct RIL_Peer_Agent *agent)
773 double *s_next; 796 double *s_next;
774 double reward; 797 double reward;
775 798
776 s_next = envi_get_state (agent->envi); 799 s_next = envi_get_state (agent->envi, agent);
777 reward = envi_get_reward (agent->envi, agent); 800 reward = envi_get_reward (agent->envi, agent);
778 801
779 LOG(GNUNET_ERROR_TYPE_DEBUG, "agent_step() with algorithm %s\n", 802 LOG(GNUNET_ERROR_TYPE_DEBUG, "agent_step() with algorithm %s\n",
@@ -873,15 +896,15 @@ agent_init (void *s, const struct GNUNET_PeerIdentity *peer)
873 agent->peer = *peer; 896 agent->peer = *peer;
874 agent->step_count = 0; 897 agent->step_count = 0;
875 agent->active = GNUNET_NO; 898 agent->active = GNUNET_NO;
876 agent->s_old = envi_get_state (solver);
877 agent->n = RIL_ACTION_TYPE_NUM; 899 agent->n = RIL_ACTION_TYPE_NUM;
878 agent->m = solver->networks_count * 4; 900 agent->m = solver->networks_count * RIL_FEATURES_NETWORK_COUNT;
879 agent->W = (double **) GNUNET_malloc (sizeof (double) * agent->n); 901 agent->W = (double **) GNUNET_malloc (sizeof (double) * agent->n);
880 for (i = 0; i < agent->n; i++) 902 for (i = 0; i < agent->n; i++)
881 { 903 {
882 agent->W[i] = (double *) GNUNET_malloc (sizeof (double) * agent->m); 904 agent->W[i] = (double *) GNUNET_malloc (sizeof (double) * agent->m);
883 } 905 }
884 agent->a_old = RIL_ACTION_INVALID; 906 agent->a_old = RIL_ACTION_INVALID;
907 agent->s_old = envi_get_state (solver, agent);
885 agent->e = (double *) GNUNET_malloc (sizeof (double) * agent->m); 908 agent->e = (double *) GNUNET_malloc (sizeof (double) * agent->m);
886 agent_modify_eligibility (agent, RIL_E_ZERO); 909 agent_modify_eligibility (agent, RIL_E_ZERO);
887 910
@@ -907,6 +930,7 @@ agent_die (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
907 GNUNET_free(agent->W); 930 GNUNET_free(agent->W);
908 GNUNET_free(agent->e); 931 GNUNET_free(agent->e);
909 GNUNET_free(agent->s_old); 932 GNUNET_free(agent->s_old);
933 GNUNET_free(agent);
910} 934}
911 935
912/** 936/**
@@ -930,7 +954,9 @@ ril_get_agent (struct GAS_RIL_Handle *solver, const struct GNUNET_PeerIdentity *
930 } 954 }
931 955
932 if (create) 956 if (create)
957 {
933 return agent_init (solver, peer); 958 return agent_init (solver, peer);
959 }
934 return NULL ; 960 return NULL ;
935} 961}
936 962
@@ -962,14 +988,18 @@ ril_network_is_active (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Ty
962 struct RIL_Network *net; 988 struct RIL_Network *net;
963 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 989 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
964 990
965 net = ril_get_network(solver, network); 991 net = ril_get_network (solver, network);
966 if (net->bw_out_available < min_bw) 992 if (net->bw_out_available < min_bw)
967 return GNUNET_NO; 993 return GNUNET_NO;
968 return GNUNET_YES; 994 return GNUNET_YES;
969} 995}
970 996
971static void 997static void
972ril_cut_from_vector (void **old, size_t element_size, unsigned int hole_start, unsigned int hole_length, unsigned int old_length) 998ril_cut_from_vector (void **old,
999 size_t element_size,
1000 unsigned int hole_start,
1001 unsigned int hole_length,
1002 unsigned int old_length)
973{ 1003{
974 char *tmpptr; 1004 char *tmpptr;
975 char *oldptr = (char *) *old; 1005 char *oldptr = (char *) *old;
@@ -978,15 +1008,15 @@ ril_cut_from_vector (void **old, size_t element_size, unsigned int hole_start, u
978 unsigned int bytes_hole; 1008 unsigned int bytes_hole;
979 unsigned int bytes_after; 1009 unsigned int bytes_after;
980 1010
981// LOG(GNUNET_ERROR_TYPE_DEBUG, "hole_start = %d, hole_length = %d, old_length = %d\n", hole_start, hole_length, old_length); 1011
982 GNUNET_assert(old_length > hole_length); 1012 GNUNET_assert(old_length > hole_length);
983 GNUNET_assert(old_length >= (hole_start + hole_length)); 1013 GNUNET_assert(old_length >= (hole_start + hole_length));
984 1014
985 size = (old_length - hole_length) * element_size; 1015 size = element_size * (old_length - hole_length);
986 1016
987 bytes_before = element_size * hole_start; 1017 bytes_before = element_size * hole_start;
988 bytes_hole = element_size * hole_length; 1018 bytes_hole = element_size * hole_length;
989 bytes_after = element_size * (old_length - hole_start - hole_length); 1019 bytes_after = element_size * (old_length - hole_start - hole_length);
990 1020
991 if (0 == size) 1021 if (0 == size)
992 { 1022 {
@@ -994,8 +1024,14 @@ ril_cut_from_vector (void **old, size_t element_size, unsigned int hole_start, u
994 } 1024 }
995 else 1025 else
996 { 1026 {
1027// LOG(GNUNET_ERROR_TYPE_DEBUG, "hole_start = %d, hole_length = %d, old_length = %d\n", hole_start, hole_length, old_length);
1028// LOG(GNUNET_ERROR_TYPE_DEBUG, "bytes_before = %d, bytes_hole = %d, bytes_after = %d\n", bytes_before, bytes_hole, bytes_after);
1029// LOG(GNUNET_ERROR_TYPE_DEBUG, "element_size = %d, bytes_old = %d, bytes_new = %d\n", element_size, old_length * element_size, size);
1030
997 tmpptr = GNUNET_malloc (size); 1031 tmpptr = GNUNET_malloc (size);
1032// LOG(GNUNET_ERROR_TYPE_DEBUG, "first\n");
998 memcpy (tmpptr, oldptr, bytes_before); 1033 memcpy (tmpptr, oldptr, bytes_before);
1034// LOG(GNUNET_ERROR_TYPE_DEBUG, "second\n");
999 memcpy (tmpptr + bytes_before, oldptr + (bytes_before + bytes_hole), bytes_after); 1035 memcpy (tmpptr + bytes_before, oldptr + (bytes_before + bytes_hole), bytes_after);
1000 } 1036 }
1001 if (NULL != *old) 1037 if (NULL != *old)
@@ -1213,14 +1249,15 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network
1213 1249
1214 address->solver_information = ril_get_network (s, network); 1250 address->solver_information = ril_get_network (s, network);
1215 1251
1216 if (!ril_network_is_active(s, network)) 1252 if (!ril_network_is_active (s, network))
1217 { 1253 {
1218 LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_add() Did not add %s address %p for peer '%s', network does not have enough bandwidth\n", 1254 LOG(GNUNET_ERROR_TYPE_DEBUG,
1255 "API_address_add() Did not add %s address %p for peer '%s', network does not have enough bandwidth\n",
1219 address->plugin, address->addr, GNUNET_i2s (&address->peer)); 1256 address->plugin, address->addr, GNUNET_i2s (&address->peer));
1220 return; 1257 return;
1221 } 1258 }
1222 1259
1223 agent = ril_get_agent(s, &address->peer, GNUNET_YES); 1260 agent = ril_get_agent (s, &address->peer, GNUNET_YES);
1224 1261
1225 //add address 1262 //add address
1226 address_wrapped = GNUNET_malloc (sizeof (struct RIL_Address_Wrapped)); 1263 address_wrapped = GNUNET_malloc (sizeof (struct RIL_Address_Wrapped));
@@ -1228,12 +1265,12 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network
1228 GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped); 1265 GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped);
1229 1266
1230 //increase size of W 1267 //increase size of W
1231 m_new = agent->m + 5; //TODO! make size of features from address variable (Note to self: ctrl+f for "5" or I kill you!) 1268 m_new = agent->m + RIL_FEATURES_ADDRESS_COUNT;
1232 m_old = agent->m; 1269 m_old = agent->m;
1233 n_new = agent->n + 1; 1270 n_new = agent->n + 1;
1234 n_old = agent->n; 1271 n_old = agent->n;
1235 1272
1236 GNUNET_array_grow (agent->W, agent->n, n_new); 1273 GNUNET_array_grow(agent->W, agent->n, n_new);
1237 for (i = 0; i < n_new; i++) 1274 for (i = 0; i < n_new; i++)
1238 { 1275 {
1239 if (i < n_old) 1276 if (i < n_old)
@@ -1248,19 +1285,16 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network
1248 } 1285 }
1249 } 1286 }
1250 1287
1251 //increase size of old state vector if there is one 1288 //increase size of old state vector
1252 if (RIL_ACTION_INVALID != agent->a_old) 1289 agent->m = m_old;
1253 { 1290 GNUNET_array_grow(agent->s_old, agent->m, m_new); //TODO initialize new state features?
1254 agent->m = m_old;
1255 GNUNET_array_grow(agent->s_old, agent->m, m_new); //TODO initialize new state features?
1256 }
1257 1291
1258 agent->m = m_old; 1292 agent->m = m_old;
1259 GNUNET_array_grow(agent->e, agent->m, m_new); 1293 GNUNET_array_grow(agent->e, agent->m, m_new);
1260 1294
1261 if (NULL == agent->address_inuse) 1295 if (NULL == agent->address_inuse)
1262 { 1296 {
1263 envi_set_active_suggestion(s, agent, address, min_bw, min_bw); 1297 envi_set_active_suggestion (s, agent, address, min_bw, min_bw);
1264 } 1298 }
1265 1299
1266 LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_add() Added %s address %p for peer '%s'\n", 1300 LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_add() Added %s address %p for peer '%s'\n",
@@ -1290,45 +1324,48 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o
1290 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 1324 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
1291 1325
1292 LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_delete() Delete %s%s %s address %p for peer '%s'\n", 1326 LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_delete() Delete %s%s %s address %p for peer '%s'\n",
1293 session_only ? "session for " : "", 1327 session_only ? "session for " : "", address->active ? "active" : "inactive", address->plugin,
1294 address->active ? "active" : "inactive", 1328 address->addr, GNUNET_i2s (&address->peer));
1295 address->plugin,
1296 address->addr,
1297 GNUNET_i2s (&address->peer));
1298 1329
1299 agent = ril_get_agent(s, &address->peer, GNUNET_NO); 1330 agent = ril_get_agent (s, &address->peer, GNUNET_NO);
1300 if (NULL == agent) 1331 if (NULL == agent)
1301 { 1332 {
1302 net = address->solver_information; 1333 net = address->solver_information;
1303 GNUNET_assert (!ril_network_is_active(s, net->type)); 1334 GNUNET_assert(!ril_network_is_active (s, net->type));
1304 LOG (GNUNET_ERROR_TYPE_DEBUG, "No agent allocated for peer yet, since address was in inactive network\n"); 1335 LOG(GNUNET_ERROR_TYPE_DEBUG,
1336 "No agent allocated for peer yet, since address was in inactive network\n");
1305 return; 1337 return;
1306 } 1338 }
1307 1339
1308 address_index = agent_address_get_index(agent, address); 1340 address_index = agent_address_get_index (agent, address);
1309 address_wrapped = agent_address_get(agent, address); 1341 address_wrapped = agent_address_get (agent, address);
1310 1342
1311 if (NULL == address_wrapped) 1343 if (NULL == address_wrapped)
1312 { 1344 {
1313 net = address->solver_information; 1345 net = address->solver_information;
1314 GNUNET_assert (!ril_network_is_active(s, net->type)); 1346 GNUNET_assert(!ril_network_is_active (s, net->type));
1315 LOG (GNUNET_ERROR_TYPE_DEBUG, "Address not considered by agent, address was in inactive network\n"); 1347 LOG(GNUNET_ERROR_TYPE_DEBUG,
1348 "Address not considered by agent, address was in inactive network\n");
1316 return; 1349 return;
1317 } 1350 }
1318 1351
1319 GNUNET_CONTAINER_DLL_remove(agent->addresses_head, agent->addresses_tail, address_wrapped); 1352 GNUNET_CONTAINER_DLL_remove(agent->addresses_head, agent->addresses_tail, address_wrapped);
1353 GNUNET_free(address_wrapped);
1320 1354
1321 //decrease W 1355 //decrease W
1322 m_new = agent->m - 5; 1356 m_new = agent->m - RIL_FEATURES_ADDRESS_COUNT;
1323 n_new = agent->n - 1; 1357 n_new = agent->n - 1;
1324 1358
1325 for (i = 0; i < agent->n; i++) 1359 for (i = 0; i < agent->n; i++)
1326 { 1360 {
1327// LOG (GNUNET_ERROR_TYPE_DEBUG, "first - cut vectors in W\n"); 1361// LOG (GNUNET_ERROR_TYPE_DEBUG, "first - cut vectors in W\n");
1328 ril_cut_from_vector((void **) &agent->W[i], sizeof (double), ((s->networks_count * 4) + (address_index * 5)), 5, agent->m); 1362 ril_cut_from_vector ((void **) &agent->W[i], sizeof(double),
1363 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
1329 } 1364 }
1330// LOG (GNUNET_ERROR_TYPE_DEBUG, "second - cut action vector out of W\n"); 1365// LOG (GNUNET_ERROR_TYPE_DEBUG, "second - cut action vector out of W\n");
1331 ril_cut_from_vector((void **) &agent->W, sizeof (double *), RIL_ACTION_TYPE_NUM + address_index, 1, agent->n); 1366 GNUNET_free (agent->W[RIL_ACTION_TYPE_NUM + address_index]);
1367 ril_cut_from_vector ((void **) &agent->W, sizeof(double *), RIL_ACTION_TYPE_NUM + address_index,
1368 1, agent->n);
1332 //correct last action 1369 //correct last action
1333 if (agent->a_old > (RIL_ACTION_TYPE_NUM + address_index)) 1370 if (agent->a_old > (RIL_ACTION_TYPE_NUM + address_index))
1334 { 1371 {
@@ -1340,9 +1377,11 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o
1340 } 1377 }
1341 //decrease old state vector and eligibility vector 1378 //decrease old state vector and eligibility vector
1342// LOG (GNUNET_ERROR_TYPE_DEBUG, "third - cut state vector\n"); 1379// LOG (GNUNET_ERROR_TYPE_DEBUG, "third - cut state vector\n");
1343 ril_cut_from_vector((void **) &agent->s_old, sizeof (double), ((s->networks_count * 4) + (address_index * 5)), 5, agent->m); 1380 ril_cut_from_vector ((void **) &agent->s_old, sizeof(double),
1381 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
1344// LOG (GNUNET_ERROR_TYPE_DEBUG, "fourth - cut eligibility vector\n"); 1382// LOG (GNUNET_ERROR_TYPE_DEBUG, "fourth - cut eligibility vector\n");
1345 ril_cut_from_vector((void **) &agent->e, sizeof (double), ((s->networks_count * 4) + (address_index * 5)), 5, agent->m); 1383 ril_cut_from_vector ((void **) &agent->e, sizeof(double),
1384 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
1346 agent->m = m_new; 1385 agent->m = m_new;
1347 agent->n = n_new; 1386 agent->n = n_new;
1348 1387
@@ -1354,15 +1393,15 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o
1354 1393
1355 if (NULL != agent->addresses_head) //if peer has an address left, use it 1394 if (NULL != agent->addresses_head) //if peer has an address left, use it
1356 { 1395 {
1357 //TODO? check if network/bandwidth update can be done more clever/elegant at different function 1396 //TODO? check if network/bandwidth update can be done more clever/elegant at different function
1358 envi_set_active_suggestion(s, agent, agent->addresses_head->address_naked, min_bw, min_bw); 1397 envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, min_bw, min_bw);
1359 net = agent->addresses_head->address_naked->solver_information; 1398 net = agent->addresses_head->address_naked->solver_information;
1360 net->bw_in_assigned -= min_bw; 1399 net->bw_in_assigned -= min_bw;
1361 net->bw_out_assigned -= min_bw; 1400 net->bw_out_assigned -= min_bw;
1362 } 1401 }
1363 } 1402 }
1364 1403
1365 LOG (GNUNET_ERROR_TYPE_DEBUG, "Address deleted\n"); 1404 LOG(GNUNET_ERROR_TYPE_DEBUG, "Address deleted\n");
1366} 1405}
1367 1406
1368/** 1407/**
@@ -1383,8 +1422,8 @@ GAS_ril_address_property_changed (void *solver,
1383{ 1422{
1384 LOG(GNUNET_ERROR_TYPE_DEBUG, 1423 LOG(GNUNET_ERROR_TYPE_DEBUG,
1385 "API_address_property_changed() Property '%s' for peer '%s' address %p changed " 1424 "API_address_property_changed() Property '%s' for peer '%s' address %p changed "
1386 "to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), address->addr, 1425 "to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
1387 rel_value); 1426 address->addr, rel_value);
1388 /* 1427 /*
1389 * Nothing to do here, properties are considered in every reward calculation 1428 * Nothing to do here, properties are considered in every reward calculation
1390 */ 1429 */
@@ -1460,18 +1499,18 @@ GAS_ril_address_change_network (void *solver,
1460 (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer), 1499 (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer),
1461 GNUNET_ATS_print_network_type (current_network), GNUNET_ATS_print_network_type (new_network)); 1500 GNUNET_ATS_print_network_type (current_network), GNUNET_ATS_print_network_type (new_network));
1462 1501
1463 if (address->active && !ril_network_is_active(solver, new_network)) 1502 if (address->active && !ril_network_is_active (solver, new_network))
1464 { 1503 {
1465 GAS_ril_address_delete(solver, address, GNUNET_NO); 1504 GAS_ril_address_delete (solver, address, GNUNET_NO);
1466 return; 1505 return;
1467 } 1506 }
1468 1507
1469 agent = ril_get_agent(s, &address->peer, GNUNET_NO); 1508 agent = ril_get_agent (s, &address->peer, GNUNET_NO);
1470 if (NULL == agent) 1509 if (NULL == agent)
1471 { 1510 {
1472 //no agent there yet, so add as if address is new 1511 //no agent there yet, so add as if address is new
1473 address->solver_information = ril_get_network (s, new_network); 1512 address->solver_information = ril_get_network (s, new_network);
1474 GAS_ril_address_add(s,address,new_network); 1513 GAS_ril_address_add (s, address, new_network);
1475 return; 1514 return;
1476 } 1515 }
1477 1516