Fix: baddr_statedump deadlock with JUL tracing
authorPaul Woegerer <paul_woegerer@mentor.com>
Fri, 29 Nov 2013 13:32:54 +0000 (14:32 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 30 Nov 2013 12:40:20 +0000 (13:40 +0100)
Signed-off-by: Paul Woegerer <paul_woegerer@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-events.h
liblttng-ust/lttng-events.c
liblttng-ust/lttng-tracer-core.h
liblttng-ust/lttng-ust-comm.c

index 5d4357084edc69d703fcda27619b6360ac9f361e..28f7391b56a5144bae513d67dabab498edb472d7 100644 (file)
@@ -513,6 +513,9 @@ struct lttng_session {
        struct lttng_ust_event_ht events_ht;    /* ht of events */
        void *owner;                            /* object owner */
        int tstate:1;                           /* Transient enable state */
+
+       /* New UST 2.4 */
+       int statedump_pending:1;
 };
 
 struct lttng_transport {
@@ -606,4 +609,7 @@ void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
 struct cds_list_head *lttng_get_probe_list_head(void);
 int lttng_session_active(void);
 
+typedef int (*t_statedump_func_ptr)(struct lttng_session *session);
+int lttng_handle_pending_statedumps(t_statedump_func_ptr statedump_func_ptr);
+
 #endif /* _LTTNG_UST_EVENTS_H */
index 77515843d3a0f5e2a6f895685064689aece4fd98..9380e9ceb688b9b46df58122d7cc3a47c14421b3 100644 (file)
@@ -294,7 +294,8 @@ int lttng_session_enable(struct lttng_session *session)
        CMM_ACCESS_ONCE(session->active) = 1;
        CMM_ACCESS_ONCE(session->been_active) = 1;
 
-       lttng_ust_sockinfo_session_enabled(session->owner, session);
+       session->statedump_pending = 1;
+       lttng_ust_sockinfo_session_enabled(session->owner);
 end:
        return ret;
 }
@@ -674,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.
  */
index e7f549e0cede664c7038f92b7bc5b29a50951d51..57df175f283d9927ba08fd2841e0f4d980546eca 100644 (file)
@@ -45,7 +45,6 @@ const char *lttng_ust_obj_get_name(int id);
 
 int lttng_get_notify_socket(void *owner);
 
-void lttng_ust_sockinfo_session_enabled(void *owner,
-               struct lttng_session *session_enabled);
+void lttng_ust_sockinfo_session_enabled(void *owner);
 
 #endif /* _LTTNG_TRACER_CORE_H */
index b99bf00edec2df760df075f0ad77597a3e1a54d1..4724fabc0d6a72cf57923cea7e6da44d94563052 100644 (file)
@@ -108,7 +108,7 @@ struct sock_info {
 
        char wait_shm_path[PATH_MAX];
        char *wait_shm_mmap;
-       struct lttng_session *session_enabled;
+       int session_enabled;
 };
 
 /* Socket from app (connect) to session daemon (listen) for communication */
@@ -126,7 +126,7 @@ struct sock_info global_apps = {
 
        .wait_shm_path = "/" LTTNG_UST_WAIT_FILENAME,
 
-       .session_enabled = NULL,
+       .session_enabled = 0,
 };
 
 /* TODO: allow global_apps_sock_path override */
@@ -141,7 +141,7 @@ struct sock_info local_apps = {
        .socket = -1,
        .notify_socket = -1,
 
-       .session_enabled = NULL,
+       .session_enabled = 0,
 };
 
 static int wait_poll_fallback;
@@ -708,6 +708,17 @@ error:
        return ret;
 }
 
+static
+void handle_pending_statedumps(struct sock_info *sock_info)
+{
+       int ctor_passed = sock_info->constructor_sem_posted;
+
+       if (ctor_passed && sock_info->session_enabled) {
+               sock_info->session_enabled = 0;
+               lttng_handle_pending_statedumps(&lttng_ust_baddr_statedump);
+       }
+}
+
 static
 void cleanup_sock_info(struct sock_info *sock_info, int exiting)
 {
@@ -1214,13 +1225,7 @@ restart:
                        if (ret) {
                                ERR("Error handling message for %s socket", sock_info->name);
                        } else {
-                               struct lttng_session *session;
-
-                               session = sock_info->session_enabled;
-                               if (session) {
-                                       sock_info->session_enabled = NULL;
-                                       lttng_ust_baddr_statedump(session);
-                               }
+                               handle_pending_statedumps(sock_info);
                        }
                        continue;
                default:
@@ -1535,9 +1540,8 @@ void ust_after_fork_child(sigset_t *restore_sigset)
        lttng_ust_init();
 }
 
-void lttng_ust_sockinfo_session_enabled(void *owner,
-               struct lttng_session *session_enabled)
+void lttng_ust_sockinfo_session_enabled(void *owner)
 {
        struct sock_info *sock_info = owner;
-       sock_info->session_enabled = session_enabled;
+       sock_info->session_enabled = 1;
 }
This page took 0.028324 seconds and 4 git commands to generate.