From: Mathieu Desnoyers Date: Mon, 3 Oct 2016 17:18:53 +0000 (-0400) Subject: Fix: perform statedump before replying to sessiond X-Git-Tag: v2.9.0-rc1~2 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=4c62d8d195fb07d3bc64b6a81836d2a5be4abcf3 Fix: perform statedump before replying to sessiond If a stop command immediately follows a start command, the consumer daemon will stop event recording in the ring buffers shared memory control structures before the sessiond sends further commands to the application. Therefore, a stop-after-start may be performed concurrently with the statedump, leading to have parts of the statedump being missing. This case may always happen if an application exits during statedump, but it is not expected to have incomplete statedump in the stop-after-start use case. The session daemon statedump regeneration tests expect that the statedump is completed when the regeneration command returns. This also requires that we perform the statedump in lttng-ust before replying to the session daemon command. Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 4a218663..7cd6a227 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -956,6 +956,21 @@ int handle_message(struct sock_info *sock_info, } } DBG("Return value: %d", lur.ret_val); + + ust_unlock(); + + /* + * Performed delayed statedump operations outside of the UST + * lock. We need to take the dynamic loader lock before we take + * the UST lock internally within handle_pending_statedump(). + */ + handle_pending_statedump(sock_info); + + if (ust_lock()) { + ret = -LTTNG_UST_ERR_EXITING; + goto error; + } + ret = send_reply(sock, &lur); if (ret < 0) { DBG("error sending reply"); @@ -986,13 +1001,6 @@ int handle_message(struct sock_info *sock_info, error: ust_unlock(); - /* - * Performed delayed statedump operations outside of the UST - * lock. We need to take the dynamic loader lock before we take - * the UST lock internally within handle_pending_statedump(). - */ - handle_pending_statedump(sock_info); - return ret; }