From: Mathieu Desnoyers Date: Sat, 22 Oct 2011 23:48:50 +0000 (-0400) Subject: Add ustctl_open_stream_read and ustctl_close_stream_read X-Git-Tag: v1.9.1~164 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6e922b240977010b0f257d22c379df95cf1a6fb9;p=lttng-ust.git Add ustctl_open_stream_read and ustctl_close_stream_read Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/lttng-ust-ctl.h b/include/ust/lttng-ust-ctl.h index 58906a57..52c954aa 100644 --- a/include/ust/lttng-ust-ctl.h +++ b/include/ust/lttng-ust-ctl.h @@ -90,6 +90,12 @@ void ustctl_unmap_channel(struct shm_handle *shm_handle); struct shm_handle; struct lib_ring_buffer; +/* Open/close stream buffers for read */ +struct lib_ring_buffer *ustctl_open_stream_read(struct shm_handle *handle, + int cpu); +void ustctl_close_stream_read(struct shm_handle *handle, + struct lib_ring_buffer *buf); + /* For mmap mode, readable without "get" operation */ int ustctl_get_mmap_len(struct shm_handle *handle, struct lib_ring_buffer *buf, diff --git a/libustctl/ustctl.c b/libustctl/ustctl.c index 581de965..abe6d034 100644 --- a/libustctl/ustctl.c +++ b/libustctl/ustctl.c @@ -452,6 +452,31 @@ void ustctl_unmap_channel(struct shm_handle *handle) channel_destroy(chan, handle, 1); } +struct lib_ring_buffer *ustctl_open_stream_read(struct shm_handle *handle, + int cpu) +{ + struct channel *chan = handle->shadow_chan; + int shm_fd, wait_fd; + uint64_t memory_map_size; + struct lib_ring_buffer *buf; + int ret; + + buf = channel_get_ring_buffer(&chan->backend.config, + chan, cpu, handle, &shm_fd, &wait_fd, &memory_map_size); + if (!buf) + return NULL; + ret = lib_ring_buffer_open_read(buf, handle, 1); + if (ret) + return NULL; + return buf; +} + +void ustctl_close_stream_read(struct shm_handle *handle, + struct lib_ring_buffer *buf) +{ + lib_ring_buffer_release_read(buf, handle, 1); +} + /* For mmap mode, readable without "get" operation */ /* returns the length to mmap. */