[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35125 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35125 - gnunet/src/ats |
Date: |
Sat, 7 Feb 2015 13:33:51 +0100 |
Author: grothoff
Date: 2015-02-07 13:33:51 +0100 (Sat, 07 Feb 2015)
New Revision: 35125
Modified:
gnunet/src/ats/gnunet-service-ats_plugins.c
gnunet/src/ats/gnunet-service-ats_plugins.h
gnunet/src/ats/gnunet-service-ats_preferences.c
Log:
simplify logic
Modified: gnunet/src/ats/gnunet-service-ats_plugins.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-06 14:26:35 UTC (rev
35124)
+++ gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-07 12:33:51 UTC (rev
35125)
@@ -277,10 +277,10 @@
unsigned long long *in_dest,
int dest_length)
{
- char * entry_in = NULL;
- char * entry_out = NULL;
- char * quota_out_str;
- char * quota_in_str;
+ char *entry_in = NULL;
+ char *entry_out = NULL;
+ char *quota_out_str;
+ char *quota_in_str;
int c;
int res;
@@ -367,11 +367,11 @@
if (GNUNET_NO == res)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- _("Could not load quota for network `%s': `%s', assigning
default bandwidth %llu\n"),
- GNUNET_ATS_print_network_type (c),
- quota_in_str,
- GNUNET_ATS_DefaultBandwidth);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not load quota for network `%s': `%s', assigning
default bandwidth %llu\n"),
+ GNUNET_ATS_print_network_type (c),
+ quota_in_str,
+ GNUNET_ATS_DefaultBandwidth);
in_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
else
@@ -385,17 +385,17 @@
}
else
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- _("No outbound quota configure for network `%s', assigning
default bandwidth %llu\n"),
- GNUNET_ATS_print_network_type (c),
- GNUNET_ATS_DefaultBandwidth);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No outbound quota configure for network `%s', assigning
default bandwidth %llu\n"),
+ GNUNET_ATS_print_network_type (c),
+ GNUNET_ATS_DefaultBandwidth);
in_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Loaded quota for network `%s' (in/out): %llu %llu\n",
- GNUNET_ATS_print_network_type (c),
- in_dest[c],
- out_dest[c]);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Loaded quota for network `%s' (in/out): %llu %llu\n",
+ GNUNET_ATS_print_network_type (c),
+ in_dest[c],
+ out_dest[c]);
GNUNET_free(entry_out);
GNUNET_free(entry_in);
}
@@ -520,6 +520,15 @@
}
+/**
+ * Tell the solver that the given address can now be used
+ * for talking to the respective peer.
+ *
+ * @param new_address the new address
+ * @param addr_net network scope the address is in
+ * @param atsi performance data for the address
+ * @param atsi_count size of the @a atsi array
+ */
void
GAS_plugin_new_address (struct ATS_Address *new_address,
enum GNUNET_ATS_Network_Type addr_net,
@@ -532,10 +541,17 @@
atsi,
atsi_count);
sf->s_bulk_stop (sf->cls);
- // if (GAS_connectivity_has_peer (&new_address->peer))
GAS_plugin_request_connect_start (&new_address->peer);
}
+/**
+ * Tell the solver that updated performance data was
+ * observed for the given address.
+ *
+ * @param new_address the new address
+ * @param atsi updated performance data for the address
+ * @param atsi_count size of the @a atsi array
+ */
void
GAS_plugin_update_address (struct ATS_Address *address,
const struct GNUNET_ATS_Information *atsi,
@@ -549,6 +565,12 @@
}
+/**
+ * Tell the solver that the given address is no longer valid
+ * can cannot be used any longer.
+ *
+ * @param address address that was deleted
+ */
void
GAS_plugin_delete_address (struct ATS_Address *address)
{
@@ -556,35 +578,36 @@
}
+/**
+ * Tell the solver that the given client has expressed its
+ * appreciation for the past performance of a given connection.
+ *
+ * @param application client providing the feedback
+ * @param peer peer the feedback is about
+ * @param scope timeframe the feedback applies to
+ * @param kind performance property the feedback relates to
+ * @param score_abs degree of the appreciation
+ */
void
-GAS_plugin_update_preferences (void *client,
- const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind,
- float score_abs)
-{
- sf->s_bulk_start (sf->cls);
- /* Tell normalization about change, normalization will call callback if
preference changed */
- GAS_normalization_normalize_preference (client, peer, kind, score_abs);
- sf->s_bulk_stop (sf->cls);
-}
-
-
-void
-GAS_plugin_preference_feedback (void *application,
+GAS_plugin_preference_feedback (struct GNUNET_SERVER_Client *application,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TIME_Relative scope,
enum GNUNET_ATS_PreferenceKind kind,
float score_abs)
{
sf->s_feedback (sf->cls,
- application,
- peer,
- scope,
- kind,
- score_abs);
+ application,
+ peer,
+ scope,
+ kind,
+ score_abs);
}
+/**
+ * Stop instant solving, there are many state updates
+ * happening in bulk right now.
+ */
void
GAS_plugin_solver_lock ()
{
@@ -592,6 +615,9 @@
}
+/**
+ * Resume instant solving, we are done with the bulk state updates.
+ */
void
GAS_plugin_solver_unlock ()
{
@@ -599,6 +625,12 @@
}
+/**
+ * Notify the plugin that a request to connect to
+ * a particular peer was given to us.
+ *
+ * @param pid identity of peer we now care about
+ */
void
GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid)
{
@@ -623,6 +655,12 @@
}
+/**
+ * Notify the plugin that a request to connect to
+ * a particular peer was dropped.
+ *
+ * @param pid identity of peer we care now less about
+ */
void
GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid)
{
Modified: gnunet/src/ats/gnunet-service-ats_plugins.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-06 14:26:35 UTC (rev
35124)
+++ gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-07 12:33:51 UTC (rev
35125)
@@ -108,6 +108,15 @@
double prop_rel);
+/**
+ * Tell the solver that the given address can now be used
+ * for talking to the respective peer.
+ *
+ * @param new_address the new address
+ * @param addr_net network scope the address is in
+ * @param atsi performance data for the address
+ * @param atsi_count size of the @a atsi array
+ */
void
GAS_plugin_new_address (struct ATS_Address *new_address,
enum GNUNET_ATS_Network_Type addr_net,
@@ -115,45 +124,83 @@
uint32_t atsi_count);
+/**
+ * Tell the solver that updated performance data was
+ * observed for the given address.
+ *
+ * @param new_address the new address
+ * @param atsi updated performance data for the address
+ * @param atsi_count size of the @a atsi array
+ */
void
GAS_plugin_update_address (struct ATS_Address *address,
const struct GNUNET_ATS_Information *atsi,
uint32_t atsi_count);
+/**
+ * Tell the solver that the given address is no longer valid
+ * can cannot be used any longer.
+ *
+ * @param address address that was deleted
+ */
void
-GAS_plugin_update_preferences (void *client,
- const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind,
- float score_abs);
+GAS_plugin_delete_address (struct ATS_Address *address);
+/**
+ * Tell the solver that the given client has expressed its
+ * appreciation for the past performance of a given connection.
+ *
+ * @param application client providing the feedback
+ * @param peer peer the feedback is about
+ * @param scope timeframe the feedback applies to
+ * @param kind performance property the feedback relates to
+ * @param score_abs degree of the appreciation
+ */
void
-GAS_plugin_preference_feedback (void *application,
+GAS_plugin_preference_feedback (struct GNUNET_SERVER_Client *application,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TIME_Relative scope,
enum GNUNET_ATS_PreferenceKind kind,
float score_abs);
-void
-GAS_plugin_delete_address (struct ATS_Address *address);
+/**
+ * Stop instant solving, there are many state updates
+ * happening in bulk right now.
+ */
void
-GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid);
+GAS_plugin_solver_lock (void);
+/**
+ * Resume instant solving, we are done with the bulk state updates.
+ */
void
-GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid);
+GAS_plugin_solver_unlock (void);
+/**
+ * Notify the plugin that a request to connect to
+ * a particular peer was given to us.
+ *
+ * @param pid identity of peer we now care about
+ */
void
-GAS_plugin_solver_lock (void);
+GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid);
+/**
+ * Notify the plugin that a request to connect to
+ * a particular peer was dropped.
+ *
+ * @param pid identity of peer we care now less about
+ */
void
-GAS_plugin_solver_unlock (void);
+GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid);
#endif
Modified: gnunet/src/ats/gnunet-service-ats_preferences.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_preferences.c 2015-02-06 14:26:35 UTC
(rev 35124)
+++ gnunet/src/ats/gnunet-service-ats_preferences.c 2015-02-07 12:33:51 UTC
(rev 35125)
@@ -435,7 +435,7 @@
p->f_abs[kind] = score;
/* p->f_abs[kind] = (p->f_abs[kind] + score) / 2; */
p->next_aging[kind] = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get
(),
- PREF_AGING_INTERVAL);
+ PREF_AGING_INTERVAL);
break;
case GNUNET_ATS_PREFERENCE_END:
break;
@@ -471,10 +471,10 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received CHANGE_PREFERENCE for peer `%s'\n",
GNUNET_i2s (peer));
- GAS_plugin_update_preferences (client,
- peer,
- kind,
- score_abs);
+ GAS_normalization_normalize_preference (client,
+ peer,
+ kind,
+ score_abs);
}
@@ -664,7 +664,6 @@
c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE;
c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE;
}
-
GNUNET_CONTAINER_DLL_insert (pc_head,
pc_tail,
c_cur);
@@ -685,7 +684,7 @@
{
p_cur = GNUNET_new (struct PreferencePeer);
p_cur->client = c_cur;
- p_cur->id = (*peer);
+ p_cur->id = *peer;
for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
{
/* Default value per peer absolute preference for a preference: 0 */
@@ -725,10 +724,12 @@
if (p_cur->f_abs[kind] == old_value)
return;
+ GAS_plugin_solver_lock ();
run_preference_update (c_cur,
p_cur,
kind,
score_abs);
+ GAS_plugin_solver_unlock ();
if (NULL == aging_task)
aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35125 - gnunet/src/ats,
gnunet <=