Fix: don't access packet header for stream_id and stream_instance_id getters
[lttng-ust.git] / liblttng-ust / lttng-ring-buffer-client.h
index e5640b2ea0e4e7096e8729e975f75141b0892692..55209f45236db21b3700f8ddac0179430780eec8 100644 (file)
@@ -556,12 +556,11 @@ static int client_stream_id(struct lttng_ust_lib_ring_buffer *buf,
                struct lttng_ust_shm_handle *handle,
                uint64_t *stream_id)
 {
-       struct packet_header *header;
+       struct channel *chan = shmp(handle, buf->backend.chan);
+       struct lttng_channel *lttng_chan = channel_get_private(chan);
+
+       *stream_id = lttng_chan->id;
 
-       header = client_packet_header(buf, handle);
-       if (!header)
-               return -1;
-       *stream_id = header->stream_id;
        return 0;
 }
 
@@ -592,10 +591,8 @@ static int client_instance_id(struct lttng_ust_lib_ring_buffer *buf,
                struct lttng_ust_shm_handle *handle,
                uint64_t *id)
 {
-       struct packet_header *header;
+       *id = buf->backend.cpu;
 
-       header = client_packet_header(buf, handle);
-       *id = header->stream_instance_id;
        return 0;
 }
 
@@ -658,7 +655,8 @@ struct lttng_channel *_channel_create(const char *name,
                                unsigned int read_timer_interval,
                                unsigned char *uuid,
                                uint32_t chan_id,
-                               const int *stream_fds, int nr_stream_fds)
+                               const int *stream_fds, int nr_stream_fds,
+                               int64_t blocking_timeout)
 {
        struct lttng_channel chan_priv_init;
        struct lttng_ust_shm_handle *handle;
@@ -674,7 +672,7 @@ struct lttng_channel *_channel_create(const char *name,
                        &chan_priv_init,
                        buf_addr, subbuf_size, num_subbuf,
                        switch_timer_interval, read_timer_interval,
-                       stream_fds, nr_stream_fds);
+                       stream_fds, nr_stream_fds, blocking_timeout);
        if (!handle)
                return NULL;
        lttng_chan = priv;
@@ -715,8 +713,16 @@ int lttng_event_reserve(struct lttng_ust_lib_ring_buffer_ctx *ctx,
        }
 
        ret = lib_ring_buffer_reserve(&client_config, ctx);
-       if (ret)
+       if (caa_unlikely(ret))
                goto put;
+       if (caa_likely(ctx->ctx_len
+                       >= sizeof(struct lttng_ust_lib_ring_buffer_ctx))) {
+               if (lib_ring_buffer_backend_get_pages(&client_config, ctx,
+                               &ctx->backend_pages)) {
+                       ret = -EPERM;
+                       goto put;
+               }
+       }
        lttng_write_event_header(&client_config, ctx, event_id);
        return 0;
 put:
This page took 0.024149 seconds and 4 git commands to generate.