From: Mathieu Desnoyers Date: Mon, 19 Nov 2018 21:12:17 +0000 (-0500) Subject: Cleanup: ust start/stop trace X-Git-Tag: v2.11.0-rc2~98 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1053a2738df351b0901f87b9ae76ef2fd94ba611;p=lttng-tools.git Cleanup: ust start/stop trace Move setting/clearing the session "active" state from cmd.c to cmd_start_trace()/cmd_stop_trace() for better encapsulation of behavior. Reduces the amount of code to maintain in the catch-all cmd.c. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 507274f35..d3c8376be 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2684,12 +2684,6 @@ int cmd_start_trace(struct ltt_session *session) /* Flag session that trace should start automatically */ if (usess) { - /* - * 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) { ret = LTTNG_ERR_UST_START_FAIL; @@ -2781,12 +2775,6 @@ int cmd_stop_trace(struct ltt_session *session) } 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) { ret = LTTNG_ERR_UST_STOP_FAIL; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 8c5f3f6af..f88df7406 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -4996,6 +4996,12 @@ int ust_app_start_trace_all(struct ltt_ust_session *usess) DBG("Starting all UST traces"); + /* + * Even though the start trace might fail, flag this session active so + * other application coming in are started by default. + */ + usess->active = 1; + rcu_read_lock(); /* @@ -5031,6 +5037,12 @@ int ust_app_stop_trace_all(struct ltt_ust_session *usess) DBG("Stopping all UST traces"); + /* + * Even though the stop trace might fail, flag this session inactive so + * other application coming in are not started by default. + */ + usess->active = 0; + rcu_read_lock(); cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {