X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust-ctl%2Fustctl.c;h=28dee5e9cdf80118113f53522dc296460f66b1af;hb=3ef94b0eba0a0ed8c8552e0284d4084f98be475f;hp=67aae68294fdfcf64782fe291568e14f5b3d3544;hpb=34a91bdb42a2a3b01b687ab5e1ba7638401e6dfc;p=lttng-ust.git diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index 67aae682..28dee5e9 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -63,10 +63,14 @@ struct ustctl_consumer_stream { }; extern void lttng_ring_buffer_client_overwrite_init(void); +extern void lttng_ring_buffer_client_overwrite_rt_init(void); extern void lttng_ring_buffer_client_discard_init(void); +extern void lttng_ring_buffer_client_discard_rt_init(void); extern void lttng_ring_buffer_metadata_client_init(void); extern void lttng_ring_buffer_client_overwrite_exit(void); +extern void lttng_ring_buffer_client_overwrite_rt_exit(void); extern void lttng_ring_buffer_client_discard_exit(void); +extern void lttng_ring_buffer_client_discard_rt_exit(void); extern void lttng_ring_buffer_metadata_client_exit(void); volatile enum ust_loglevel ust_loglevel; @@ -752,9 +756,7 @@ int ustctl_send_channel_to_ust(int sock, int session_handle, return ret; ret = ustcomm_recv_app_reply(sock, &lur, lum.handle, lum.cmd); if (!ret) { - if (lur.ret_val >= 0) { - channel_data->handle = lur.ret_val; - } + channel_data->handle = lur.ret_val; } return ret; } @@ -958,7 +960,7 @@ struct ustctl_consumer_channel * attr->subbuf_size, attr->num_subbuf, attr->switch_timer_interval, attr->read_timer_interval, - attr->uuid); + attr->uuid, attr->chan_id); if (!chan->chan) { goto chan_error; } @@ -1052,6 +1054,40 @@ end: return ret; } +/* + * Write at most one packet in the channel. + * Returns the number of bytes written on success, < 0 on error. + */ +ssize_t ustctl_write_one_packet_to_channel( + struct ustctl_consumer_channel *channel, + const char *metadata_str, /* NOT null-terminated */ + size_t len) /* metadata length */ +{ + struct lttng_ust_lib_ring_buffer_ctx ctx; + struct lttng_channel *chan = 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), + len); + lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, + sizeof(char), -1, chan->handle); + ret = chan->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); + +end: + return reserve_len; +} + int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan) { struct channel *chan; @@ -1576,7 +1612,7 @@ int ustctl_recv_register_event(int sock, goto signature_error; } /* Enforce end of string */ - signature[signature_len - 1] = '\0'; + a_sign[signature_len - 1] = '\0'; /* recv fields */ if (fields_len) {