From aecf2da5ff4c92398b58af71ec10a3c2a311076e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 3 Feb 2020 17:25:58 -0500 Subject: [PATCH] Fix: sessiond: bounded snapshot record fails when no streams exist MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Attempting to record a snapshot with a `--max-size` fails when no streams exist. For instance, attempting to record a snapshot for a user space session when no applications are running will fail with the following output: Error: Invalid snapshot size. Cannot fit at least one packet per stream. Error: Snapshot max size is invalid The function get_session_nb_packets_per_stream() computes an approximation of the number of packets to capture to honor the maximal size specified. However, at the end, it doesn't distinguish between '0' meaning that "no packets can be captured" (no streams exist) and '0' meaning that "the max size is too small to accomodate one packet". Those two cases can be distinguished by checking if the 'size_left' is still the 'max_size', meaning that not even the size of one packet was substracted from 'max_size'. Reported-by: Simon Marchi Signed-off-by: Jérémie Galarneau Change-Id: I5caef9ce926bbc7143a90667749ffaed972590c1 --- src/bin/lttng-sessiond/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 68b6aa253..139133210 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -4574,7 +4574,7 @@ int64_t get_session_nb_packets_per_stream(const struct ltt_session *session, } cur_nb_packets++; } - if (!cur_nb_packets) { + if (!cur_nb_packets && size_left != max_size) { /* Not enough room to grab one packet of each stream, error. */ return -1; } -- 2.34.1