Fix: grab more than one packet for snapshots
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index b6b24a5a2b2b426fc78845bb8ca4bf7b1f16770a..bac01a0359ab85d93990c0fcb6ec1676c7cd896b 100644 (file)
@@ -201,6 +201,9 @@ int kernel_create_event(struct lttng_event *ev,
                case ENOSYS:
                        WARN("Event type not implemented");
                        break;
+               case ENOENT:
+                       WARN("Event %s not found!", ev->name);
+                       break;
                default:
                        PERROR("create event ioctl");
                }
@@ -759,16 +762,17 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess)
        DBG("Tearing down kernel session");
 
        /*
-        * Destroy channels on the consumer if in no output mode because the
-        * streams are in *no* monitor mode so we have to send a command to clean
-        * them up or else they leaked.
+        * Destroy channels on the consumer if at least one FD has been sent and we
+        * are in no output mode because the streams are in *no* monitor mode so we
+        * have to send a command to clean them up or else they leaked.
         */
-       if (!ksess->output_traces) {
+       if (!ksess->output_traces && ksess->consumer_fds_sent) {
                int ret;
                struct consumer_socket *socket;
                struct lttng_ht_iter iter;
 
                /* For each consumer socket. */
+               rcu_read_lock();
                cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
                                socket, node.node) {
                        struct ltt_kernel_channel *chan;
@@ -782,6 +786,7 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess)
                                }
                        }
                }
+               rcu_read_unlock();
        }
 
        /* Close any relayd session */
@@ -826,7 +831,8 @@ void kernel_destroy_channel(struct ltt_kernel_channel *kchan)
  * Return 0 on success or else return a LTTNG_ERR code.
  */
 int kernel_snapshot_record(struct ltt_kernel_session *ksess,
-               struct snapshot_output *output, int wait, unsigned int nb_streams)
+               struct snapshot_output *output, int wait,
+               uint64_t nb_packets_per_stream)
 {
        int err, ret, saved_metadata_fd;
        struct consumer_socket *socket;
@@ -858,10 +864,6 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                goto error_open_stream;
        }
 
-       if (output->max_size > 0 && nb_streams > 0) {
-               max_size_per_stream = output->max_size / nb_streams;
-       }
-
        /* Send metadata to consumer and snapshot everything. */
        cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
                        socket, node.node) {
@@ -888,22 +890,11 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
 
                /* For each channel, ask the consumer to snapshot it. */
                cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
-                       if (max_size_per_stream &&
-                                       chan->channel->attr.subbuf_size > max_size_per_stream) {
-                               ret = LTTNG_ERR_INVALID;
-                               DBG3("Kernel snapshot record maximum stream size %" PRIu64
-                                               " is smaller than subbuffer size of %" PRIu64,
-                                               max_size_per_stream, chan->channel->attr.subbuf_size);
-                               (void) kernel_consumer_destroy_metadata(socket,
-                                               ksess->metadata);
-                               goto error_consumer;
-                       }
-
                        pthread_mutex_lock(socket->lock);
                        ret = consumer_snapshot_channel(socket, chan->fd, output, 0,
                                        ksess->uid, ksess->gid,
                                        DEFAULT_KERNEL_TRACE_DIR, wait,
-                                       max_size_per_stream);
+                                       nb_packets_per_stream);
                        pthread_mutex_unlock(socket->lock);
                        if (ret < 0) {
                                ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
@@ -917,7 +908,7 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                pthread_mutex_lock(socket->lock);
                ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output,
                                1, ksess->uid, ksess->gid,
-                               DEFAULT_KERNEL_TRACE_DIR, wait, max_size_per_stream);
+                               DEFAULT_KERNEL_TRACE_DIR, wait, 0);
                pthread_mutex_unlock(socket->lock);
                if (ret < 0) {
                        ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
This page took 0.024835 seconds and 4 git commands to generate.