Reset vtid after fork in child
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 28 Sep 2011 00:39:07 +0000 (20:39 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 28 Sep 2011 00:39:07 +0000 (20:39 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/lttng-events.h
libust/lttng-context-vtid.c
libust/lttng-ust-comm.c

index 7a8cf6f839617de14ef7673fc301487ca5f14639..6bb4e8cce10ef1b89b791a262b89a0f1cbc42387 100644 (file)
@@ -322,5 +322,6 @@ void lttng_remove_context_field(struct lttng_ctx **ctx_p,
 void lttng_destroy_context(struct lttng_ctx *ctx);
 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
 int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx);
+void lttng_context_vtid_reset(void);
 
 #endif /* _UST_LTTNG_EVENTS_H */
index fd1e320078a1e949aab91df298dc326a21aa27fc..a7e1c81de80174d998c52bfd301c0418eec17aff 100644 (file)
@@ -38,6 +38,16 @@ static inline pid_t gettid(void)
  */
 static __thread pid_t cached_vtid;
 
+/*
+ * Upon fork or clone, the TID assigned to our thread is not the same as
+ * we kept in cache. Luckily, we are the only thread surviving in the
+ * child process, so we can simply clear our cached version.
+ */
+void lttng_context_vtid_reset(void)
+{
+       cached_vtid = 0;
+}
+
 static
 size_t vtid_get_size(size_t offset)
 {
index 6bf9e2b5b350ebb2936507a054a1236c578f9b7c..7971168c638b2d14fdf0864ec3bb6a0b35ec840e 100644 (file)
@@ -39,6 +39,7 @@
 #include <urcu/futex.h>
 
 #include <lttng-ust-comm.h>
+#include <ust/lttng-events.h>
 #include <ust/usterr-signal-safe.h>
 #include <ust/lttng-ust-abi.h>
 #include <ust/tracepoint.h>
@@ -924,6 +925,7 @@ void ust_after_fork_child(ust_fork_info_t *fork_info)
        /* Release urcu mutexes */
        rcu_bp_after_fork_child();
        lttng_ust_cleanup(0);
+       lttng_context_vtid_reset();
        /* Release mutexes and reenable signals */
        ust_after_fork_common(fork_info);
        lttng_ust_init();
This page took 0.024674 seconds and 4 git commands to generate.