aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-30 09:32:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-30 09:32:01 +0000
commit247ecc51c01c54313844cb495c1fa829806bc170 (patch)
tree72d9f516765361cfae33825e2a2e7057d59b5c0a /src
parent4ed987ed9bd12e201d9146972274933b4479bb0e (diff)
fix and improved logging
Diffstat (limited to 'src')
-rw-r--r--src/ats-tests/ats-testing-experiment.c9
-rw-r--r--src/ats-tests/ats-testing-log.c18
-rw-r--r--src/ats-tests/ats-testing.h8
-rw-r--r--src/ats-tests/gnunet-ats-sim.c24
-rw-r--r--src/ats-tests/perf_ats.c2
-rw-r--r--src/ats-tests/perf_ats.h2
6 files changed, 51 insertions, 12 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index 54c7675d7d..d55adc2d74 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -259,6 +259,12 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
fprintf (stderr, "Experiment timeout!\n");
+ if (GNUNET_SCHEDULER_NO_TASK != e->episode_timeout_task)
+ {
+ e->episode_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
+ }
+
e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time),
GNUNET_SYSERR);
}
@@ -319,7 +325,8 @@ timeout_episode (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
{
struct Experiment *e = cls;
e->episode_timeout_task = GNUNET_SCHEDULER_NO_TASK;
- e->ep_done_cb (e->cur);
+ if (NULL != e->ep_done_cb)
+ e->ep_done_cb (e->cur);
/* Scheduling next */
e->cur = e->cur->next;
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index 29408d1f84..a5c1d0bc00 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -668,10 +668,7 @@ collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
void
GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
{
- int c_m;
struct GNUNET_SCHEDULER_TaskContext tc;
- struct PeerLoggingTimestep *cur;
-
if (GNUNET_YES!= l->running)
return;
@@ -680,10 +677,25 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
l->log_task = GNUNET_SCHEDULER_NO_TASK;
tc.reason = GNUNET_SCHEDULER_REASON_SHUTDOWN;
collect_log_task (l, &tc);
+ l->running = GNUNET_NO;
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
_("Stop logging\n"));
+}
+
+/**
+ * Clean up logging data
+ *
+ * @param l the logging handle
+ */
+void
+GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
+{
+ int c_m;
+ struct PeerLoggingTimestep *cur;
+ if (GNUNET_YES == l->running)
+ GNUNET_ATS_TEST_logging_stop (l);
for (c_m = 0; c_m < l->num_peers; c_m++)
{
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index 91c15d6d1f..c27033ee75 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -567,6 +567,14 @@ GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
* @param l the logging handle
*/
void
+GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l);
+
+/**
+ * Stop logging
+ *
+ * @param l the logging handle
+ */
+void
GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
/**
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index c7febecc9b..6a9797179a 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -37,6 +37,16 @@
static struct BenchmarkPeer *masters_p;
static struct BenchmarkPeer *slaves_p;
+/**
+ * cmd option -e: experiment file
+ */
+static char *opt_exp_file;
+
+/**
+ * cmd option -l: enable logging
+ */
+static int opt_log;
+
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
struct Experiment *e;
@@ -151,11 +161,14 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i
/* Stop logging */
GNUNET_ATS_TEST_logging_stop (l);
evaluate (duration);
+ if (opt_log)
+ GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file);
/* Stop traffic generation */
GNUNET_ATS_TEST_generate_traffic_stop_all();
/* Clean up experiment */
GNUNET_ATS_TEST_experimentation_stop (e);
+ GNUNET_ATS_TEST_logging_clean_up (l);
e = NULL;
/* Shutdown topology */
@@ -179,8 +192,10 @@ static void topology_setup_done (void *cls,
masters_p = masters;
slaves_p = slaves;
- l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_UNIT_SECONDS, e->name,
- masters_p, e->num_masters);
+ l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_UNIT_SECONDS,
+ e->name,
+ masters_p,
+ e->num_masters);
GNUNET_ATS_TEST_experimentation_run (e, &episode_done_cb, &experiment_done_cb);
for (c_m = 0; c_m < e->num_masters; c_m++)
@@ -199,9 +214,6 @@ static void topology_setup_done (void *cls,
e->max_duration), &do_shutdown, NULL);
}
-static char *opt_exp_file;
-static int opt_log;
-
static void
parse_args (int argc, char *argv[])
{
@@ -236,7 +248,6 @@ main (int argc, char *argv[])
fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file );
e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file);
- GNUNET_free (opt_exp_file);
if (NULL == e)
{
fprintf (stderr, "Invalid experiment\n");
@@ -257,6 +268,7 @@ main (int argc, char *argv[])
NULL,
&transport_recv_cb,
&log_request__cb);
+ GNUNET_free (opt_exp_file);
return 0;
}
/* end of file gnunet-ats-sim.c */
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 7e835495c8..33954f7eba 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -192,7 +192,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (GNUNET_YES == logging)
- GNUNET_ATS_TEST_logging_stop(l);
+ GNUNET_ATS_TEST_logging_clean_up(l);
shutdown_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_SCHEDULER_NO_TASK != progress_task)
diff --git a/src/ats-tests/perf_ats.h b/src/ats-tests/perf_ats.h
index a1cd431735..8fd1f70f40 100644
--- a/src/ats-tests/perf_ats.h
+++ b/src/ats-tests/perf_ats.h
@@ -251,7 +251,7 @@ void
GNUNET_ATS_TEST_logging_now (void);
void
-GNUNET_ATS_TEST_logging_stop ();
+GNUNET_ATS_TEST_logging_clean_up ();
void
GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,