X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=6c6386d2b3b1107255260110175743fa04ccf9bf;hb=fdadac0853f699c7dc829162955cc8f459b6d2f2;hp=b688a4c09e45f25c3d62bc82b86cc73bcb23fe16;hpb=52898cb1ecfe2cf37bda9b95039826da517b9a5b;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index b688a4c09..6c6386d2b 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -727,6 +727,12 @@ static void update_ust_app(int app_sock) { struct ltt_session *sess, *stmp; + /* Consumer is in an ERROR state. Stop any application update. */ + if (uatomic_read(&ust_consumerd_state) == CONSUMER_ERROR) { + /* Stop the update process since the consumer is dead. */ + return; + } + /* For all tracing session(s) */ cds_list_for_each_entry_safe(sess, stmp, &session_list_ptr->head, list) { session_lock(sess); @@ -1135,6 +1141,13 @@ restart_poll: exit: error: + /* + * We lock here because we are about to close the sockets and some other + * thread might be using them so wait before we are exclusive which will + * abort all other consumer command by other threads. + */ + pthread_mutex_lock(&consumer_data->lock); + /* Immediately set the consumerd state to stopped */ if (consumer_data->type == LTTNG_CONSUMER_KERNEL) { uatomic_set(&kernel_consumerd_state, CONSUMER_ERROR); @@ -1166,9 +1179,6 @@ error: PERROR("close"); } } - /* Cleanup metadata socket mutex. */ - pthread_mutex_destroy(consumer_data->metadata_sock.lock); - free(consumer_data->metadata_sock.lock); if (sock >= 0) { ret = close(sock); @@ -1180,6 +1190,10 @@ error: unlink(consumer_data->err_unix_sock_path); unlink(consumer_data->cmd_unix_sock_path); consumer_data->pid = 0; + pthread_mutex_unlock(&consumer_data->lock); + /* Cleanup metadata socket mutex. */ + pthread_mutex_destroy(consumer_data->metadata_sock.lock); + free(consumer_data->metadata_sock.lock); lttng_poll_clean(&events); error_poll: