From: Francis Deslauriers Date: Thu, 14 Jan 2021 22:44:49 +0000 (-0500) Subject: Cleanup: Extract `ust_app_synchronize_all_channels()` function X-Git-Tag: v2.13.0-rc1~190 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=a84d10248d99b14e8758011fbe82344b19b258b7;ds=sidebyside Cleanup: Extract `ust_app_synchronize_all_channels()` function Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: Id24eff10cc07c5e061fbb45e871087c17eac9b1d --- diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 2a5ec9e23..50d2f1932 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -5735,38 +5735,20 @@ end: } /* - * The caller must ensure that the application is compatible and is tracked - * by the process attribute trackers. + * RCU read lock must be held by the caller. */ static -void ust_app_synchronize(struct ltt_ust_session *usess, +void ust_app_synchronize_all_channels(struct ltt_ust_session *usess, + struct ust_app_session *ua_sess, struct ust_app *app) { int ret = 0; struct cds_lfht_iter uchan_iter; struct ltt_ust_channel *uchan; - struct ust_app_session *ua_sess = NULL; - /* - * The application's configuration should only be synchronized for - * active sessions. - */ - assert(usess->active); - - ret = find_or_create_ust_app_session(usess, app, &ua_sess, NULL); - if (ret < 0) { - /* Tracer is probably gone or ENOMEM. */ - goto error; - } + assert(usess); assert(ua_sess); - - pthread_mutex_lock(&ua_sess->lock); - if (ua_sess->deleted) { - pthread_mutex_unlock(&ua_sess->lock); - goto end; - } - - rcu_read_lock(); + assert(app); cds_lfht_for_each_entry(usess->domain_global.channels->ht, &uchan_iter, uchan, node.node) { @@ -5785,7 +5767,7 @@ void ust_app_synchronize(struct ltt_ust_session *usess, app, uchan, &ua_chan); if (ret) { /* Tracer is probably gone or ENOMEM. */ - goto error_unlock; + goto end; } if (!ua_chan) { @@ -5798,7 +5780,7 @@ void ust_app_synchronize(struct ltt_ust_session *usess, ret = ust_app_channel_synchronize_event(ua_chan, uevent, ua_sess, app); if (ret) { - goto error_unlock; + goto end; } } @@ -5807,10 +5789,47 @@ void ust_app_synchronize(struct ltt_ust_session *usess, enable_ust_app_channel(ua_sess, uchan, app) : disable_ust_app_channel(ua_sess, ua_chan, app); if (ret) { - goto error_unlock; + goto end; } } } +end: + return; +} + +/* + * The caller must ensure that the application is compatible and is tracked + * by the process attribute trackers. + */ +static +void ust_app_synchronize(struct ltt_ust_session *usess, + struct ust_app *app) +{ + int ret = 0; + struct ust_app_session *ua_sess = NULL; + + /* + * The application's configuration should only be synchronized for + * active sessions. + */ + assert(usess->active); + + ret = find_or_create_ust_app_session(usess, app, &ua_sess, NULL); + if (ret < 0) { + /* Tracer is probably gone or ENOMEM. */ + goto error; + } + assert(ua_sess); + + pthread_mutex_lock(&ua_sess->lock); + if (ua_sess->deleted) { + pthread_mutex_unlock(&ua_sess->lock); + goto end; + } + + rcu_read_lock(); + + ust_app_synchronize_all_channels(usess, ua_sess, app); /* * Create the metadata for the application. This returns gracefully if a