consumerd: cleanup: use buffer view interface for mmap read subbuf
[lttng-tools.git] / src / common / consumer / consumer.h
index 256ea1976016feffcf805d5d5bd0df3d8598a2bf..aebcf4baccb9711eb36fa1521c2ae857e7ee8b34 100644 (file)
@@ -33,6 +33,7 @@
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/pipe.h>
 #include <common/index/ctf-index.h>
+#include <common/buffer-view.h>
 
 /* Commands for consumer */
 enum lttng_consumer_command {
@@ -218,6 +219,8 @@ struct lttng_consumer_channel {
        uint64_t discarded_events;
        /* Total number of missed packets due to overwriting (overwrite). */
        uint64_t lost_packets;
+
+       bool streams_sent_to_relayd;
 };
 
 /*
@@ -300,8 +303,11 @@ struct lttng_consumer_stream {
        /* UID/GID of the user owning the session to which stream belongs */
        uid_t uid;
        gid_t gid;
-       /* Network sequence number. Indicating on which relayd socket it goes. */
-       uint64_t net_seq_idx;
+       /*
+        * Relayd id, indicating on which relayd socket it goes. Set to -1ULL if
+        * not the stream is not associated to a relay daemon.
+        */
+       uint64_t relayd_id;
        /*
         * Indicate if this stream was successfully sent to a relayd. This is set
         * after the refcount of the relayd is incremented and is checked when the
@@ -337,9 +343,9 @@ struct lttng_consumer_stream {
         * Lock to use the stream FDs since they are used between threads.
         *
         * This is nested INSIDE the consumer_data lock.
-        * This is nested INSIDE the metadata cache lock.
         * This is nested INSIDE the channel lock.
         * This is nested INSIDE the channel timer lock.
+        * This is nested OUTSIDE the metadata cache lock.
         * This is nested OUTSIDE consumer_relayd_sock_pair lock.
         */
        pthread_mutex_t lock;
@@ -390,9 +396,9 @@ struct lttng_consumer_stream {
        /* Copy of the sequence number of the last packet extracted. */
        uint64_t last_sequence_number;
        /*
-        * FD of the index file for this stream.
+        * Index file object of the index file for this stream.
         */
-       int index_fd;
+       struct lttng_index_file *index_file;
 
        /*
         * Local pipe to extract data when using splice.
@@ -419,9 +425,9 @@ struct lttng_consumer_stream {
  */
 struct consumer_relayd_sock_pair {
        /* Network sequence number. */
-       uint64_t net_seq_idx;
+       uint64_t id;
        /* Number of stream associated with this relayd */
-       unsigned int refcount;
+       int refcount;
 
        /*
         * This flag indicates whether or not we should destroy this object. The
@@ -455,6 +461,7 @@ struct consumer_relayd_sock_pair {
        /* Session id on both sides for the sockets. */
        uint64_t relayd_session_id;
        uint64_t sessiond_session_id;
+       struct lttng_consumer_local_data *ctx;
 };
 
 /*
@@ -591,6 +598,12 @@ struct lttng_consumer_global_data {
        struct lttng_ht *stream_per_chan_id_ht;
 };
 
+/*
+ * Set to nonzero when the consumer is exiting. Updated by signal
+ * handler and thread exit, read by threads.
+ */
+extern volatile int consumer_quit;
+
 /*
  * Init consumer data structures.
  */
@@ -670,7 +683,7 @@ void consumer_del_channel(struct lttng_consumer_channel *channel);
 /* lttng-relayd consumer command */
 struct consumer_relayd_sock_pair *consumer_find_relayd(uint64_t key);
 int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path);
-int consumer_send_relayd_streams_sent(uint64_t net_seq_idx);
+int consumer_send_relayd_streams_sent(uint64_t relayd_id);
 void close_relayd_stream(struct lttng_consumer_stream *stream);
 struct lttng_consumer_channel *consumer_find_channel(uint64_t key);
 int consumer_handle_stream_before_relayd(struct lttng_consumer_stream *stream,
@@ -687,7 +700,8 @@ struct lttng_consumer_local_data *lttng_consumer_create(
 void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx);
 ssize_t lttng_consumer_on_read_subbuffer_mmap(
                struct lttng_consumer_local_data *ctx,
-               struct lttng_consumer_stream *stream, unsigned long len,
+               struct lttng_consumer_stream *stream,
+               const struct lttng_buffer_view *buffer,
                unsigned long padding,
                struct ctf_packet_index *index);
 ssize_t lttng_consumer_on_read_subbuffer_splice(
@@ -710,7 +724,7 @@ int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
 ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
                struct lttng_consumer_local_data *ctx);
 int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream);
-int consumer_add_relayd_socket(uint64_t net_seq_idx, int sock_type,
+void consumer_add_relayd_socket(uint64_t relayd_id, int sock_type,
                struct lttng_consumer_local_data *ctx, int sock,
                struct pollfd *consumer_sockpoll, struct lttcomm_relayd_sock *relayd_sock,
                uint64_t sessiond_id, uint64_t relayd_session_id);
@@ -731,5 +745,6 @@ void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
 int consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
 void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
 int consumer_create_index_file(struct lttng_consumer_stream *stream);
+void lttng_consumer_cleanup_relayd(struct consumer_relayd_sock_pair *relayd);
 
 #endif /* LIB_CONSUMER_H */
This page took 0.025498 seconds and 5 git commands to generate.