Fix: baddr_statedump deadlock with JUL tracing
[lttng-ust.git] / liblttng-ust / lttng-events.c
index 34c708f6b67b1d7dd2ce3b5248d45635bdd3a9b0..9380e9ceb688b9b46df58122d7cc3a47c14421b3 100644 (file)
@@ -293,6 +293,9 @@ int lttng_session_enable(struct lttng_session *session)
        /* Set atomically the state to "active" */
        CMM_ACCESS_ONCE(session->active) = 1;
        CMM_ACCESS_ONCE(session->been_active) = 1;
+
+       session->statedump_pending = 1;
+       lttng_ust_sockinfo_session_enabled(session->owner);
 end:
        return ret;
 }
@@ -491,6 +494,31 @@ static
 int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                struct lttng_enabler *enabler)
 {
+       struct lttng_ust_excluder_node *excluder;
+
+       /* If event matches with an excluder, return 'does not match' */
+       cds_list_for_each_entry(excluder, &enabler->excluder_head, node) {
+               int count;
+
+               for (count = 0; count < excluder->excluder.count; count++) {
+                       int found, len;
+                       char *excluder_name;
+
+                       excluder_name = (char *) (excluder->excluder.names)
+                                       + count * LTTNG_UST_SYM_NAME_LEN;
+                       len = strnlen(excluder_name, LTTNG_UST_SYM_NAME_LEN);
+                       if (len > 0 && excluder_name[len - 1] == '*') {
+                               found = !strncmp(desc->name, excluder_name,
+                                               len - 1);
+                       } else {
+                               found = !strncmp(desc->name, excluder_name,
+                                               LTTNG_UST_SYM_NAME_LEN - 1);
+                       }
+                       if (found) {
+                               return 0;
+                       }
+               }
+       }
        switch (enabler->type) {
        case LTTNG_ENABLER_WILDCARD:
                return lttng_desc_match_wildcard_enabler(desc, enabler);
@@ -647,6 +675,22 @@ int lttng_fix_pending_events(void)
        return 0;
 }
 
+/*
+ * Called after session enable: For each session, execute pending statedumps.
+ */
+int lttng_handle_pending_statedumps(t_statedump_func_ptr statedump_func_ptr)
+{
+       struct lttng_session *session;
+
+       cds_list_for_each_entry(session, &sessions, node) {
+               if (session->statedump_pending) {
+                       session->statedump_pending = 0;
+                       statedump_func_ptr(session);
+               }
+       }
+       return 0;
+}
+
 /*
  * Only used internally at session destruction.
  */
@@ -687,6 +731,7 @@ struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
                return NULL;
        enabler->type = type;
        CDS_INIT_LIST_HEAD(&enabler->filter_bytecode_head);
+       CDS_INIT_LIST_HEAD(&enabler->excluder_head);
        memcpy(&enabler->event_param, event_param,
                sizeof(enabler->event_param));
        enabler->chan = chan;
@@ -720,6 +765,15 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
        return 0;
 }
 
+int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler,
+               struct lttng_ust_excluder_node *excluder)
+{
+       excluder->enabler = enabler;
+       cds_list_add_tail(&excluder->node, &enabler->excluder_head);
+       lttng_session_lazy_sync_enablers(enabler->chan->session);
+       return 0;
+}
+
 int lttng_attach_context(struct lttng_ust_context *context_param,
                struct lttng_ctx **ctx, struct lttng_session *session)
 {
@@ -740,6 +794,8 @@ int lttng_attach_context(struct lttng_ust_context *context_param,
                return lttng_add_vpid_to_ctx(ctx);
        case LTTNG_UST_CONTEXT_PROCNAME:
                return lttng_add_procname_to_ctx(ctx);
+       case LTTNG_UST_CONTEXT_IP:
+               return lttng_add_ip_to_ctx(ctx);
        default:
                return -EINVAL;
        }
@@ -765,6 +821,7 @@ static
 void lttng_enabler_destroy(struct lttng_enabler *enabler)
 {
        struct lttng_ust_filter_bytecode_node *filter_node, *tmp_filter_node;
+       struct lttng_ust_excluder_node *excluder_node, *tmp_excluder_node;
 
        /* Destroy filter bytecode */
        cds_list_for_each_entry_safe(filter_node, tmp_filter_node,
@@ -772,6 +829,12 @@ void lttng_enabler_destroy(struct lttng_enabler *enabler)
                free(filter_node);
        }
 
+       /* Destroy excluders */
+       cds_list_for_each_entry_safe(excluder_node, tmp_excluder_node,
+                       &enabler->excluder_head, node) {
+               free(excluder_node);
+       }
+
        /* Destroy contexts */
        lttng_destroy_context(enabler->ctx);
 
This page took 0.028823 seconds and 4 git commands to generate.