From: Jonathan Rajotte Date: Mon, 6 Jun 2022 22:00:30 +0000 (-0400) Subject: Custom upgrade: refactor: ust_app_find_by_pid -> ust_app_with_pid_exists X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=refs%2Fheads%2F2.13-custom-upgrade Custom upgrade: refactor: ust_app_find_by_pid -> ust_app_with_pid_exists ust_app_find_by_pid is only used to check if apps should be updated. No need to return a ust_app. When a ust_app will be necessary, multiple ust_app objects could be returned. Signed-off-by: Jonathan Rajotte Change-Id: Ic6d2ff9820591ca85021ce701982136424792a22 --- diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index b6e756cc6..b28e5317e 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -987,7 +987,6 @@ enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value( struct process_attr_tracker *tracker; int integral_value; enum process_attr_tracker_status status; - struct ust_app *app; /* * Convert process attribute tracker value to the integral @@ -1067,10 +1066,7 @@ enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value( /* Add session to application */ switch (process_attr) { case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID: - app = ust_app_find_by_pid(integral_value); - if (app) { - should_update_apps = true; - } + should_update_apps = ust_app_with_pid_exists(integral_value); break; default: should_update_apps = true; @@ -1096,7 +1092,6 @@ enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value( struct process_attr_tracker *tracker; int integral_value; enum process_attr_tracker_status status; - struct ust_app *app; /* * Convert process attribute tracker value to the integral @@ -1177,10 +1172,7 @@ enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value( /* Add session to application */ switch (process_attr) { case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID: - app = ust_app_find_by_pid(integral_value); - if (app) { - should_update_apps = true; - } + should_update_apps = ust_app_with_pid_exists(integral_value); break; default: should_update_apps = true; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 409fb3590..e180bff2a 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -3910,28 +3910,25 @@ error: } /* - * Return ust app pointer or NULL if not found. RCU read side lock MUST be + * Check if a ust_app with a given pid is present. RCU read side lock MUST be * acquired before calling this function. */ -struct ust_app *ust_app_find_by_pid(pid_t pid) +bool ust_app_with_pid_exists(pid_t pid) { - struct ust_app *app = NULL; struct lttng_ht_node_ulong *node; struct lttng_ht_iter iter; + bool present = false; lttng_ht_lookup(ust_app_ht, (void *)((unsigned long) pid), &iter); node = lttng_ht_iter_get_node_ulong(&iter); if (node == NULL) { - DBG2("UST app no found with pid %d", pid); - goto error; + DBG2("UST app not found with pid %d", pid); + goto end; } - DBG2("Found UST app by pid %d", pid); - - app = caa_container_of(node, struct ust_app, pid_n); - -error: - return app; + present = true; +end: + return present; } /* diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 4a7a7c92d..7bdc80988 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -362,7 +362,7 @@ void ust_app_global_update_all_event_notifier_rules(void); void ust_app_clean_list(void); int ust_app_ht_alloc(void); -struct ust_app *ust_app_find_by_pid(pid_t pid); +bool ust_app_with_pid_exists(pid_t pid); struct ust_app_stream *ust_app_alloc_stream(void); int ust_app_recv_registration(int sock, struct ust_register_msg *msg); int ust_app_recv_notify(int sock); @@ -614,9 +614,9 @@ struct ust_app *ust_app_find_by_sock(int sock) return NULL; } static inline -struct ust_app *ust_app_find_by_pid(pid_t pid) +bool ust_app_with_pid_exists(pid_t pid) { - return NULL; + return false; } static inline uint64_t ust_app_get_size_one_more_packet_per_stream(