summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
98357ff)
Ensure an instrumented signal handler interrupting the procname
context code will not write a partial process name string into the
trace context.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
#include <assert.h>
#include "compat.h"
#include <assert.h>
#include "compat.h"
+/* Maximum number of nesting levels for the procname cache. */
+#define PROCNAME_NESTING_MAX 2
+
/*
* We cache the result to ensure we don't trigger a system call for
* each event.
/*
* We cache the result to ensure we don't trigger a system call for
* each event.
* be set for a thread before the first event is logged within this
* thread.
*/
* be set for a thread before the first event is logged within this
* thread.
*/
-typedef char procname_array[17];
+typedef char procname_array[PROCNAME_NESTING_MAX][17];
+
static DEFINE_URCU_TLS(procname_array, cached_procname);
static DEFINE_URCU_TLS(procname_array, cached_procname);
+static DEFINE_URCU_TLS(int, procname_nesting);
+
static inline
char *wrapper_getprocname(void)
{
static inline
char *wrapper_getprocname(void)
{
- if (caa_unlikely(!URCU_TLS(cached_procname)[0])) {
- lttng_ust_getprocname(URCU_TLS(cached_procname));
- URCU_TLS(cached_procname)[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+ int nesting = URCU_TLS(procname_nesting);
+
+ if (caa_unlikely(nesting >= PROCNAME_NESTING_MAX))
+ return "<unknown>";
+ if (caa_unlikely(!URCU_TLS(cached_procname)[nesting][0])) {
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), nesting + 1);
+ lttng_ust_getprocname(URCU_TLS(cached_procname)[nesting]);
+ URCU_TLS(cached_procname)[nesting][LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), nesting);
- return URCU_TLS(cached_procname);
+ return URCU_TLS(cached_procname)[nesting];
}
void lttng_context_procname_reset(void)
{
}
void lttng_context_procname_reset(void)
{
- URCU_TLS(cached_procname)[0] = '\0';
+ URCU_TLS(cached_procname)[1][0] = '\0';
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), 1);
+ URCU_TLS(cached_procname)[0][0] = '\0';
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), 0);