X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust-ctl%2Fustctl.c;h=0a76437d8eb93871b3f33c33cdf46fdba1ea1262;hb=3b5babf8592ca27acaf01fca24406922fc5cc89c;hp=5fd54df82f62e03ad739dacf977177ac6fb01109;hpb=65c48d6a4b532436c000f8b3b9b771cfe9c07491;p=lttng-ust.git diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index 5fd54df8..0a76437d 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -45,7 +45,7 @@ * Channel representation within consumer. */ struct ustctl_consumer_channel { - struct lttng_channel *chan; /* lttng channel buffers */ + struct lttng_ust_channel_buffer *chan; /* lttng channel buffers */ /* initial attributes */ struct ustctl_consumer_channel_attr attr; @@ -587,9 +587,10 @@ int ustctl_create_event_notifier(int sock, struct lttng_ust_abi_event_notifier * free(event_notifier_data); return ret; } - /* Send struct lttng_ust_event_notifier */ + /* Send struct lttng_ust_abi_event_notifier */ len = ustcomm_send_unix_sock(sock, event_notifier, sizeof(*event_notifier)); if (len != sizeof(*event_notifier)) { + free(event_notifier_data); if (len < 0) return len; else @@ -1279,7 +1280,7 @@ struct ustctl_consumer_channel * if (!chan) return NULL; - chan->chan = transport->ops.channel_create(transport_name, NULL, + chan->chan = transport->ops.priv->channel_create(transport_name, NULL, attr->subbuf_size, attr->num_subbuf, attr->switch_timer_interval, attr->read_timer_interval, @@ -1304,7 +1305,7 @@ void ustctl_destroy_channel(struct ustctl_consumer_channel *chan) { (void) ustctl_channel_close_wait_fd(chan); (void) ustctl_channel_close_wakeup_fd(chan); - chan->chan->ops->channel_destroy(chan->chan); + chan->chan->ops->priv->channel_destroy(chan->chan); free(chan); } @@ -1313,7 +1314,7 @@ int ustctl_send_channel_to_sessiond(int sock, { struct shm_object_table *table; - table = channel->chan->handle->table; + table = channel->chan->chan->handle->table; if (table->size <= 0) return -EINVAL; return ustctl_send_channel(sock, @@ -1343,17 +1344,17 @@ int ustctl_write_metadata_to_channel( size_t len) /* metadata length */ { struct lttng_ust_lib_ring_buffer_ctx ctx; - struct lttng_channel *chan = channel->chan; + struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan; const char *str = metadata_str; int ret = 0, waitret; size_t reserve_len, pos; for (pos = 0; pos < len; pos += reserve_len) { reserve_len = min_t(size_t, - chan->ops->packet_avail_size(chan->chan, chan->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, + lttng_chan_buf->chan->handle), len - pos); - lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, - sizeof(char), -1, chan->handle); + lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len, sizeof(char)); /* * We don't care about metadata buffer's records lost * count, because we always retry here. Report error if @@ -1362,7 +1363,7 @@ int ustctl_write_metadata_to_channel( */ waitret = wait_cond_interruptible_timeout( ({ - ret = chan->ops->event_reserve(&ctx, 0); + ret = lttng_chan_buf->ops->event_reserve(&ctx, 0); ret != -ENOBUFS || !ret; }), LTTNG_METADATA_TIMEOUT_MSEC); @@ -1374,8 +1375,8 @@ int ustctl_write_metadata_to_channel( ret = waitret; goto end; } - chan->ops->event_write(&ctx, &str[pos], reserve_len); - chan->ops->event_commit(&ctx); + lttng_chan_buf->ops->event_write(&ctx, &str[pos], reserve_len); + lttng_chan_buf->ops->event_commit(&ctx); } end: return ret; @@ -1391,25 +1392,25 @@ ssize_t ustctl_write_one_packet_to_channel( size_t len) /* metadata length */ { struct lttng_ust_lib_ring_buffer_ctx ctx; - struct lttng_channel *chan = channel->chan; + struct lttng_ust_channel_buffer *lttng_chan_buf = channel->chan; const char *str = metadata_str; ssize_t reserve_len; int ret; reserve_len = min_t(ssize_t, - chan->ops->packet_avail_size(chan->chan, chan->handle), + lttng_chan_buf->ops->priv->packet_avail_size(lttng_chan_buf->chan, + lttng_chan_buf->chan->handle), len); - lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, - sizeof(char), -1, chan->handle); - ret = chan->ops->event_reserve(&ctx, 0); + lib_ring_buffer_ctx_init(&ctx, lttng_chan_buf->chan, NULL, reserve_len, sizeof(char)); + ret = lttng_chan_buf->ops->event_reserve(&ctx, 0); if (ret != 0) { DBG("LTTng: event reservation failed"); assert(ret < 0); reserve_len = ret; goto end; } - chan->ops->event_write(&ctx, str, reserve_len); - chan->ops->event_commit(&ctx); + lttng_chan_buf->ops->event_write(&ctx, str, reserve_len); + lttng_chan_buf->ops->event_commit(&ctx); end: return reserve_len; @@ -1417,7 +1418,7 @@ end: int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; int ret; chan = consumer_chan->chan->chan; @@ -1430,7 +1431,7 @@ int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan) int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; int ret; chan = consumer_chan->chan->chan; @@ -1443,7 +1444,7 @@ int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; chan = stream->chan->chan->chan; return ring_buffer_stream_close_wait_fd(&chan->backend.config, @@ -1452,7 +1453,7 @@ int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream) int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; chan = stream->chan->chan->chan; return ring_buffer_stream_close_wakeup_fd(&chan->backend.config, @@ -1465,7 +1466,7 @@ struct ustctl_consumer_stream * { struct ustctl_consumer_stream *stream; struct lttng_ust_shm_handle *handle; - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; int shm_fd, wait_fd, wakeup_fd; uint64_t memory_map_size; struct lttng_ust_lib_ring_buffer *buf; @@ -1473,7 +1474,7 @@ struct ustctl_consumer_stream * if (!channel) return NULL; - handle = channel->chan->handle; + handle = channel->chan->chan->handle; if (!handle) return NULL; @@ -1514,7 +1515,7 @@ void ustctl_destroy_stream(struct ustctl_consumer_stream *stream) consumer_chan = stream->chan; (void) ustctl_stream_close_wait_fd(stream); (void) ustctl_stream_close_wakeup_fd(stream); - lib_ring_buffer_release_read(buf, consumer_chan->chan->handle); + lib_ring_buffer_release_read(buf, consumer_chan->chan->chan->handle); free(stream); } @@ -1522,16 +1523,16 @@ int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *chan) { if (!chan) return -EINVAL; - return shm_get_wait_fd(chan->chan->handle, - &chan->chan->handle->chan._ref); + return shm_get_wait_fd(chan->chan->chan->handle, + &chan->chan->chan->handle->chan._ref); } int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *chan) { if (!chan) return -EINVAL; - return shm_get_wakeup_fd(chan->chan->handle, - &chan->chan->handle->chan._ref); + return shm_get_wakeup_fd(chan->chan->chan->handle, + &chan->chan->chan->handle->chan._ref); } int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream) @@ -1543,7 +1544,7 @@ int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - return shm_get_wait_fd(consumer_chan->chan->handle, &buf->self._ref); + return shm_get_wait_fd(consumer_chan->chan->chan->handle, &buf->self._ref); } int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream) @@ -1555,7 +1556,7 @@ int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - return shm_get_wakeup_fd(consumer_chan->chan->handle, &buf->self._ref); + return shm_get_wakeup_fd(consumer_chan->chan->chan->handle, &buf->self._ref); } /* For mmap mode, readable without "get" operation */ @@ -1569,7 +1570,7 @@ void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream) return NULL; buf = stream->buf; consumer_chan = stream->chan; - return shmp(consumer_chan->chan->handle, buf->backend.memory_map); + return shmp(consumer_chan->chan->chan->handle, buf->backend.memory_map); } /* returns the length to mmap. */ @@ -1578,7 +1579,7 @@ int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream, { struct ustctl_consumer_channel *consumer_chan; unsigned long mmap_buf_len; - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; if (!stream) return -EINVAL; @@ -1600,7 +1601,7 @@ int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; if (!stream) return -EINVAL; @@ -1619,7 +1620,7 @@ int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream, int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream, unsigned long *off) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; unsigned long sb_bindex; struct lttng_ust_lib_ring_buffer *buf; struct ustctl_consumer_channel *consumer_chan; @@ -1635,11 +1636,11 @@ int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream, return -EINVAL; sb_bindex = subbuffer_id_get_index(&chan->backend.config, buf->backend.buf_rsb.id); - barray_idx = shmp_index(consumer_chan->chan->handle, buf->backend.array, + barray_idx = shmp_index(consumer_chan->chan->chan->handle, buf->backend.array, sb_bindex); if (!barray_idx) return -EINVAL; - pages = shmp(consumer_chan->chan->handle, barray_idx->shmp); + pages = shmp(consumer_chan->chan->chan->handle, barray_idx->shmp); if (!pages) return -EINVAL; *off = pages->mmap_offset; @@ -1651,7 +1652,7 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; if (!stream) @@ -1661,7 +1662,7 @@ int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, consumer_chan = stream->chan; chan = consumer_chan->chan->chan; *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); return 0; } @@ -1670,7 +1671,7 @@ int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream, unsigned long *len) { struct ustctl_consumer_channel *consumer_chan; - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_lib_ring_buffer *buf; if (!stream) @@ -1679,7 +1680,7 @@ int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream, consumer_chan = stream->chan; chan = consumer_chan->chan->chan; *len = lib_ring_buffer_get_read_data_size(&chan->backend.config, buf, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); *len = LTTNG_UST_PAGE_ALIGN(*len); return 0; } @@ -1695,7 +1696,7 @@ int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_get_next_subbuf(buf, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); } @@ -1709,7 +1710,7 @@ int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - lib_ring_buffer_put_next_subbuf(buf, consumer_chan->chan->handle); + lib_ring_buffer_put_next_subbuf(buf, consumer_chan->chan->chan->handle); return 0; } @@ -1726,7 +1727,7 @@ int ustctl_snapshot(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot, - &buf->prod_snapshot, consumer_chan->chan->handle); + &buf->prod_snapshot, consumer_chan->chan->chan->handle); } /* @@ -1745,7 +1746,7 @@ int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream) consumer_chan = stream->chan; return lib_ring_buffer_snapshot_sample_positions(buf, &buf->cons_snapshot, &buf->prod_snapshot, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); } /* Get the consumer position (iteration start) */ @@ -1786,7 +1787,7 @@ int ustctl_get_subbuf(struct ustctl_consumer_stream *stream, buf = stream->buf; consumer_chan = stream->chan; return lib_ring_buffer_get_subbuf(buf, *pos, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); } /* Release exclusive sub-buffer access */ @@ -1799,7 +1800,7 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream) return -EINVAL; buf = stream->buf; consumer_chan = stream->chan; - lib_ring_buffer_put_subbuf(buf, consumer_chan->chan->handle); + lib_ring_buffer_put_subbuf(buf, consumer_chan->chan->chan->handle); return 0; } @@ -1814,7 +1815,7 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream, consumer_chan = stream->chan; lib_ring_buffer_switch_slow(buf, producer_active ? SWITCH_ACTIVE : SWITCH_FLUSH, - consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); } void ustctl_clear_buffer(struct ustctl_consumer_stream *stream) @@ -1826,8 +1827,8 @@ void ustctl_clear_buffer(struct ustctl_consumer_stream *stream) buf = stream->buf; consumer_chan = stream->chan; lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE, - consumer_chan->chan->handle); - lib_ring_buffer_clear_reader(buf, consumer_chan->chan->handle); + consumer_chan->chan->chan->handle); + lib_ring_buffer_clear_reader(buf, consumer_chan->chan->chan->handle); } static @@ -1835,7 +1836,7 @@ struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb( struct lttng_ust_lib_ring_buffer *buf, struct lttng_ust_shm_handle *handle) { - struct channel *chan; + struct lttng_ust_lib_ring_buffer_channel *chan; const struct lttng_ust_lib_ring_buffer_config *config; struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb; @@ -1861,7 +1862,7 @@ int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream, if (!stream || !timestamp_begin) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1878,7 +1879,7 @@ int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream, if (!stream || !timestamp_end) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1895,7 +1896,7 @@ int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream, if (!stream || !events_discarded) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1912,7 +1913,7 @@ int ustctl_get_content_size(struct ustctl_consumer_stream *stream, if (!stream || !content_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1929,7 +1930,7 @@ int ustctl_get_packet_size(struct ustctl_consumer_stream *stream, if (!stream || !packet_size) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1946,7 +1947,7 @@ int ustctl_get_stream_id(struct ustctl_consumer_stream *stream, if (!stream || !stream_id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; @@ -1963,7 +1964,7 @@ int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream, if (!stream || !ts) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb || !client_cb->current_timestamp) return -ENOSYS; @@ -1980,7 +1981,7 @@ int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream, if (!stream || !seq) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb || !client_cb->sequence_number) return -ENOSYS; @@ -1997,14 +1998,14 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream *stream, if (!stream || !id) return -EINVAL; buf = stream->buf; - handle = stream->chan->chan->handle; + handle = stream->chan->chan->chan->handle; client_cb = get_client_cb(buf, handle); if (!client_cb) return -ENOSYS; return client_cb->instance_id(buf, handle, id); } -#ifdef HAVE_PERF_EVENT +#ifdef HAVE_LINUX_PERF_EVENT_H int ustctl_has_perf_counters(void) {