[lttng-dev] [PATCH lttng-tools] Fix: consumer signal handling race
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Mon Sep 7 11:27:32 EDT 2015
I notice this fix is now merged, thanks!
Mathieu
----- On Sep 5, 2015, at 7:58 PM, Mathieu Desnoyers mathieu.desnoyers at efficios.com wrote:
> If a signal comes in after ctx has been destroyed, it will try to use a
> closed file descriptor.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> src/bin/lttng-consumerd/lttng-consumerd.c | 10 ++++++++--
> src/bin/lttng-sessiond/main.c | 1 -
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c
> b/src/bin/lttng-consumerd/lttng-consumerd.c
> index 764cf4c..0d34fee 100644
> --- a/src/bin/lttng-consumerd/lttng-consumerd.c
> +++ b/src/bin/lttng-consumerd/lttng-consumerd.c
> @@ -109,7 +109,9 @@ static void sighandler(int sig)
> return;
> }
>
> - lttng_consumer_should_exit(ctx);
> + if (ctx) {
> + lttng_consumer_should_exit(ctx);
> + }
> }
>
> /*
> @@ -312,6 +314,7 @@ int main(int argc, char **argv)
> {
> int ret = 0, retval = 0;
> void *status;
> + struct lttng_consumer_local_data *tmp_ctx;
>
> if (set_signal_handler()) {
> retval = -1;
> @@ -626,7 +629,10 @@ exit_health_thread:
> exit_health_pipe:
>
> exit_init_data:
> - lttng_consumer_destroy(ctx);
> + tmp_ctx = ctx;
> + ctx = NULL;
> + cmm_barrier(); /* Clear ctx for signal handler. */
> + lttng_consumer_destroy(tmp_ctx);
> lttng_consumer_cleanup();
>
> if (health_consumerd) {
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index 2983cbf..7c48e4d 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -712,7 +712,6 @@ static void sessiond_cleanup(void)
> wait_consumer(&ustconsumer64_data);
> wait_consumer(&ustconsumer32_data);
>
> -
> DBG("Cleaning up all agent apps");
> agent_app_ht_clean();
>
> --
> 2.1.4
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list