stuff
[oweals/gnunet.git] / src / transport / gnunet-service-transport_ats.c
index acbc3878c97fa9876fe92a461500aac6a8a43ee0..df425bfb020c58f509bf9cd269b932523e14fddd 100644 (file)
@@ -457,12 +457,15 @@ static void _dummy ()
   _dummy2();
 }
 
+
+
 static void _dummy2 ()
 {
   ats_modify_problem_state (NULL, 0);
-   _dummy();
-   int t = ATS_COST_UPDATED + ATS_MODIFIED + ATS_NEW;
-   t = 0;
+  qm[1].atis_index = 0;
+  _dummy();
+  int t = ATS_COST_UPDATED + ATS_MODIFIED + ATS_NEW;
+  t++;
 }
 
 /*
@@ -1303,8 +1306,7 @@ void ats_update_problem_qm (struct ATS_Handle * ats)
 
 
 void
-ats_calculate_bandwidth_distribution (struct ATS_Handle * ats,
-    struct GNUNET_STATISTICS_Handle *stats)
+ats_calculate_bandwidth_distribution (struct ATS_Handle * ats)
 {
     struct GNUNET_TIME_Absolute start;
     struct GNUNET_TIME_Relative creation;
@@ -1401,50 +1403,50 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle * ats,
           (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES",
           (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID");
       ats->successful_executions ++;
-      GNUNET_STATISTICS_set (stats, "# ATS successful executions",
+      GNUNET_STATISTICS_set (ats->stats, "# ATS successful executions",
           ats->successful_executions,
           GNUNET_NO);
 
       if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob==NULL))
-          GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO);
+          GNUNET_STATISTICS_set (ats->stats, "ATS state",ATS_NEW, GNUNET_NO);
       else if ((ats->internal.modified_resources == GNUNET_YES) &&
               (ats->internal.modified_quality == GNUNET_NO))
-        GNUNET_STATISTICS_set (stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO);
+        GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO);
       else if ((ats->internal.modified_resources == GNUNET_NO) &&
               (ats->internal.modified_quality == GNUNET_YES) &&
               (ats->internal.simplex_rerun_required == GNUNET_NO))
-        GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO);
+        GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO);
       else if ((ats->internal.modified_resources == GNUNET_YES) &&
               (ats->internal.modified_quality == GNUNET_YES) &&
               (ats->internal.simplex_rerun_required == GNUNET_NO))
-        GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO);
+        GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO);
       else if (ats->internal.simplex_rerun_required == GNUNET_NO)
-        GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
+        GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
     }
     else
     {
       if (ats->internal.c_peers != 0)
       {
         ats->invalid_executions ++;
-        GNUNET_STATISTICS_set (stats, "# ATS invalid executions",
+        GNUNET_STATISTICS_set (ats->stats, "# ATS invalid executions",
             ats->invalid_executions, GNUNET_NO);
       }
       else
       {
-        GNUNET_STATISTICS_set (stats, "# ATS successful executions",
+        GNUNET_STATISTICS_set (ats->stats, "# ATS successful executions",
             ats->successful_executions, GNUNET_NO);
       }
     }
 
-    GNUNET_STATISTICS_set (stats,
+    GNUNET_STATISTICS_set (ats->stats,
         "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
-    GNUNET_STATISTICS_set (stats,
+    GNUNET_STATISTICS_set (ats->stats,
         "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO);
-    GNUNET_STATISTICS_set (stats,
+    GNUNET_STATISTICS_set (ats->stats,
         "ATS peers", ats->internal.c_peers, GNUNET_NO);
-    GNUNET_STATISTICS_set (stats,
+    GNUNET_STATISTICS_set (ats->stats,
         "ATS solution", ats->internal.solution, GNUNET_NO);
-    GNUNET_STATISTICS_set (stats,
+    GNUNET_STATISTICS_set (ats->stats,
         "ATS timestamp", start.abs_value, GNUNET_NO);
 
     if ((ats->save_mlp == GNUNET_YES) &&
@@ -1666,15 +1668,42 @@ void ats_update_problem_cr (struct ATS_Handle * ats)
 }
 
 void ats_set_logging_options (struct ATS_Handle * ats,
-                              int minimum_addresses,
-                              int minimum_peers,
-                              int overwrite_dump,
-                              int log_solution,
-                              int log_problem)
+                              struct GNUNET_STATISTICS_Handle * stats,
+                             const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  int minimum_addresses;
+  int minimum_peers;
+  int overwrite_dump;
+  int log_solution;
+  int log_problem;
+  unsigned long long  value;
+
   if (ats == NULL)
     return;
-
+  log_problem = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                     "transport",
+                                                     "DUMP_MLP");
+  log_solution = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                      "transport",
+                                                      "DUMP_SOLUTION");
+  overwrite_dump = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                        "transport",
+                                                        "DUMP_OVERWRITE");
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number(cfg,
+                                           "transport",
+                                           "DUMP_MIN_PEERS", 
+                                           &value))
+    minimum_peers = (int) value;
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number(cfg,
+                                           "transport",
+                                           "DUMP_MIN_ADDRS", 
+                                           &value))
+    minimum_addresses = (int) value;
+
+
+  ats->stats = stats;
   ats->dump_min_addr = minimum_addresses;
   ats->dump_min_peers = minimum_peers;
   ats->dump_overwrite = overwrite_dump;