gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34623 - gnunet/src/ats
Date: Mon, 15 Dec 2014 16:01:39 +0100

Author: grothoff
Date: 2014-12-15 16:01:39 +0100 (Mon, 15 Dec 2014)
New Revision: 34623

Modified:
   gnunet/src/ats/ats_api_performance.c
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/test_ats_api_performance_list_peer_addresses.c
Log:
-doxygen, indentation

Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c        2014-12-15 14:47:44 UTC (rev 
34622)
+++ gnunet/src/ats/ats_api_performance.c        2014-12-15 15:01:39 UTC (rev 
34623)
@@ -481,9 +481,9 @@
     GNUNET_break(0);
     return GNUNET_SYSERR;
   }
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
-             _("Received %s message\n"),
-             "ATS_ADDRESSLIST_RESPONSE");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              _("Received %s message\n"),
+              "ATS_ADDRESSLIST_RESPONSE");
 
   pi = (const struct PeerInformationMessage *) msg;
   id = ntohl (pi->id);
@@ -520,20 +520,27 @@
   }
 
   memset (&allzeros, '\0', sizeof(allzeros));
-  if ((0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros)))
-      && (0 == plugin_name_length) && (0 == plugin_address_length)
-      && (0 == ats_count))
+  if ( (0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros))) &&
+       (0 == plugin_name_length) &&
+       (0 == plugin_address_length) &&
+       (0 == ats_count) )
   {
     /* Done */
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Received last message for %s \n"),
-        "ATS_ADDRESSLIST_RESPONSE");
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+               _("Received last message for %s \n"),
+               "ATS_ADDRESSLIST_RESPONSE");
     bandwidth_zero.value__ = htonl (0);
+    GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
+                                 ph->addresslist_tail,
+                                 alh);
     if (NULL != alh->cb)
-      alh->cb (ph->addr_info_cb_cls, NULL, GNUNET_NO, bandwidth_zero,
-          bandwidth_zero, NULL, 0);
-    GNUNET_CONTAINER_DLL_remove(ph->addresslist_head, ph->addresslist_tail,
-        alh);
-    GNUNET_free(alh);
+      alh->cb (ph->addr_info_cb_cls,
+               NULL,
+               GNUNET_NO,
+               bandwidth_zero,
+               bandwidth_zero,
+               NULL, 0);
+    GNUNET_free (alh);
     return GNUNET_OK;
   }
 
@@ -797,10 +804,8 @@
   struct PendingMessage *p;
   struct AddressListRequestMessage *m;
 
-  GNUNET_assert(NULL != handle);
   if (NULL == infocb)
-    return NULL ;
-
+    return NULL;
   alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle);
   alh->id = handle->id;
   handle->id++;
@@ -809,19 +814,21 @@
   alh->ph = handle;
   alh->all_addresses = all;
   if (NULL == peer)
+  {
     alh->all_peers = GNUNET_YES;
+  }
   else
   {
     alh->all_peers = GNUNET_NO;
     alh->peer = (*peer);
   }
+  GNUNET_CONTAINER_DLL_insert (handle->addresslist_head,
+                               handle->addresslist_tail,
+                               alh);
 
-  GNUNET_CONTAINER_DLL_insert(handle->addresslist_head,
-      handle->addresslist_tail, alh);
-
   p = GNUNET_malloc (sizeof (struct PendingMessage) +
-      sizeof (struct AddressListRequestMessage));
-  p->size = sizeof(struct AddressListRequestMessage);
+                     sizeof (struct AddressListRequestMessage));
+  p->size = sizeof (struct AddressListRequestMessage);
   m = (struct AddressListRequestMessage *) &p[1];
   m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
   m->header.size = htons (sizeof(struct AddressListRequestMessage));
@@ -829,14 +836,9 @@
   m->id = htonl (alh->id);
   if (NULL != peer)
     m->peer = *peer;
-  else
-  {
-    memset (&m->peer, '\0', sizeof(struct GNUNET_PeerIdentity));
-  }
   GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head,
                                    handle->pending_tail,
                                    p);
-
   do_transmit (handle);
 
   return alh;
