X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng-context-vtid.c;h=264bbb3011da08760bbb85697de1bf64f1f6f048;hb=a93244f8421385c560a70d0308a69e7c9289916e;hp=522d2bd6112b8bb74c9be53ea172324f7d1363f4;hpb=74a747024b7d44431e22a6ce3c628ad72d2700a5;p=lttng-modules.git diff --git a/lttng-context-vtid.c b/lttng-context-vtid.c index 522d2bd6..264bbb30 100644 --- a/lttng-context-vtid.c +++ b/lttng-context-vtid.c @@ -32,7 +32,13 @@ void vtid_record(struct lttng_ctx_field *field, { pid_t vtid; - vtid = task_pid_vnr(current); + /* + * nsproxy can be NULL when scheduled out of exit. + */ + if (!current->nsproxy) + vtid = 0; + else + vtid = task_pid_vnr(current); lib_ring_buffer_align_ctx(ctx, ltt_alignof(vtid)); chan->ops->event_write(ctx, &vtid, sizeof(vtid)); } @@ -44,6 +50,10 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx) field = lttng_append_context(ctx); if (!field) return -ENOMEM; + if (lttng_find_context(*ctx, "vtid")) { + lttng_remove_context_field(ctx, field); + return -EEXIST; + } field->event_field.name = "vtid"; field->event_field.type.atype = atype_integer; field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;