Fix: sessiond: bad fd used while rotating exiting app's buffers
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.h
index 9b42d518d30f2e619ea7f89c5e4dc307454b37b7..3972088a4cbde6415db658deb2f4c7fefd741884 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
  * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * SPDX-License-Identifier: GPL-2.0-only
@@ -10,7 +10,9 @@
 #define _LTT_UST_APP_H
 
 #include <stdint.h>
+#include <urcu/ref.h>
 
+#include <common/index-allocator.h>
 #include <common/uuid.h>
 
 #include "trace-ust.h"
@@ -25,7 +27,7 @@
 struct lttng_bytecode;
 struct lttng_ust_filter_bytecode;
 
-extern int ust_consumerd64_fd, ust_consumerd32_fd;
+extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
 
 /*
  * Object used to close the notify socket in a call_rcu(). Since the
@@ -41,6 +43,7 @@ struct ust_app_ht_key {
        const char *name;
        const struct lttng_bytecode *filter;
        enum lttng_ust_abi_loglevel_type loglevel_type;
+       int loglevel_value;
        const struct lttng_event_exclusion *exclusion;
 };
 
@@ -48,7 +51,7 @@ struct ust_app_ht_key {
  * Application registration data structure.
  */
 struct ust_register_msg {
-       enum ustctl_socket_type type;
+       enum lttng_ust_ctl_socket_type type;
        uint32_t major;
        uint32_t minor;
        uint32_t abi_major;
@@ -114,6 +117,7 @@ struct ust_app_event {
 
 struct ust_app_event_notifier_rule {
        int enabled;
+       uint64_t error_counter_index;
        int handle;
        struct lttng_ust_abi_object_data *obj;
        /* Holds a strong reference. */
@@ -156,7 +160,7 @@ struct ust_app_channel {
        unsigned int expected_stream_count;
        char name[LTTNG_UST_ABI_SYM_NAME_LEN];
        struct lttng_ust_abi_object_data *obj;
-       struct ustctl_consumer_channel_attr attr;
+       struct lttng_ust_ctl_consumer_channel_attr attr;
        struct ust_app_stream_list streams;
        /* Session pointer that owns this object. */
        struct ust_app_session *session;
@@ -235,7 +239,7 @@ struct ust_app_session {
        unsigned int live_timer_interval;       /* usec */
 
        /* Metadata channel attributes. */
-       struct ustctl_consumer_channel_attr metadata_attr;
+       struct lttng_ust_ctl_consumer_channel_attr metadata_attr;
 
        char root_shm_path[PATH_MAX];
        char shm_path[PATH_MAX];
@@ -246,6 +250,12 @@ struct ust_app_session {
  * and a linked list is kept of all running traceable app.
  */
 struct ust_app {
+       /*
+        * The lifetime of 'sock' holds a reference to the application; the
+        * application management thread will release a reference to the
+        * application if the application dies.
+        */
+       struct urcu_ref ref;
        int sock;
        pthread_mutex_t sock_lock;      /* Protects sock protocol. */
 
@@ -319,6 +329,9 @@ struct ust_app {
                 */
                struct lttng_ust_abi_object_data *object;
                struct lttng_pipe *event_pipe;
+               struct lttng_ust_abi_object_data *counter;
+               struct lttng_ust_abi_object_data **counter_cpu;
+               int nr_counter_cpu;
        } event_notifier_group;
        /*
         * Hashtable indexing the application's event notifier rule's
@@ -332,7 +345,7 @@ struct ust_app {
 int ust_app_register(struct ust_register_msg *msg, int sock);
 int ust_app_register_done(struct ust_app *app);
 int ust_app_version(struct ust_app *app);
-void ust_app_unregister(int sock);
+void ust_app_unregister_by_socket(int sock);
 int ust_app_start_trace_all(struct ltt_ust_session *usess);
 int ust_app_stop_trace_all(struct ltt_ust_session *usess);
 int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
@@ -366,7 +379,6 @@ struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
 void ust_app_notify_sock_unregister(int sock);
 ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
                struct consumer_socket *socket, int send_zero_data);
-void ust_app_destroy(struct ust_app *app);
 enum lttng_error_code ust_app_snapshot_record(
                const struct ltt_ust_session *usess,
                const struct consumer_output *output, int wait,
@@ -399,6 +411,12 @@ int ust_app_supported(void)
        return 1;
 }
 
+bool ust_app_supports_notifiers(const struct ust_app *app);
+bool ust_app_supports_counters(const struct ust_app *app);
+
+bool ust_app_get(struct ust_app *app);
+void ust_app_put(struct ust_app *app);
+
 #else /* HAVE_LIBLTTNG_UST_CTL */
 
 static inline
@@ -447,7 +465,7 @@ int ust_app_version(struct ust_app *app)
        return -ENOSYS;
 }
 static inline
-void ust_app_unregister(int sock)
+void ust_app_unregister_by_socket(int sock)
 {
 }
 static inline
@@ -564,11 +582,6 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
        return 0;
 }
 static inline
-void ust_app_destroy(struct ust_app *app)
-{
-       return;
-}
-static inline
 enum lttng_error_code ust_app_snapshot_record(struct ltt_ust_session *usess,
                const struct consumer_output *output, int wait, uint64_t max_stream_size)
 {
@@ -579,13 +592,28 @@ unsigned int ust_app_get_nb_stream(struct ltt_ust_session *usess)
 {
        return 0;
 }
-
+static inline
+void ust_app_update_event_notifier_error_count(
+               struct lttng_trigger *lttng_trigger)
+{
+       return;
+}
 static inline
 int ust_app_supported(void)
 {
        return 0;
 }
 static inline
+bool ust_app_supports_notifiers(const struct ust_app *app)
+{
+       return false;
+}
+static inline
+bool ust_app_supports_counters(const struct ust_app *app)
+{
+       return false;
+}
+static inline
 struct ust_app *ust_app_find_by_sock(int sock)
 {
        return NULL;
@@ -655,6 +683,16 @@ enum lttng_error_code ust_app_open_packets(struct ltt_session *session)
        return 0;
 }
 
+static inline
+void ust_app_get(struct ust_app *app)
+{
+}
+
+static inline
+void ust_app_put(struct ust_app *app)
+{
+}
+
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
 #endif /* _LTT_UST_APP_H */
This page took 0.031558 seconds and 4 git commands to generate.