@@ -846,7 +848,7 @@
 /**
  * Cancel a pending address listing operation
  *
- * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
+ * @param handle the handle of the request to cancel
  */
 void
 GNUNET_ATS_performance_list_addresses_cancel (struct 
GNUNET_ATS_AddressListHandle *handle)
@@ -860,7 +862,7 @@
 
 
 /**
- * Convert a GNUNET_ATS_PreferenceType to a string
+ * Convert a `enum GNUNET_ATS_PreferenceType` to a string
  *
  * @param type the preference type
  * @return a string or NULL if invalid
@@ -871,7 +873,7 @@
   char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
   if (type < GNUNET_ATS_PreferenceCount)
     return prefs[type];
-  return NULL ;
+  return NULL;
 }
 
 
@@ -988,12 +990,10 @@
     case GNUNET_ATS_PREFERENCE_BANDWIDTH:
       count++;
       (void) va_arg (ap, double);
-
       break;
     case GNUNET_ATS_PREFERENCE_LATENCY:
       count++;
       (void) va_arg (ap, double);
-
       break;
     default:
       GNUNET_assert(0);
@@ -1035,7 +1035,9 @@
     }
   }
   va_end(ap);
-  GNUNET_CONTAINER_DLL_insert_tail(ph->pending_head, ph->pending_tail, p);
+  GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
+                                    ph->pending_tail,
+                                    p);
   do_transmit (ph);
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2014-12-15 14:47:44 UTC 
(rev 34622)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2014-12-15 15:01:39 UTC 
(rev 34623)
@@ -360,13 +360,26 @@
 
 
 /**
- * FIXME.
+ * Send a #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE with the
+ * given address details to the client identified in @a ai.
+ *
+ * @param ai our address information context (identifies the client)
+ * @param id the peer id this address is for
+ * @param plugin_name name of the plugin that supports this address
+ * @param plugin_addr address
+ * @param plugin_addr_len length of @a plugin_addr
+ * @param active #GNUNET_YES if this address is actively used
+ * @param atsi ats performance information
+ * @param atsi_count number of ats performance elements in @a atsi
+ * @param bandwidth_out current outbound bandwidth assigned to address
+ * @param bandwidth_in current inbound bandwidth assigned to address
  */
 static void
 transmit_req_addr (struct AddressIteration *ai,
                    const struct GNUNET_PeerIdentity *id,
                    const char *plugin_name,
-                   const void *plugin_addr, size_t plugin_addr_len,
+                   const void *plugin_addr,
+                   size_t plugin_addr_len,
                    int active,
                    const struct GNUNET_ATS_Information *atsi,
                    uint32_t atsi_count,
@@ -468,14 +481,14 @@
   /* Transmit result */
   if ((GNUNET_YES == ai->all) || (GNUNET_YES == active))
   {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Sending result for  %s peer `%s' plugin `%s' BW out %u, BW 
in %u\n",
-                  (active == GNUNET_YES) ? "ACTIVE" : "INACTIVE",
-                  GNUNET_i2s (id),
-                  plugin_name,
-                  (unsigned int) ntohl (bandwidth_out.value__),
-                  (unsigned int) ntohl (bandwidth_in.value__));
-    transmit_req_addr (cls,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending result for  %s peer `%s' plugin `%s' BW out %u, BW in 
%u\n",
+                (active == GNUNET_YES) ? "ACTIVE" : "INACTIVE",
+                GNUNET_i2s (id),
+                plugin_name,
+                (unsigned int) ntohl (bandwidth_out.value__),
+                (unsigned int) ntohl (bandwidth_in.value__));
+    transmit_req_addr (ai,
                        id,
                        plugin_name,
                        plugin_addr, plugin_addr_len,

Modified: gnunet/src/ats/test_ats_api_performance_list_peer_addresses.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_list_peer_addresses.c       
2014-12-15 14:47:44 UTC (rev 34622)
+++ gnunet/src/ats/test_ats_api_performance_list_peer_addresses.c       
2014-12-15 15:01:39 UTC (rev 34623)
@@ -105,9 +105,10 @@
             uint32_t ats_count)
 {
   static int counter = 0;
+
   if (NULL == address)
   {
-    phal = 0;
+    phal = NULL;
     if (2 == counter)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -117,6 +118,9 @@
     }
     else
     {
+      fprintf (stderr,
+               "Expected 2 addresses, got %d\n",
+               counter);
       GNUNET_break (0);
       GNUNET_SCHEDULER_shutdown ();
     }
@@ -136,9 +140,9 @@
 
 
 static int
-stat_cb(void *cls, const char *subsystem,
-        const char *name, uint64_t value,
-        int is_persistent)
+stat_cb (void *cls, const char *subsystem,
+         const char *name, uint64_t value,
+         int is_persistent)
 {
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -153,7 +157,7 @@
     if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Failed to connect to performance API\n");
+                  "Failed to connect to performance API\n");
       GNUNET_SCHEDULER_shutdown ();
       return GNUNET_SYSERR;
     }
@@ -190,7 +194,7 @@
     phal = NULL;
   }
 
-  if (perf_ats != NULL)
+  if (NULL != perf_ats)
   {
     GNUNET_ATS_performance_done (perf_ats);
     perf_ats = NULL;




reply via email to

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