gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35114 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r35114 - gnunet/src/ats
Date: Thu, 5 Feb 2015 21:09:20 +0100

Author: grothoff
Date: 2015-02-05 21:09:20 +0100 (Thu, 05 Feb 2015)
New Revision: 35114

Modified:
   gnunet/src/ats/gnunet-service-ats_preferences.c
Log:
starting with cleaning up gnunet-service-ats_preferences.c

Modified: gnunet/src/ats/gnunet-service-ats_preferences.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_preferences.c     2015-02-05 20:04:08 UTC 
(rev 35113)
+++ gnunet/src/ats/gnunet-service-ats_preferences.c     2015-02-05 20:09:20 UTC 
(rev 35114)
@@ -64,14 +64,13 @@
 static struct PeerRelative defvalues;
 
 
-
 /**
- * Preference client
+ * Preference client, information we keep track of per client.
  */
 struct PreferenceClient
 {
   /**
-   * Next in DLL
+   * Previous in DLL
    */
   struct PreferenceClient *prev;
 
@@ -81,54 +80,54 @@
   struct PreferenceClient *next;
 
   /**
-   * Client handle
+   * Head of peer list
    */
-  void *client;
+  struct PreferencePeer *p_head;
 
   /**
-   * Array of sum of absolute preferences for this client
+   * Tail of peer list
    */
-  double f_abs_sum[GNUNET_ATS_PreferenceCount];
+  struct PreferencePeer *p_tail;
 
   /**
-   * Array of sum of relative preferences for this client
+   * Client handle
    */
-  double f_rel_sum[GNUNET_ATS_PreferenceCount];
+  struct GNUNET_SERVER_Client *client;
 
   /**
-   * Head of peer list
+   * Array of sum of absolute preferences for this client
    */
-  struct PreferencePeer *p_head;
+  double f_abs_sum[GNUNET_ATS_PreferenceCount];
 
   /**
-   * Tail of peer list
+   * Array of sum of relative preferences for this client
    */
-  struct PreferencePeer *p_tail;
+  double f_rel_sum[GNUNET_ATS_PreferenceCount];
 };
 
 
 /**
- * Preference peer
+ * Preference information per peer and client.
  */
 struct PreferencePeer
 {
   /**
-   * Next in DLL
+   * Next in DLL of preference entries for the same client.
    */
   struct PreferencePeer *next;
 
   /**
-   * Previous in DLL
+   * Previous in DLL of preference entries for the same client.
    */
   struct PreferencePeer *prev;
 
   /**
-   * Client
+   * Client that expressed this preferences.
    */
   struct PreferenceClient *client;
 
   /**
-   * Peer id
+   * Peer identity for which the preference was expressed.
    */
   struct GNUNET_PeerIdentity id;
 
@@ -164,11 +163,12 @@
  */
 static struct PreferenceClient *pc_tail;
 
+/**
+ * Handle for task we run periodically to age preferences over time.
+ */
+static struct GNUNET_SCHEDULER_Task *aging_task;
 
 
-static struct GNUNET_SCHEDULER_Task * aging_task;
-
-
 /**
  * Update a peer
  *
@@ -210,12 +210,13 @@
   }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-      "%u clients have a total relative preference for peer `%s' `%s' of %.3f 
and for %s in total %.3f\n",
-      peer_count, GNUNET_i2s (id),
-      GNUNET_ATS_print_preference_type (kind),
-      f_rel_total,
-      GNUNET_ATS_print_preference_type (kind),
-      f_rel_sum);
+       "%u clients have a total relative preference for peer `%s' `%s' of %.3f 
and for %s in total %.3f\n",
+       peer_count,
+       GNUNET_i2s (id),
+       GNUNET_ATS_print_preference_type (kind),
+       f_rel_total,
+       GNUNET_ATS_print_preference_type (kind),
+       f_rel_sum);
 
   /* Find entry for the peer containing relative values in the hashmap */
   if (NULL != rp)
@@ -234,6 +235,9 @@
 }
 
 
+/**
+ * FIXME
+ */
 static int
 update_iterator (void *cls,
                  const struct GNUNET_PeerIdentity *key,
@@ -249,7 +253,6 @@
 }
 
 
-
 /**
  * Recalculate preference for a specific ATS property
  *
@@ -300,7 +303,10 @@
 }
 
 
-
+/**
+ * FIXME.
+ *
+ */
 static void
 run_preference_update (struct PreferenceClient *c_cur,
                        struct PreferencePeer *p_cur,
@@ -322,8 +328,6 @@
 }
 
 
-
-
 /**
  * Reduce absolute preferences since they got old
  *
@@ -331,12 +335,13 @@
  * @param tc context
  */
 static void
-preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+preference_aging (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct PreferencePeer *p;
   struct PreferenceClient *cur_client;
-  int i;
-  int values_to_update;
+  unsigned int i;
+  unsigned int values_to_update;
   double backup;
 
   aging_task = NULL;
@@ -382,16 +387,18 @@
 
   if (values_to_update > 0)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-        "Rescheduling aging task due to %u elements to age\n",
-        values_to_update);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Rescheduling aging task due to %u elements to age\n",
+                values_to_update);
     aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
-        &preference_aging, NULL );
+                                               &preference_aging,
+                                               NULL);
   }
   else
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-        "No values to age left, not rescheduling aging task\n");
-
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "No values to age left, not rescheduling aging task\n");
+  }
 }
 
 
@@ -720,11 +727,11 @@
 GAS_normalization_get_preferences_by_peer (void *cls,
                                           const struct GNUNET_PeerIdentity *id)
 {
-  GNUNET_assert(NULL != preference_peers);
-  GNUNET_assert(NULL != id);
+  struct PeerRelative *rp;
 
-  struct PeerRelative *rp;
-  if (NULL == (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, id)))
+  if (NULL ==
+      (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers,
+                                               id)))
   {
     return defvalues.f_rel;
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]