[lttng-dev] [PATCH lttng-tools 03/10] Fix: kernel tracing: flush after stop

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed May 18 18:04:12 UTC 2016


We should flush the last packet after stop, not before. Otherwise, we
may end up with events written immediately after the flush, which
defeats the purpose of flushing.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-sessiond/cmd.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
index 16d8ba2..d57edcd 100644
--- a/src/bin/lttng-sessiond/cmd.c
+++ b/src/bin/lttng-sessiond/cmd.c
@@ -2437,7 +2437,15 @@ int cmd_stop_trace(struct ltt_session *session)
 	if (ksession && ksession->active) {
 		DBG("Stop kernel tracing");
 
-		/* Flush metadata if exist */
+		ret = kernel_stop_session(ksession);
+		if (ret < 0) {
+			ret = LTTNG_ERR_KERN_STOP_FAIL;
+			goto error;
+		}
+
+		kernel_wait_quiescent(kernel_tracer_fd);
+
+		/* Flush metadata after stopping (if exists) */
 		if (ksession->metadata_stream_fd >= 0) {
 			ret = kernel_metadata_flush_buffer(ksession->metadata_stream_fd);
 			if (ret < 0) {
@@ -2445,7 +2453,7 @@ int cmd_stop_trace(struct ltt_session *session)
 			}
 		}
 
-		/* Flush all buffers before stopping */
+		/* Flush all buffers after stopping */
 		cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) {
 			ret = kernel_flush_buffer(kchan);
 			if (ret < 0) {
@@ -2453,14 +2461,6 @@ int cmd_stop_trace(struct ltt_session *session)
 			}
 		}
 
-		ret = kernel_stop_session(ksession);
-		if (ret < 0) {
-			ret = LTTNG_ERR_KERN_STOP_FAIL;
-			goto error;
-		}
-
-		kernel_wait_quiescent(kernel_tracer_fd);
-
 		ksession->active = 0;
 	}
 
-- 
2.1.4



More information about the lttng-dev mailing list