gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r35104 - gnunet/src/ats
Date: Thu, 5 Feb 2015 17:26:23 +0100

Author: grothoff
Date: 2015-02-05 17:26:23 +0100 (Thu, 05 Feb 2015)
New Revision: 35104

Added:
   gnunet/src/ats/gnunet-service-ats_feedback.c
   gnunet/src/ats/gnunet-service-ats_feedback.h
Modified:
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_plugins.h
   gnunet/src/ats/gnunet-service-ats_preferences.c
   gnunet/src/ats/gnunet-service-ats_preferences.h
Log:
separating out feedback from preferences

Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2015-02-05 16:09:26 UTC (rev 35103)
+++ gnunet/src/ats/Makefile.am  2015-02-05 16:26:23 UTC (rev 35104)
@@ -45,6 +45,7 @@
  gnunet-ats-solver-eval.c gnunet-ats-solver-eval.h \
  gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
  gnunet-service-ats_plugins.c gnunet-service-ats_plugins.h \
+ gnunet-service-ats_feedback.c gnunet-service-ats_feedback.h \
  gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
  gnunet-service-ats_preferences.c gnunet-service-ats_preferences.h \
  gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h \
@@ -107,10 +108,11 @@
 gnunet_service_ats_SOURCES = \
  gnunet-service-ats.c gnunet-service-ats.h\
  gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
- gnunet-service-ats_plugins.c gnunet-service-ats_plugins.h \
  gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \
+ gnunet-service-ats_feedback.c gnunet-service-ats_feedback.h \
  gnunet-service-ats_normalization.c gnunet-service-ats_normalization.h \
  gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
+ gnunet-service-ats_plugins.c gnunet-service-ats_plugins.h \
  gnunet-service-ats_preferences.c gnunet-service-ats_preferences.h \
  gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \
  gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2015-02-05 16:09:26 UTC (rev 35103)
+++ gnunet/src/ats/gnunet-service-ats.c 2015-02-05 16:26:23 UTC (rev 35104)
@@ -111,7 +111,7 @@
   GAS_scheduling_remove_client (client);
   GAS_connectivity_remove_client (client);
   GAS_normalization_preference_client_disconnect (client);
-  GAS_addresses_preference_client_disconnect (client);
+  GAS_preference_client_disconnect (client);
 }
 
 
@@ -189,6 +189,7 @@
   GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
   GAS_reservations_init (server);
   GAS_connectivity_init ();
+  GAS_preference_init ();
   GAS_normalization_start ();
   GAS_addresses_init (server);
   if (GNUNET_OK !=
@@ -199,6 +200,7 @@
     GAS_normalization_stop ();
     GAS_reservations_done ();
     GAS_connectivity_done ();
+    GAS_preference_done ();
     if (NULL != GSA_stats)
     {
       GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO);

Added: gnunet/src/ats/gnunet-service-ats_feedback.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_feedback.c                                
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_feedback.c        2015-02-05 16:26:23 UTC 
(rev 35104)
@@ -0,0 +1,124 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011-2015 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file ats/gnunet-service-ats_feedback.c
+ * @brief ats service, handling of feedback
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet-service-ats.h"
+#include "gnunet-service-ats_plugins.h"
+#include "gnunet-service-ats_feedback.h"
+#include "ats.h"
+
+
+/**
+ * Change the preference for a peer
+ *
+ * @param application the client sending this request
+ * @param peer the peer id
+ * @param scope the time interval for this feedback: [now - scope .. now]
+ * @param kind the preference kind to change
+ * @param score_abs the new preference score
+ */
+static void
+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)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received PREFERENCE FEEDBACK for peer `%s'\n",
+              GNUNET_i2s (peer));
+  GAS_plugin_preference_feedback (application,
+                                 peer,
+                                 scope,
+                                 kind,
+                                 score_abs);
+}
+
+
+/**
+ * Handle 'preference feedback' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_preference_feedback (void *cls,
+                               struct GNUNET_SERVER_Client *client,
+                               const struct GNUNET_MessageHeader *message)
+{
+  const struct FeedbackPreferenceMessage *msg;
+  const struct PreferenceInformation *pi;
+  uint16_t msize;
+  uint32_t nump;
+  uint32_t i;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received PREFERENCE_FEEDBACK message\n");
+  msize = ntohs (message->size);
+  if (msize < sizeof (struct FeedbackPreferenceMessage))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client,
+                                GNUNET_SYSERR);
+    return;
+  }
+  msg = (const struct FeedbackPreferenceMessage *) message;
+  nump = ntohl (msg->num_feedback);
+  if (msize !=
+      sizeof (struct FeedbackPreferenceMessage) +
+      nump * sizeof (struct PreferenceInformation))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client,
+                                GNUNET_SYSERR);
+    return;
+  }
+  if (GNUNET_NO ==
+      GNUNET_CONTAINER_multipeermap_contains (GSA_addresses,
+                                             &msg->peer))
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+              "Received PREFERENCE FEEDBACK for unknown peer `%s'\n",
+              GNUNET_i2s (&msg->peer));
+    return;
+  }
+
+  GNUNET_STATISTICS_update (GSA_stats,
+                            "# preference feedbacks requests processed",
+                            1,
+                            GNUNET_NO);
+  pi = (const struct PreferenceInformation *) &msg[1];
+  for (i = 0; i < nump; i++)
+    preference_feedback (client,
+                         &msg->peer,
+                         GNUNET_TIME_relative_ntoh(msg->scope),
+                         (enum GNUNET_ATS_PreferenceKind) ntohl 
(pi[i].preference_kind),
+                         pi[i].preference_value);
+  GNUNET_SERVER_receive_done (client,
+                              GNUNET_OK);
+}
+
+/* end of gnunet-service-ats_feedback.c */

