gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r35167 - gnunet/src/ats
Date: Sun, 8 Feb 2015 17:43:41 +0100

Author: grothoff
Date: 2015-02-08 17:43:41 +0100 (Sun, 08 Feb 2015)
New Revision: 35167

Modified:
   gnunet/src/ats/plugin_ats_proportional.c
Log:
clean up find_quality_property_index and get_active_address_it

Modified: gnunet/src/ats/plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/plugin_ats_proportional.c    2015-02-08 16:39:33 UTC (rev 
35166)
+++ gnunet/src/ats/plugin_ats_proportional.c    2015-02-08 16:43:41 UTC (rev 
35167)
@@ -638,17 +638,22 @@
 
 
 /**
- * Find index of a ATS property type in the array.
+ * Find index of a ATS property type in the quality properties array.
+ *
+ * @param type ATS property type
+ * @return index in the quality array, #GNUNET_SYSERR if the type
+ *         was not a quality property
  */
 static int
-find_property_index (uint32_t type)
+find_quality_property_index (enum GNUNET_ATS_Property type)
 {
-  int existing_types[] = GNUNET_ATS_QualityProperties;
-  int c;
+  enum GNUNET_ATS_Property existing_types[] = GNUNET_ATS_QualityProperties;
+  unsigned int c;
 
   for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
     if (existing_types[c] == type)
       return c;
+  GNUNET_break (0);
   return GNUNET_SYSERR;
 }
 
@@ -723,10 +728,10 @@
   }
 
   /* Now compare ATS information */
-  index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
+  index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
   cur_distance = current->atsin[index].norm;
   best_distance = ctx->best->atsin[index].norm;
-  index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
+  index = find_quality_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
   cur_delay = current->atsin[index].norm;
   best_delay = ctx->best->atsin[index].norm;
 
@@ -802,7 +807,8 @@
 
 
 /**
- * Hashmap Iterator to find current active address for peer
+ * Address map iterator to find current active address for peer.
+ * Asserts that only one address is active per peer.
  *
  * @param cls last active address
  * @param key peer's key
@@ -815,27 +821,12 @@
                        void *value)
 {
   struct ATS_Address **dest = cls;
-  struct ATS_Address *aa = (struct ATS_Address *) value;
+  struct ATS_Address *aa = value;
 
-  LOG (GNUNET_ERROR_TYPE_INFO,
-         "Checking address %p\n", aa);
-
-  if (GNUNET_YES == aa->active)
-  {
-  LOG (GNUNET_ERROR_TYPE_INFO,
-         "Address %p is active\n", aa);
-    if (NULL != (*dest))
-    {
-      /* should never happen */
-      LOG (GNUNET_ERROR_TYPE_ERROR,
-           "Multiple active addresses for peer `%s'\n",
-           GNUNET_i2s (&aa->peer));
-      GNUNET_break(0);
-      return GNUNET_NO;
-    }
-    (*dest) = aa;
-
-  }
+  if (GNUNET_YES != aa->active)
+    return GNUNET_OK;
+  GNUNET_assert (NULL == (*dest));
+  (*dest) = aa;
   return GNUNET_OK;
 }
 




reply via email to

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