for (c = 0; c < dest_length; c++)
{
cur = &s->network_entries[c];
+ cur->active_addresses = 0;
cur->type = network[c];
cur->total_quota_in = in_quota[c];
cur->total_quota_out = out_quota[c];
}
static void
-update_quota (struct GAS_SIMPLISTIC_Handle *s, struct Network *net)
+update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, struct Network *net)
{
unsigned long long quota_in;
unsigned long long quota_out;
quota_out = net->total_quota_out / net->active_addresses;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "New quota for network type `%s' (in/out): %llu/%llu \n",
- net->desc, quota_in, quota_out);
+ "New per address quota for network type `%s' for %u addresses (in/out): %llu/%llu \n",
+ net->desc, net->active_addresses, quota_in, quota_out);
cur = net->head;
while (NULL != cur)
cur->addr->assigned_bw_in.value__ = htonl (quota_in);
cur->addr->assigned_bw_out.value__ = htonl (quota_out);
/* Notify on change */
- s->bw_changed (cur->addr);
+ if (GNUNET_YES == cur->addr->active)
+ s->bw_changed (cur->addr);
}
cur = cur->next;
}
cur->active_addresses);
/* Update quota for this network type */
- update_quota (s, cur);
+ update_quota_per_network (s, cur);
}
}
/* Update quota for this network type */
- update_quota (s, c);
+ update_quota_per_network (s, c);
#endif
}
}
/* Update quota for this network type */
- update_quota (s, c);
+ update_quota_per_network (s, c);
#endif
}
const struct GNUNET_PeerIdentity *peer)
{
struct GAS_SIMPLISTIC_Handle *s = solver;
- struct ATS_Address *aa;
- struct ATS_Address *previous;
+ struct Network *net_prev;
+ struct Network *net_cur;
+ struct ATS_Address *cur;
+ struct ATS_Address *prev;
GNUNET_assert (s != NULL);
- aa = NULL;
+ cur = NULL;
/* Get address with: stick to current address, lower distance, lower latency */
GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
- &find_address_it, &aa);
- if (NULL == aa)
+ &find_address_it, &cur);
+ if (NULL == cur)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
return NULL;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
-
- if (GNUNET_YES == aa->active)
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n", cur, GNUNET_i2s (peer));
+ net_cur = (struct Network *) cur->solver_information;
+ if (GNUNET_YES == cur->active)
{
/* This address was selected previously, so no need to update quotas */
- return aa;
+ return cur;
}
/* This address was not active, so we have to:
* - update quota for this address network
*/
- previous = find_active_address (solver, addresses, peer);
- if (NULL == previous)
+ prev = find_active_address (s, addresses, peer);
+ if (NULL != prev)
{
- /* No currently address, nothing to do */
- return aa;
+ net_prev = (struct Network *) prev->solver_information;
+ prev->active = GNUNET_NO; /* No active any longer */
+ prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
+ prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
+ s->bw_changed (prev); /* notify about bw change, REQUIERED? */
+ net_cur->active_addresses --;
+ update_quota_per_network (s, net_prev);
}
- aa->active = GNUNET_YES;
- s->active_addresses++;
+ cur->active = GNUNET_YES;
+ net_cur->active_addresses ++;
+ update_quota_per_network (s, net_cur);
- return aa;
+ return cur;
}
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_ATS_scheduling_done (sched_ats);
+ if (NULL != sched_ats)
+ GNUNET_ATS_scheduling_done (sched_ats);
sched_ats = NULL;
free_test_address (&test_addr);
}
const struct GNUNET_ATS_Information *atsi,
uint32_t ats_count)
{
- if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 0;
- }
- else
+ static int stage = 0;
+ if (0 == stage)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n",
- GNUNET_i2s (&address->peer));
- ret = 1;
- }
+ if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n",
+ GNUNET_i2s (&address->peer));
+ ret = 0;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n",
+ GNUNET_i2s (&address->peer));
+ ret = 1;
+ }
- if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n");
- ret = 1;
+ if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n");
+ ret = 1;
+ }
+ stage ++;
+ GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
-
- GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
- GNUNET_SCHEDULER_add_now (&end, NULL);
}
static void