diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 12:40:04 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 12:40:04 +0000 |
commit | f2554d328813646fe2bf6771ea269578b9961622 (patch) | |
tree | 04e82cd9bb13dac95b91ed9bcaad228ae66d3dcc /src/ats/gnunet-service-ats_addresses.c | |
parent | 8dda13088674ec864e3133e8a5770e01704e8409 (diff) | |
download | gnunet-f2554d328813646fe2bf6771ea269578b9961622.tar.gz gnunet-f2554d328813646fe2bf6771ea269578b9961622.zip |
- reduce debug level in proportional
- store pref client in DLL
- remove disconnected clients
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 99 |
1 files changed, 92 insertions, 7 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 154838a00..746dbd7e3 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -249,6 +249,27 @@ struct GAS_Addresses_Suggestion_Requests | |||
249 | struct GNUNET_PeerIdentity id; | 249 | struct GNUNET_PeerIdentity id; |
250 | }; | 250 | }; |
251 | 251 | ||
252 | /** | ||
253 | * Pending Address suggestion requests | ||
254 | */ | ||
255 | struct GAS_Addresses_Preference_Clients | ||
256 | { | ||
257 | /** | ||
258 | * Next in DLL | ||
259 | */ | ||
260 | struct GAS_Addresses_Preference_Clients *next; | ||
261 | |||
262 | /** | ||
263 | * Previous in DLL | ||
264 | */ | ||
265 | struct GAS_Addresses_Preference_Clients *prev; | ||
266 | |||
267 | /** | ||
268 | * Peer ID | ||
269 | */ | ||
270 | void *client; | ||
271 | }; | ||
272 | |||
252 | /** | 273 | /** |
253 | * Handle for ATS address component | 274 | * Handle for ATS address component |
254 | */ | 275 | */ |
@@ -290,6 +311,16 @@ struct GAS_Addresses_Handle | |||
290 | struct GAS_Addresses_Suggestion_Requests *pending_requests_tail; | 311 | struct GAS_Addresses_Suggestion_Requests *pending_requests_tail; |
291 | 312 | ||
292 | /** | 313 | /** |
314 | * Address suggestion requests DLL head | ||
315 | */ | ||
316 | struct GAS_Addresses_Preference_Clients *preference_clients_head; | ||
317 | |||
318 | /** | ||
319 | * Address suggestion requests DLL head | ||
320 | */ | ||
321 | struct GAS_Addresses_Preference_Clients *preference_clients_tail; | ||
322 | |||
323 | /** | ||
293 | * Solver functions | 324 | * Solver functions |
294 | */ | 325 | */ |
295 | struct GNUNET_ATS_PluginEnvironment env; | 326 | struct GNUNET_ATS_PluginEnvironment env; |
@@ -636,7 +667,7 @@ find_exact_address (struct GAS_Addresses_Handle *handle, | |||
636 | const double * | 667 | const double * |
637 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 668 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) |
638 | { | 669 | { |
639 | return GAS_normalization_get_preferences (id); | 670 | return GAS_normalization_get_preferences_by_peer (id); |
640 | } | 671 | } |
641 | 672 | ||
642 | /** | 673 | /** |
@@ -1365,7 +1396,7 @@ struct RelativityContext { | |||
1365 | struct GAS_Addresses_Handle *ah; | 1396 | struct GAS_Addresses_Handle *ah; |
1366 | }; | 1397 | }; |
1367 | 1398 | ||
1368 | 1399 | #if 0 | |
1369 | static int | 1400 | static int |
1370 | eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, void *obj) | 1401 | eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, void *obj) |
1371 | { | 1402 | { |
@@ -1390,6 +1421,7 @@ eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, voi | |||
1390 | 1421 | ||
1391 | return GNUNET_OK; | 1422 | return GNUNET_OK; |
1392 | } | 1423 | } |
1424 | #endif | ||
1393 | 1425 | ||
1394 | 1426 | ||
1395 | /** | 1427 | /** |
@@ -1401,6 +1433,7 @@ void | |||
1401 | GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | 1433 | GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) |
1402 | { | 1434 | { |
1403 | struct GAS_Addresses_Suggestion_Requests *cur; | 1435 | struct GAS_Addresses_Suggestion_Requests *cur; |
1436 | struct GAS_Addresses_Preference_Clients *pcur; | ||
1404 | int c; | 1437 | int c; |
1405 | 1438 | ||
1406 | float quality_requests_fulfilled = 0.0; | 1439 | float quality_requests_fulfilled = 0.0; |
@@ -1491,11 +1524,13 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | |||
1491 | } | 1524 | } |
1492 | 1525 | ||
1493 | /* 3) How well does selection match application requirements */ | 1526 | /* 3) How well does selection match application requirements */ |
1494 | for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next) | 1527 | include_requirements = GNUNET_NO; |
1528 | for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next) | ||
1495 | { | 1529 | { |
1496 | GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses, | 1530 | /* V metrics*/ |
1497 | &cur->id, &eval_preference_relativity, ah); | 1531 | { |
1498 | include_requirements = GNUNET_NO; | 1532 | /* V peers */ |
1533 | } | ||
1499 | } | 1534 | } |
1500 | /* GUQ */ | 1535 | /* GUQ */ |
1501 | 1536 | ||
@@ -1656,7 +1691,40 @@ normalized_property_changed_cb (void *cls, struct ATS_Address *address, | |||
1656 | ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel); | 1691 | ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel); |
1657 | } | 1692 | } |
1658 | 1693 | ||
1694 | static struct GAS_Addresses_Preference_Clients * | ||
1695 | find_preference_client (struct GAS_Addresses_Handle *handle, void *client) | ||
1696 | { | ||
1697 | struct GAS_Addresses_Preference_Clients *cur; | ||
1698 | |||
1699 | for (cur = handle->preference_clients_head; NULL != cur; cur = cur->next) | ||
1700 | { | ||
1701 | if (cur->client == client) | ||
1702 | return cur; | ||
1703 | } | ||
1704 | return NULL; | ||
1705 | } | ||
1706 | |||
1707 | /** | ||
1708 | * A performance client disconnected | ||
1709 | * | ||
1710 | * @param handle address handle | ||
1711 | * @param client the client | ||
1712 | */ | ||
1713 | |||
1714 | void | ||
1715 | GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle *handle, | ||
1716 | void *client) | ||
1717 | { | ||
1718 | struct GAS_Addresses_Preference_Clients * pc; | ||
1719 | if (NULL != (pc = find_preference_client (handle, client))) | ||
1720 | { | ||
1721 | GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head, | ||
1722 | handle->preference_clients_tail, pc); | ||
1723 | GNUNET_free (pc); | ||
1724 | } | ||
1659 | 1725 | ||
1726 | GAS_normalization_preference_client_disconnect (client); | ||
1727 | } | ||
1660 | 1728 | ||
1661 | /** | 1729 | /** |
1662 | * Change the preference for a peer | 1730 | * Change the preference for a peer |
@@ -1668,10 +1736,11 @@ normalized_property_changed_cb (void *cls, struct ATS_Address *address, | |||
1668 | * @param score_abs the new preference score | 1736 | * @param score_abs the new preference score |
1669 | */ | 1737 | */ |
1670 | void | 1738 | void |
1671 | GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle, | 1739 | GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle, |
1672 | void *client, const struct GNUNET_PeerIdentity *peer, | 1740 | void *client, const struct GNUNET_PeerIdentity *peer, |
1673 | enum GNUNET_ATS_PreferenceKind kind, float score_abs) | 1741 | enum GNUNET_ATS_PreferenceKind kind, float score_abs) |
1674 | { | 1742 | { |
1743 | struct GAS_Addresses_Preference_Clients * pc; | ||
1675 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1744 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1676 | "Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE", | 1745 | "Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE", |
1677 | GNUNET_i2s (peer), client); | 1746 | GNUNET_i2s (peer), client); |
@@ -1689,6 +1758,14 @@ GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle, | |||
1689 | return; | 1758 | return; |
1690 | } | 1759 | } |
1691 | 1760 | ||
1761 | if (NULL == find_preference_client (handle, client)) | ||
1762 | { | ||
1763 | pc = GNUNET_malloc (sizeof (struct GAS_Addresses_Preference_Clients)); | ||
1764 | pc->client = client; | ||
1765 | GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head, | ||
1766 | handle->preference_clients_tail, pc); | ||
1767 | } | ||
1768 | |||
1692 | handle->env.sf.s_bulk_start (handle->solver); | 1769 | handle->env.sf.s_bulk_start (handle->solver); |
1693 | /* Tell normalization about change, normalization will call callback if preference changed */ | 1770 | /* Tell normalization about change, normalization will call callback if preference changed */ |
1694 | GAS_normalization_normalize_preference (client, peer, kind, score_abs); | 1771 | GAS_normalization_normalize_preference (client, peer, kind, score_abs); |
@@ -2110,6 +2187,7 @@ void | |||
2110 | GAS_addresses_done (struct GAS_Addresses_Handle *handle) | 2187 | GAS_addresses_done (struct GAS_Addresses_Handle *handle) |
2111 | { | 2188 | { |
2112 | struct GAS_Addresses_Suggestion_Requests *cur; | 2189 | struct GAS_Addresses_Suggestion_Requests *cur; |
2190 | struct GAS_Addresses_Preference_Clients *pcur; | ||
2113 | 2191 | ||
2114 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down addresses\n"); | 2192 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down addresses\n"); |
2115 | GNUNET_assert(NULL != handle); | 2193 | GNUNET_assert(NULL != handle); |
@@ -2123,6 +2201,13 @@ GAS_addresses_done (struct GAS_Addresses_Handle *handle) | |||
2123 | GNUNET_free(cur); | 2201 | GNUNET_free(cur); |
2124 | } | 2202 | } |
2125 | 2203 | ||
2204 | while (NULL != (pcur = handle->preference_clients_head)) | ||
2205 | { | ||
2206 | GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head, | ||
2207 | handle->preference_clients_tail, pcur); | ||
2208 | GNUNET_free (pcur); | ||
2209 | } | ||
2210 | |||
2126 | GNUNET_PLUGIN_unload (handle->plugin, handle->solver); | 2211 | GNUNET_PLUGIN_unload (handle->plugin, handle->solver); |
2127 | GNUNET_free (handle->plugin); | 2212 | GNUNET_free (handle->plugin); |
2128 | GNUNET_free(handle); | 2213 | GNUNET_free(handle); |