updated configuration files
[oweals/gnunet.git] / src / ats / ats_api_performance.c
index b7c24aa53304b696e8f8e1816eb7fb8a17a47ea3..acbc18e582b499983d30a5cdb97ee834b3723ccc 100644 (file)
@@ -273,6 +273,16 @@ static void
 do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
 
 
+/**
+ * Type of a function to call when we receive a message
+ * from the service.
+ *
+ * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
+ * @param msg message received, NULL on timeout or fatal error
+ */
+static void
+process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg);
+
 /**
  * We can now transmit a message to ATS. Do it.
  *
@@ -298,6 +308,10 @@ transmit_message_to_ats (void *cls, size_t size, void *buf)
     ret += p->size;
     size -= p->size;
     GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
+    if (GNUNET_YES == p->is_init)
+      GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
+                            GNUNET_TIME_UNIT_FOREVER_REL);
+
     GNUNET_free (p);
   }
   do_transmit (ph);
@@ -609,8 +623,6 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
   GNUNET_assert (NULL == ph->client);
   ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
   GNUNET_assert (NULL != ph->client);
-  GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
-                         GNUNET_TIME_UNIT_FOREVER_REL);
   if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
   {
     p = GNUNET_malloc (sizeof (struct PendingMessage) +
@@ -943,12 +955,14 @@ GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *p
  * preference is satisfied by ATS
  *
  * @param ph performance handle
+ * @param scope the time interval this valid for: [now - scope .. now]
  * @param peer identifies the peer
  * @param ... 0-terminated specification of the desired changes
  */
 void
 GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
-                                                                                                                                                       const struct GNUNET_PeerIdentity *peer, ...)
+                                                                                                                                                       const struct GNUNET_PeerIdentity *peer,
+                                                                                                                                                       const struct GNUNET_TIME_Relative scope, ...)
 {
   struct PendingMessage *p;
   struct FeedbackPreferenceMessage *m;
@@ -959,7 +973,7 @@ GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
   enum GNUNET_ATS_PreferenceKind kind;
 
   count = 0;
-  va_start (ap, peer);
+  va_start (ap, scope);
   while (GNUNET_ATS_PREFERENCE_END !=
          (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
   {
@@ -989,11 +1003,12 @@ GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
   m = (struct FeedbackPreferenceMessage *) &p[1];
   m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
   m->header.size = htons (msize);
-  m->num_preferences = htonl (count);
+  m->scope = GNUNET_TIME_relative_hton (scope);
+  m->num_feedback = htonl (count);
   m->peer = *peer;
   pi = (struct PreferenceInformation *) &m[1];
   count = 0;
-  va_start (ap, peer);
+  va_start (ap, scope);
   while (GNUNET_ATS_PREFERENCE_END !=
          (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
   {