[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30795 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30795 - gnunet/src/ats |
Date: |
Tue, 19 Nov 2013 13:40:04 +0100 |
Author: wachs
Date: 2013-11-19 13:40:04 +0100 (Tue, 19 Nov 2013)
New Revision: 30795
Modified:
gnunet/src/ats/gnunet-service-ats_addresses.c
gnunet/src/ats/gnunet-service-ats_addresses.h
gnunet/src/ats/gnunet-service-ats_normalization.c
gnunet/src/ats/gnunet-service-ats_normalization.h
gnunet/src/ats/gnunet-service-ats_performance.c
gnunet/src/ats/libgnunet_plugin_ats_proportional.c
Log:
- reduce debug level in proportional
- store pref client in DLL
- remove disconnected clients
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -249,6 +249,27 @@
struct GNUNET_PeerIdentity id;
};
+ /**
+ * Pending Address suggestion requests
+ */
+ struct GAS_Addresses_Preference_Clients
+ {
+ /**
+ * Next in DLL
+ */
+ struct GAS_Addresses_Preference_Clients *next;
+
+ /**
+ * Previous in DLL
+ */
+ struct GAS_Addresses_Preference_Clients *prev;
+
+ /**
+ * Peer ID
+ */
+ void *client;
+ };
+
/**
* Handle for ATS address component
*/
@@ -290,6 +311,16 @@
struct GAS_Addresses_Suggestion_Requests *pending_requests_tail;
/**
+ * Address suggestion requests DLL head
+ */
+ struct GAS_Addresses_Preference_Clients *preference_clients_head;
+
+ /**
+ * Address suggestion requests DLL head
+ */
+ struct GAS_Addresses_Preference_Clients *preference_clients_tail;
+
+ /**
* Solver functions
*/
struct GNUNET_ATS_PluginEnvironment env;
@@ -636,7 +667,7 @@
const double *
get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
{
- return GAS_normalization_get_preferences (id);
+ return GAS_normalization_get_preferences_by_peer (id);
}
/**
@@ -1365,7 +1396,7 @@
struct GAS_Addresses_Handle *ah;
};
-
+#if 0
static int
eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id,
void *obj)
{
@@ -1390,6 +1421,7 @@
return GNUNET_OK;
}
+#endif
/**
@@ -1401,6 +1433,7 @@
GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah)
{
struct GAS_Addresses_Suggestion_Requests *cur;
+ struct GAS_Addresses_Preference_Clients *pcur;
int c;
float quality_requests_fulfilled = 0.0;
@@ -1491,11 +1524,13 @@
}
/* 3) How well does selection match application requirements */
- for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next)
+ include_requirements = GNUNET_NO;
+ for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next)
{
- GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses,
- &cur->id, &eval_preference_relativity, ah);
- include_requirements = GNUNET_NO;
+ /* V metrics*/
+ {
+ /* V peers */
+ }
}
/* GUQ */
@@ -1656,9 +1691,42 @@
ah->env.sf.s_address_update_property (ah->solver, address, type, 0,
prop_rel);
}
+static struct GAS_Addresses_Preference_Clients *
+find_preference_client (struct GAS_Addresses_Handle *handle, void *client)
+{
+ struct GAS_Addresses_Preference_Clients *cur;
+ for (cur = handle->preference_clients_head; NULL != cur; cur = cur->next)
+ {
+ if (cur->client == client)
+ return cur;
+ }
+ return NULL;
+}
/**
+ * A performance client disconnected
+ *
+ * @param handle address handle
+ * @param client the client
+ */
+
+void
+GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle
*handle,
+ void *client)
+{
+ struct GAS_Addresses_Preference_Clients * pc;
+ if (NULL != (pc = find_preference_client (handle, client)))
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head,
+ handle->preference_clients_tail, pc);
+ GNUNET_free (pc);
+ }
+
+ GAS_normalization_preference_client_disconnect (client);
+}
+
+/**
* Change the preference for a peer
*
* @param handle the address handle
@@ -1668,10 +1736,11 @@
* @param score_abs the new preference score
*/
void
-GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
+GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
void *client, const struct GNUNET_PeerIdentity *peer,
enum GNUNET_ATS_PreferenceKind kind, float score_abs)
{
+ struct GAS_Addresses_Preference_Clients * pc;
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE",
GNUNET_i2s (peer), client);
@@ -1689,6 +1758,14 @@
return;
}
+ if (NULL == find_preference_client (handle, client))
+ {
+ pc = GNUNET_malloc (sizeof (struct GAS_Addresses_Preference_Clients));
+ pc->client = client;
+ GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head,
+ handle->preference_clients_tail, pc);
+ }
+
handle->env.sf.s_bulk_start (handle->solver);
/* Tell normalization about change, normalization will call callback if
preference changed */
GAS_normalization_normalize_preference (client, peer, kind, score_abs);
@@ -2110,6 +2187,7 @@
GAS_addresses_done (struct GAS_Addresses_Handle *handle)
{
struct GAS_Addresses_Suggestion_Requests *cur;
+ struct GAS_Addresses_Preference_Clients *pcur;
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down addresses\n");
GNUNET_assert(NULL != handle);
@@ -2123,6 +2201,13 @@
GNUNET_free(cur);
}
+ while (NULL != (pcur = handle->preference_clients_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head,
+ handle->preference_clients_tail, pcur);
+ GNUNET_free (pcur);
+ }
+
GNUNET_PLUGIN_unload (handle->plugin, handle->solver);
GNUNET_free (handle->plugin);
GNUNET_free(handle);
Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -523,7 +523,19 @@
GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
const struct GNUNET_PeerIdentity *peer);
+
/**
+ * A performance client disconnected
+ *
+ * @param handle address handle
+ * @param client the client
+ */
+
+void
+GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle
*handle,
+ void *client);
+
+/**
* Change the preference for a peer
*
* @param handle the address handle
@@ -533,7 +545,7 @@
* @param score_abs the new preference score
*/
void
-GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
+GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
void *client, const struct GNUNET_PeerIdentity *peer,
enum GNUNET_ATS_PreferenceKind kind, float score_abs);
Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -404,6 +404,7 @@
}
+
/**
* Normalize an updated preference value
*
@@ -502,7 +503,7 @@
* default preferences if peer does not exist
*/
const double *
-GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id)
+GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity
*id)
{
GNUNET_assert(NULL != preference_peers);
GNUNET_assert(NULL != id);
@@ -809,7 +810,49 @@
}
}
+
+static void
+free_client (struct PreferenceClient *pc)
+{
+ struct PreferencePeer *next_p;
+ struct PreferencePeer *p;
+ next_p = pc->p_head;
+ while (NULL != (p = next_p))
+ {
+ next_p = p->next;
+ GNUNET_CONTAINER_DLL_remove(pc->p_head, pc->p_tail, p);
+ GNUNET_free(p);
+ }
+ GNUNET_free(pc);
+}
+
+
/**
+ * A performance client disconnected
+ *
+ * @param client the client
+ */
+
+void
+GAS_normalization_preference_client_disconnect (void *client)
+{
+ struct PreferenceClient *c_cur;
+ /* Find preference client */
+
+ for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next)
+ {
+ if (client == c_cur->client)
+ break;
+ }
+ if (NULL == c_cur)
+ return;
+
+ GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, c_cur);
+ free_client (c_cur);
+}
+
+
+/**
* Start the normalization component
*
* @param pref_ch_cb callback to call on relative preference changing
@@ -893,14 +936,7 @@
{
next_pc = pc->next;
GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc);
- next_p = pc->p_head;
- while (NULL != (p = next_p))
- {
- next_p = p->next;
- GNUNET_CONTAINER_DLL_remove(pc->p_head, pc->p_tail, p);
- GNUNET_free(p);
- }
- GNUNET_free(pc);
+ free_client (pc);
}
GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &free_peer, NULL );
Modified: gnunet/src/ats/gnunet-service-ats_normalization.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.h 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/gnunet-service-ats_normalization.h 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -55,7 +55,7 @@
* with GNUNET_ATS_PreferenceKind, NULL if peer does not exist
*/
const double *
-GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id);
+GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity
*id);
/**
@@ -99,6 +99,14 @@
/**
+ * A performance client disconnected
+ *
+ * @param client the disconnecting client
+ */
+void
+GAS_normalization_preference_client_disconnect (void *client);
+
+/**
* Start the normalization component
*
* @param pref_ch_cb callback to call on relative preference changing
Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/gnunet-service-ats_performance.c 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -129,6 +129,7 @@
if (NULL == pc)
return;
GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
+ GAS_addresses_preference_client_disconnect (GSA_addresses, client);
GNUNET_free (pc);
}
@@ -639,7 +640,7 @@
1, GNUNET_NO);
pi = (const struct PreferenceInformation *) &msg[1];
for (i = 0; i < nump; i++)
- GAS_addresses_change_preference (GSA_addresses,
+ GAS_addresses_preference_change (GSA_addresses,
client,
&msg->peer,
(enum GNUNET_ATS_PreferenceKind)
Modified: gnunet/src/ats/libgnunet_plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/libgnunet_plugin_ats_proportional.c 2013-11-19 11:15:52 UTC
(rev 30794)
+++ gnunet/src/ats/libgnunet_plugin_ats_proportional.c 2013-11-19 12:40:04 UTC
(rev 30795)
@@ -479,7 +479,7 @@
if (s->network_entries[c].active_addresses > 0)
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
"Had %u active addresses for network `%s' not deleted during
shutdown\n",
s->network_entries[c].active_addresses, s->network_entries[c].desc);
GNUNET_break(0);
@@ -499,13 +499,13 @@
}
if (s->total_addresses > 0)
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
"Had %u addresses not deleted during shutdown\n", s->total_addresses);
GNUNET_break(0);
}
if (s->active_addresses > 0)
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
"Had %u active addresses not deleted during shutdown\n",
s->active_addresses);
GNUNET_break (0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30795 - gnunet/src/ats,
gnunet <=