Compute variable sized context length
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 30 May 2017 15:50:18 +0000 (11:50 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 11 Jun 2018 18:38:50 +0000 (14:38 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-ring-buffer-client.h

index 48d304293b95c4f7baa84ee44784810928f1ce77..8b87db0d4ca47e3d7e0b696db0002efb30b59a34 100644 (file)
@@ -100,7 +100,8 @@ size_t ctx_get_aligned_size(size_t offset, struct lttng_ctx *ctx,
 }
 
 static inline
-void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len)
+void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len,
+               struct lttng_channel *chan, struct lib_ring_buffer_ctx *bufctx)
 {
        int i;
        size_t offset = 0;
@@ -109,8 +110,13 @@ void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len)
                *ctx_len = 0;
                return;
        }
-       for (i = 0; i < ctx->nr_fields; i++)
-               offset += ctx->fields[i].get_size(offset);
+       for (i = 0; i < ctx->nr_fields; i++) {
+               if (ctx->fields[i].get_size)
+                       offset += ctx->fields[i].get_size(offset);
+               if (ctx->fields[i].get_size_arg)
+                       offset += ctx->fields[i].get_size_arg(offset,
+                                       &ctx->fields[i], bufctx, chan);
+       }
        *ctx_len = offset;
 }
 
@@ -631,8 +637,8 @@ int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx,
        int ret, cpu;
 
        /* Compute internal size of context structures. */
-       ctx_get_struct_size(lttng_chan->ctx, &client_ctx.packet_context_len);
-       ctx_get_struct_size(event->ctx, &client_ctx.event_context_len);
+       ctx_get_struct_size(lttng_chan->ctx, &client_ctx.packet_context_len, lttng_chan, ctx);
+       ctx_get_struct_size(event->ctx, &client_ctx.event_context_len, lttng_chan, ctx);
 
        cpu = lib_ring_buffer_get_cpu(&client_config);
        if (unlikely(cpu < 0))
This page took 0.026507 seconds and 4 git commands to generate.