From: David Goulet Date: Tue, 25 Mar 2014 17:19:57 +0000 (-0400) Subject: Rename kernel and ust trace variable for clarity X-Git-Tag: v2.5.0-rc1~91 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=14fb1ebe1000da2c3ccca45e7e97ad6637947cfe;p=lttng-tools.git Rename kernel and ust trace variable for clarity Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 161680a6c..ea25a5e47 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -823,7 +823,7 @@ static int start_kernel_session(struct ltt_kernel_session *ksess, int wpipe) /* Quiescent wait after starting trace */ kernel_wait_quiescent(kernel_tracer_fd); - ksess->started = 1; + ksess->active = 1; ret = LTTNG_OK; @@ -1819,7 +1819,11 @@ int cmd_start_trace(struct ltt_session *session) /* Flag session that trace should start automatically */ if (usess) { - usess->start_trace = 1; + /* + * Even though the start trace might fail, flag this session active so + * other application coming in are started by default. + */ + usess->active = 1; ret = ust_app_start_trace_all(usess); if (ret < 0) { @@ -1861,7 +1865,7 @@ int cmd_stop_trace(struct ltt_session *session) } /* Kernel tracer */ - if (ksession && ksession->started) { + if (ksession && ksession->active) { DBG("Stop kernel tracing"); /* Flush metadata if exist */ @@ -1888,11 +1892,15 @@ int cmd_stop_trace(struct ltt_session *session) kernel_wait_quiescent(kernel_tracer_fd); - ksession->started = 0; + ksession->active = 0; } - if (usess && usess->start_trace) { - usess->start_trace = 0; + if (usess && usess->active) { + /* + * Even though the stop trace might fail, flag this session inactive so + * other application coming in are not started by default. + */ + usess->active = 0; ret = ust_app_stop_trace_all(usess); if (ret < 0) { diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 934aaffe8..f576e3a60 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -109,8 +109,8 @@ struct ltt_kernel_session { struct consumer_output *tmp_consumer; /* Tracing session id */ uint64_t id; - /* Session is started and active */ - unsigned int started; + /* Session is active or not meaning it has been started or stopped. */ + unsigned int active:1; /* Tell or not if the session has to output the traces. */ unsigned int output_traces; unsigned int snapshot_mode; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 8d3c7dcf8..dfbbcd777 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -218,7 +218,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) /* Init data structure */ lus->id = session_id; - lus->start_trace = 0; + lus->active = 0; /* Set default metadata channel attribute. */ lus->metadata_attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 6a41f0f9f..bac5c328b 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -77,12 +77,13 @@ struct ltt_ust_domain_global { /* UST session */ struct ltt_ust_session { uint64_t id; /* Unique identifier of session */ - int start_trace; struct ltt_ust_domain_global domain_global; struct jul_domain domain_jul; /* UID/GID of the user owning the session */ uid_t uid; gid_t gid; + /* Is the session active meaning has is been started or stopped. */ + unsigned int active:1; /* * Two consumer_output object are needed where one is for the current * output object and the second one is the temporary object used to store diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 00c6d9622..7f27eae07 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -4238,7 +4238,7 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock) pthread_mutex_unlock(&ua_sess->lock); - if (usess->start_trace) { + if (usess->active) { ret = ust_app_start_trace(usess, app); if (ret < 0) { goto error; diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index bc3154c28..150d5dafb 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -82,7 +82,7 @@ static void test_create_one_ust_session(void) ok(usess != NULL, "Create UST session"); ok(usess->id == 42 && - usess->start_trace == 0 && + usess->active == 0 && usess->domain_global.channels != NULL && usess->uid == 0 && usess->gid == 0,