lttng lib: ring buffer remove duplicate null pointer
[lttng-modules.git] / lttng-context-vtid.c
index 665e1a9c21755bb8b4a4aab4f07e6dcdf4ce00b1..264bbb3011da08760bbb85697de1bf64f1f6f048 100644 (file)
@@ -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));
 }
@@ -40,11 +46,14 @@ void vtid_record(struct lttng_ctx_field *field,
 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
 {
        struct lttng_ctx_field *field;
-       int ret;
 
        field = lttng_append_context(ctx);
        if (!field)
-               return ret;
+               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;
This page took 0.023145 seconds and 4 git commands to generate.