From 2a6c19e8b67a36fa07cde86adde1cf9eeed77dd8 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 18 Apr 2012 10:27:15 +0000 Subject: [PATCH] - fixes --- src/ats/gnunet-service-ats_addresses_mlp.c | 33 +++++++++++++----- src/ats/perf_ats_mlp.c | 39 ++++++++++++++++------ 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index f16832ecf..dfb62e665 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -883,9 +883,6 @@ lp_solv: GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)", mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO); - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "ats-mlp", - "%llu %llu \n", duration.rel_value, mlp->lp_total_duration / mlp->lp_solved); /* Analyze problem status */ res = glp_get_status (mlp->prob); switch (res) { @@ -1121,12 +1118,30 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, char * quota_in_str; /* Init GLPK environment */ - int res = 0; - if (0 != (res = glp_init_env())) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK %u\n", res); - GNUNET_free(mlp); - return NULL; + int res = glp_init_env(); + switch (res) { + case 0: + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", + "initialization successful"); + break; + case 1: + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", + "environment is already initialized"); + break; + case 2: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", + "initialization failed (insufficient memory)"); + GNUNET_free(mlp); + return NULL; + break; + case 3: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", + "initialization failed (unsupported programming model)"); + GNUNET_free(mlp); + return NULL; + break; + default: + break; } /* Create initial MLP problem */ diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index 24590e68a..623f187ea 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -40,6 +40,7 @@ static unsigned int peers; static unsigned int addresses; +static unsigned int numeric; struct PeerContext *p; struct ATS_Address *a; @@ -84,6 +85,15 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { unsigned int ca; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); + + if (NULL != mlp) + { + GAS_mlp_done (mlp); + mlp = NULL; + } + if (NULL != a) { for (ca=0; ca < (peers * addresses); ca++) @@ -92,8 +102,6 @@ do_shutdown (void *cls, GNUNET_free (a[ca].ats); } } - if (NULL != mlp) - GAS_mlp_done (mlp); if (NULL != amap) GNUNET_CONTAINER_multihashmap_destroy(amap); @@ -117,22 +125,28 @@ int stat_lp_it (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) { - GNUNET_break (0); - static int calls; static long long unsigned lp_time; static long long unsigned mlp_time; + static long long unsigned lp_time_set; + static long long unsigned mlp_time_set; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received: `%s' : %u \n", name, value); if (0 == strcmp (name, "# LP execution time (ms)")) + { lp_time = value; + lp_time_set = GNUNET_YES; + } if (0 == strcmp (name, "# MLP execution time (ms)")) + { mlp_time = value; + mlp_time_set = GNUNET_YES; + } - GNUNET_break (0); - calls ++; - - if (2 == calls) + if ((GNUNET_YES == lp_time_set) && (GNUNET_YES == mlp_time_set)) { - printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time); + if (GNUNET_YES == numeric) + printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time); if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) GNUNET_SCHEDULER_cancel(shutdown_task); shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); @@ -149,7 +163,7 @@ int stat_ready_it (void *cls, const char *subsystem, unsigned int ca = 0; struct GNUNET_CONFIGURATION_Handle *cfg = cls; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Statistics service ready\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Statistics service ready\n"); GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL); GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL); @@ -215,7 +229,7 @@ int stat_ready_it (void *cls, const char *subsystem, /* Solving the problem */ if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully \n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n"); else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); @@ -267,6 +281,9 @@ main (int argc, char *argv[]) {'p', "peers", NULL, gettext_noop ("peers"), 1, &GNUNET_GETOPT_set_uint, &peers}, + {'n', "numeric", NULL, + gettext_noop ("numeric output only"), 0, + &GNUNET_GETOPT_set_one, &numeric}, GNUNET_GETOPT_OPTION_END }; -- 2.25.1