Fix: sessiond: snapshot errors don't clear session's trace chunk
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 2c2ce285a676461238703f2cb77a285cdb5a66b6..5e522d6fe0886108b87df756e930a6519a5a8a09 100644 (file)
@@ -1,19 +1,9 @@
 /*
- * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _LGPL_SOURCE
@@ -4584,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;
        }
@@ -4697,7 +4687,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                        snapshot_output->max_size);
        if (nb_packets_per_stream < 0) {
                ret_code = LTTNG_ERR_MAX_SIZE_INVALID;
-               goto error;
+               goto error_close_trace_chunk;
        }
 
        if (session->kernel_session) {
@@ -4705,7 +4695,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                snapshot_kernel_consumer_output, session,
                                wait, nb_packets_per_stream);
                if (ret_code != LTTNG_OK) {
-                       goto error;
+                       goto error_close_trace_chunk;
                }
        }
 
@@ -4714,10 +4704,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                snapshot_ust_consumer_output, session,
                                wait, nb_packets_per_stream);
                if (ret_code != LTTNG_OK) {
-                       goto error;
+                       goto error_close_trace_chunk;
                }
        }
 
+error_close_trace_chunk:
        if (session_set_trace_chunk(session, NULL, &snapshot_trace_chunk)) {
                ERR("Failed to release the current trace chunk of session \"%s\"",
                                session->name);
This page took 0.026534 seconds and 5 git commands to generate.