Fix: sessiond: don't negate error code on list error
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index e067cb835e1a2739dfa35f83ce32a3d3c59b586a..31eb2b43025f6d0207ed3e840c634dabc25b405a 100644 (file)
@@ -823,8 +823,7 @@ end:
        return nb_event;
 
 error:
-       /* Negate the error code to differentiate the size from an error */
-       return -ret;
+       return ret;
 }
 
 /*
@@ -4540,7 +4539,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;
        }
@@ -4653,7 +4652,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) {
@@ -4661,7 +4660,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;
                }
        }
 
@@ -4670,10 +4669,10 @@ 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_close_trace_chunk(
                            session, session->current_trace_chunk, NULL, NULL)) {
                /*
@@ -4907,6 +4906,12 @@ int cmd_rotate_session(struct ltt_session *session,
                goto end;
        }
 
+       /* Unsupported feature in lttng-modules before 2.8 (lack of sequence number). */
+       if (session->kernel_session && !kernel_supports_ring_buffer_packet_sequence_number()) {
+               cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL;
+               goto end;
+       }
+
        if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) {
                DBG("Refusing to launch a rotation; a rotation is already in progress for session %s",
                                session->name);
This page took 0.024922 seconds and 4 git commands to generate.