From f848c3eb8a294665ea333a0d5244bd5adba8277c Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 15 Feb 2012 11:29:16 -0500 Subject: [PATCH] Fix ust app session started state on start trace The started flag must be set as soon as possible in the start trace function since if the start fails, it is still consider started for the code logic. Added one test to validate the restart tracing in UST. Signed-off-by: David Goulet --- src/bin/lttng-sessiond/ust-app.c | 4 +++- tests/lttng/ust_global_event_basic.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 335c20ff1..030358241 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1935,6 +1935,9 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) goto skip_setup; } + /* Indicate that the session has been started once */ + ua_sess->started = 1; + ret = create_ust_app_metadata(ua_sess, usess->pathname, app); if (ret < 0) { goto error_rcu_unlock; @@ -1991,7 +1994,6 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) if (ret < 0) { goto error_rcu_unlock; } - ua_sess->started = 1; skip_setup: /* This start the UST tracing */ diff --git a/tests/lttng/ust_global_event_basic.c b/tests/lttng/ust_global_event_basic.c index c56c39bd2..867e4391b 100644 --- a/tests/lttng/ust_global_event_basic.c +++ b/tests/lttng/ust_global_event_basic.c @@ -159,6 +159,22 @@ int main(int argc, char **argv) } PRINT_OK(); + printf("Restart tracing: "); + if ((ret = lttng_start_tracing(session_name)) < 0) { + printf("error starting tracing: %s\n", lttng_strerror(ret)); + goto start_fail; + } + PRINT_OK(); + + sleep(2); + + printf("Stop tracing: "); + if ((ret = lttng_stop_tracing(session_name)) < 0) { + printf("error stopping tracing: %s\n", lttng_strerror(ret)); + goto stop_fail; + } + PRINT_OK(); + printf("Destroy tracing session: "); if ((ret = lttng_destroy_session(session_name)) < 0) { printf("error destroying session: %s\n", lttng_strerror(ret)); -- 2.34.1