Added: gnunet/src/ats/gnunet-service-ats_feedback.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_feedback.h                                
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_feedback.h        2015-02-05 16:26:23 UTC 
(rev 35104)
@@ -0,0 +1,41 @@
+/*
+ This file is part of GNUnet.
+ (C) 2011-2014 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+/**
+ * @file ats/gnunet-service-ats_feedback.h
+ * @brief handle client feedback
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_SERVICE_ATS_FEEDBACK_H
+#define GNUNET_SERVICE_ATS_FEEDBACK_H
+
+/**
+ * Handle 'preference feedback' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_preference_feedback (void *cls,
+                                struct GNUNET_SERVER_Client *client,
+                                const struct GNUNET_MessageHeader *message);
+
+#endif

Modified: gnunet/src/ats/gnunet-service-ats_plugins.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-05 16:09:26 UTC (rev 
35103)
+++ gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-05 16:26:23 UTC (rev 
35104)
@@ -30,6 +30,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_ats_service.h"
 #include "gnunet-service-ats.h"
+#include "gnunet-service-ats_addresses.h"
 #include "gnunet_statistics_service.h"
 #include "ats.h"
 

Modified: gnunet/src/ats/gnunet-service-ats_preferences.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_preferences.c     2015-02-05 16:09:26 UTC 
(rev 35103)
+++ gnunet/src/ats/gnunet-service-ats_preferences.c     2015-02-05 16:26:23 UTC 
(rev 35104)
@@ -17,9 +17,8 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
- * @file ats/gnunet-service-ats_performance.c
+ * @file ats/gnunet-service-ats_preferences.c
  * @brief ats service, interaction with 'performance' API
  * @author Matthias Wachs
  * @author Christian Grothoff
@@ -114,7 +113,6 @@
   /**
    * Next in DLL
    */
-
   struct PreferenceClient *next;
 
   /**
@@ -133,10 +131,6 @@
   double f_rel_sum[GNUNET_ATS_PreferenceCount];
 
   /**
-   * List of peer preferences for this client
-   */
-
-  /**
    * Head of peer list
    */
   struct PreferencePeer *p_head;
@@ -147,6 +141,7 @@
   struct PreferencePeer *p_tail;
 };
 
+
 /**
  * Preference peer
  */
@@ -194,7 +189,6 @@
  */
 static struct GNUNET_CONTAINER_MultiPeerMap *preference_peers;
 
-
 /**
  * Clients in DLL: head
  */
@@ -234,7 +228,7 @@
  */
 static void
 update_relative_values_for_peer (const struct GNUNET_PeerIdentity *id,
-                                enum GNUNET_ATS_PreferenceKind kind, 
+                                enum GNUNET_ATS_PreferenceKind kind,
                                 struct PeerRelative *rp)
 {
   struct PreferenceClient *c_cur;
@@ -283,7 +277,7 @@
       /* No client had any preferences for this type and any peer */
       rp->f_rel[kind] = DEFAULT_REL_PREFERENCE;
     }
-    if (backup != rp->f_rel[kind]) 
+    if (backup != rp->f_rel[kind])
       GAS_normalized_preference_changed (&rp->id, kind, rp->f_rel[kind]);
   }
 }
