-fix config, shutdown issue
[oweals/gnunet.git] / src / ats / plugin_ats_proportional.c
index e45244ec03542363c0f7d41030c833579c05f729..b4cabb0676afe60074d05693ea704468fe7cb4fa 100644 (file)
@@ -687,8 +687,6 @@ find_best_address_it (void *cls,
   struct AddressSolverInformation *asi;
   struct GNUNET_TIME_Relative active_time;
   struct GNUNET_TIME_Relative min_active_time;
-  const double *norm_prop_cur;
-  const double *norm_prop_best;
   double best_delay;
   double best_distance;
   double cur_delay;
@@ -738,19 +736,12 @@ find_best_address_it (void *cls,
   }
 
   /* Now compare ATS information */
-  norm_prop_cur = ctx->s->env->get_property (ctx->s->env->cls,
-                                             current);
   index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
-  cur_distance = norm_prop_cur[index];
+  cur_distance = current->atsin[index].norm;
+  best_distance = ctx->best->atsin[index].norm;
   index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
-  cur_delay = norm_prop_cur[index];
-
-  norm_prop_best = ctx->s->env->get_property (ctx->s->env->cls,
-                                              ctx->best);
-  index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
-  best_distance = norm_prop_best[index];
-  index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
-  best_delay = norm_prop_best[index];
+  cur_delay = current->atsin[index].norm;
+  best_delay = ctx->best->atsin[index].norm;
 
   /* user shorter distance */
   if (cur_distance < best_distance)
@@ -1106,53 +1097,61 @@ distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s,
         GNUNET_ATS_print_network_type(n->type),
         n->active_addresses, n->total_addresses);
 
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_START,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_SINGLE);
 
     /* Distribute  */
     distribute_bandwidth(s, n);
 
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_STOP,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_SINGLE);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_SINGLE);
 
     /* Do propagation */
     propagate_bandwidth (s, n);
 
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_SINGLE);
   }
   else
   {
     int i;
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_START,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_ALL);
     for (i = 0; i < s->network_count; i++)
     {
       /* Distribute */
       distribute_bandwidth(s, &s->network_entries[i]);
     }
 
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_STOP,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_ALL);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_ALL);
     for (i = 0; i < s->network_count; i++)
     {
       /* Do propagation */
       propagate_bandwidth(s, &s->network_entries[i]);
     }
-    if (NULL != s->env->info_cb)
-      s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
-          GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
+    s->env->info_cb (s->env->cls,
+                     GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
+                     GAS_STAT_SUCCESS,
+                     GAS_INFO_PROP_ALL);
   }
 }
 
@@ -1614,7 +1613,7 @@ GAS_proportional_address_add (void *solver,
 static void
 GAS_proportional_address_property_changed (void *solver,
                                            struct ATS_Address *address,
-                                           uint32_t type,
+                                           enum GNUNET_ATS_Property type,
                                            uint32_t abs_value,
                                            double rel_value)
 {
@@ -1738,7 +1737,6 @@ libgnunet_plugin_ats_proportional_init (void *cls)
   GNUNET_assert (NULL != env->cfg);
   GNUNET_assert (NULL != env->bandwidth_changed_cb);
   GNUNET_assert (NULL != env->get_preferences);
-  GNUNET_assert (NULL != env->get_property);
 
   s = GNUNET_new (struct GAS_PROPORTIONAL_Handle);
   s->env = env;