@@ -493,7 +487,7 @@
  * @param client the client
  */
 void
-GAS_addresses_preference_client_disconnect (void *client)
+GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client)
 {
   struct GAS_Addresses_Preference_Clients *pc;
 
@@ -513,7 +507,6 @@
 }
 
 
-
 /**
  * Change the preference for a peer
  *
@@ -522,11 +515,11 @@
  * @param kind the preference kind to change
  * @param score_abs the new preference score
  */
-void
-GAS_addresses_preference_change (void *client,
-                                 const struct GNUNET_PeerIdentity *peer,
-                                 enum GNUNET_ATS_PreferenceKind kind,
-                                 float score_abs)
+static void
+preference_change (void *client,
+                    const struct GNUNET_PeerIdentity *peer,
+                    enum GNUNET_ATS_PreferenceKind kind,
+                    float score_abs)
 {
   struct GAS_Addresses_Preference_Clients *pc;
 
@@ -604,116 +597,19 @@
                             1, GNUNET_NO);
   pi = (const struct PreferenceInformation *) &msg[1];
   for (i = 0; i < nump; i++)
-    GAS_addresses_preference_change (client,
-                                     &msg->peer,
-                                     (enum GNUNET_ATS_PreferenceKind)
-                                     ntohl (pi[i].preference_kind),
-                                     pi[i].preference_value);
+    preference_change (client,
+                       &msg->peer,
+                       (enum GNUNET_ATS_PreferenceKind)
+                       ntohl (pi[i].preference_kind),
+                       pi[i].preference_value);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 
-
-
 /**
- * Change the preference for a peer
- *
- * @param application the client sending this request
- * @param peer the peer id
- * @param scope the time interval for this feedback: [now - scope .. now]
- * @param kind the preference kind to change
- * @param score_abs the new preference score
+ * Initialize preferences subsystem.
  */
 void
-GAS_addresses_preference_feedback (void *application,
-                                   const struct GNUNET_PeerIdentity *peer,
-                                   const struct GNUNET_TIME_Relative scope,
-                                   enum GNUNET_ATS_PreferenceKind kind,
-                                   float score_abs)
-{
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             "Received `%s' for peer `%s' for client %p\n",
-             "PREFERENCE FEEDBACK",
-             GNUNET_i2s (peer),
-             application);
-
-  if (GNUNET_NO ==
-      GNUNET_CONTAINER_multipeermap_contains (GSA_addresses,
-                                             peer))
-  {
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' for unknown peer `%s' from client %p\n",
-              "PREFERENCE FEEDBACK",
-              GNUNET_i2s (peer), 
-              application);
-    return;
-  }
-
-  GAS_plugin_preference_feedback (application,
-                                 peer,
-                                 scope,
-                                 kind,
-                                 score_abs);
-}
-
-
-/**
- * Handle 'preference feedback' messages from clients.
- *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
- */
-void
-GAS_handle_preference_feedback (void *cls,
-                               struct GNUNET_SERVER_Client *client,
-                               const struct GNUNET_MessageHeader *message)
-{
-  const struct FeedbackPreferenceMessage *msg;
-  const struct PreferenceInformation *pi;
-  uint16_t msize;
-  uint32_t nump;
-  uint32_t i;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' message\n",
-              "PREFERENCE_FEEDBACK");
-  msize = ntohs (message->size);
-  if (msize < sizeof (struct FeedbackPreferenceMessage))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  msg = (const struct FeedbackPreferenceMessage *) message;
-  nump = ntohl (msg->num_feedback);
-  if (msize !=
-      sizeof (struct FeedbackPreferenceMessage) +
-      nump * sizeof (struct PreferenceInformation))
-  {
-    GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-    return;
-  }
-  GNUNET_STATISTICS_update (GSA_stats,
-                            "# preference feedbacks requests processed",
-                            1, GNUNET_NO);
-  pi = (const struct PreferenceInformation *) &msg[1];
-  for (i = 0; i < nump; i++)
-    GAS_addresses_preference_feedback (client,
-                                       &msg->peer,
-                                       GNUNET_TIME_relative_ntoh(msg->scope),
-                                       (enum GNUNET_ATS_PreferenceKind)
-                                       ntohl (pi[i].preference_kind),
-                                       pi[i].preference_value);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
- * Shutdown preferences subsystem.
- */
-void
 GAS_preference_init ()
 {
   int i;
@@ -721,7 +617,6 @@
   preference_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
   for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
     defvalues.f_rel[i] = DEFAULT_REL_PREFERENCE;
-
 }
 
 
@@ -734,14 +629,19 @@
  * @return #GNUNET_OK to continue
  */
 static int
-free_peer (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+free_peer (void *cls,
+           const struct GNUNET_PeerIdentity *key,
+           void *value)
 {
   struct PeerRelative *rp = value;
-  if (GNUNET_YES
-      == GNUNET_CONTAINER_multipeermap_remove (preference_peers, key, value))
-    GNUNET_free(rp);
+
+  if (GNUNET_YES ==
+      GNUNET_CONTAINER_multipeermap_remove (preference_peers,
+                                            key,
+                                            value))
+    GNUNET_free (rp);
   else
-    GNUNET_break(0);
+    GNUNET_break (0);
   return GNUNET_OK;
 }
 
@@ -751,6 +651,7 @@
 {
   struct PreferencePeer *next_p;
   struct PreferencePeer *p;
+
   next_p = pc->p_head;
   while (NULL != (p = next_p))
   {
@@ -762,9 +663,6 @@
 }
 
 
-
-
-
 /**
  * Shutdown preferences subsystem.
  */
@@ -780,7 +678,6 @@
     GNUNET_SCHEDULER_cancel (aging_task);
     aging_task = NULL;
   }
-
   next_pc = pc_head;
   while (NULL != (pc = next_pc))
   {
@@ -788,9 +685,9 @@
     GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc);
     free_client (pc);
   }
-
-  GNUNET_CONTAINER_multipeermap_iterate (preference_peers, 
-                                        &free_peer, NULL);
+  GNUNET_CONTAINER_multipeermap_iterate (preference_peers,
+                                        &free_peer,
+                                         NULL);
   GNUNET_CONTAINER_multipeermap_destroy (preference_peers);
 
   while (NULL != (pcur = preference_clients_head))
@@ -809,8 +706,6 @@
 }
 
 
-
-
 /**
  * Normalize an updated preference value
  *
@@ -911,7 +806,8 @@
   /* Start aging task */
   if (NULL == aging_task)
     aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
-        &preference_aging, NULL );
+                                               &preference_aging,
+                                               NULL);
 
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_preferences.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_preferences.h     2015-02-05 16:09:26 UTC 
(rev 35103)
+++ gnunet/src/ats/gnunet-service-ats_preferences.h     2015-02-05 16:26:23 UTC 
(rev 35104)
@@ -40,30 +40,15 @@
 
 
 /**
- * A preference client disconnected
+ * A preference client disconnected.
  *
- * @param client the client; FIXME: type!?
+ * @param client the client
  */
 void
-GAS_addresses_preference_client_disconnect (void *client);
+GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client);
 
 
 /**
- * Change the preference for a peer
- *
- * @param client the client sending this request; FIXME: type!?
- * @param peer the peer id
- * @param kind the preference kind to change
- * @param score_abs the new preference score
- */
-void
-GAS_addresses_preference_change (void *client,
-                                 const struct GNUNET_PeerIdentity *peer,
-                                 enum GNUNET_ATS_PreferenceKind kind,
-                                 float score_abs);
-
-
-/**
  * Handle 'preference change' messages from clients.
  *
  * @param cls unused, NULL
@@ -76,32 +61,7 @@
                               const struct GNUNET_MessageHeader *message);
 
 
-
 /**
- * Application feedback on how good preference requirements are fulfilled
- * for a specific preference in the given time scope [now - scope .. now]
- *
- * An application notifies ATS if (and only if) it has feedback information
- * for a specific property. This value is valid until the feedback score is
- * updated by the application.
- *
- * If the application has no feedback for this preference kind the application
- * will not explicitly call.
- *
- * @param application the application sending this request; FIXME: type?
- * @param peer the peer id
- * @param scope the time interval this valid for: [now - scope .. now]
- * @param kind the preference kind this feedback is intended for
- * @param score_abs the new preference score
- */
-void
-GAS_addresses_preference_feedback (void *application,
-                                   const struct GNUNET_PeerIdentity *peer,
-                                   const struct GNUNET_TIME_Relative scope,
-                                   enum GNUNET_ATS_PreferenceKind kind,
-                                   float score_abs);
-
-/**
  * Handle 'preference feedback' messages from clients.
  *
  * @param cls unused, NULL
@@ -116,6 +76,13 @@
 
 
 /**
+ * Initialize preferences subsystem.
+ */
+void
+GAS_preference_init (void);
+
+
+/**
  * Shutdown preferences subsystem.
  */
 void




reply via email to

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