goto end;
}
- if (reply.ret_code == LTTNG_OK) {
+ if (reply.ret_code == LTTCOMM_CONSUMERD_SUCCESS) {
/* All good. */
ret = 0;
} else {
}
/* An error is possible so don't touch the key and stream_count. */
- if (reply.ret_code != LTTNG_OK) {
+ if (reply.ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
ret = -1;
goto end;
}
*key = reply.key;
*stream_count = reply.stream_count;
+ ret = 0;
end:
return ret;
struct ust_app_channel *ua_chan, struct consumer_output *consumer,
struct consumer_socket *socket, struct ust_registry_session *registry)
{
- int ret;
+ int ret, output;
uint32_t chan_id;
uint64_t key, chan_reg_key;
char *pathname = NULL;
chan_id = chan_reg->chan_id;
}
+ switch (ua_chan->attr.output) {
+ case LTTNG_UST_MMAP:
+ default:
+ output = LTTNG_EVENT_MMAP;
+ break;
+ }
+
consumer_init_ask_channel_comm_msg(&msg,
ua_chan->attr.subbuf_size,
ua_chan->attr.num_subbuf,
ua_chan->attr.overwrite,
ua_chan->attr.switch_timer_interval,
ua_chan->attr.read_timer_interval,
- (int) ua_chan->attr.output,
+ output,
(int) ua_chan->attr.type,
ua_sess->tracing_id,
pathname,
channel->uid = uid;
channel->gid = gid;
channel->relayd_id = relayd_id;
- channel->output = output;
channel->tracefile_size = tracefile_size;
channel->tracefile_count = tracefile_count;
channel->monitor = monitor;
pthread_mutex_init(&channel->lock, NULL);
pthread_mutex_init(&channel->timer_lock, NULL);
+ switch (output) {
+ case LTTNG_EVENT_SPLICE:
+ channel->output = CONSUMER_CHANNEL_SPLICE;
+ break;
+ case LTTNG_EVENT_MMAP:
+ channel->output = CONSUMER_CHANNEL_MMAP;
+ break;
+ default:
+ assert(0);
+ free(channel);
+ channel = NULL;
+ goto end;
+ }
+
/*
* In monitor mode, the streams associated with the channel will be put in
* a special list ONLY owned by this channel. So, the refcount is set to 1
struct lttcomm_relayd_sock *relayd_sock, uint64_t sessiond_id)
{
int fd = -1, ret = -1, relayd_created = 0;
- enum lttng_error_code ret_code = LTTNG_OK;
+ enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct consumer_relayd_sock_pair *relayd = NULL;
assert(ctx);
}
/* First send a status message before receiving the fds. */
- ret = consumer_send_status_msg(sock, LTTNG_OK);
+ ret = consumer_send_status_msg(sock, LTTCOMM_CONSUMERD_SUCCESS);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_FATAL);
assert(sock >= 0);
if (!channel) {
- msg.ret_code = -LTTNG_ERR_UST_CHAN_FAIL;
+ msg.ret_code = LTTCOMM_CONSUMERD_CHANNEL_FAIL;
} else {
- msg.ret_code = LTTNG_OK;
+ msg.ret_code = LTTCOMM_CONSUMERD_SUCCESS;
msg.key = channel->key;
msg.stream_count = channel->streams.count;
}
int sock, struct pollfd *consumer_sockpoll)
{
ssize_t ret;
- enum lttng_error_code ret_code = LTTNG_OK;
+ enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttcomm_consumer_msg msg;
ret = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg));
/* Somehow, the session daemon is not responding anymore. */
goto error_fatal;
}
- if (ret_code != LTTNG_OK) {
+
+ if (ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
/* Channel was not found. */
goto end_nosignal;
}
* lttcomm error code.
*/
enum lttcomm_return_code {
+ LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 1, /* Command socket ready */
LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */
LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */
LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
+ LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
/* MUST be last element */
LTTCOMM_NR, /* Last element */
* Status message returned to the sessiond after a received command.
*/
struct lttcomm_consumer_status_msg {
- enum lttng_error_code ret_code;
+ enum lttcomm_return_code ret_code;
} LTTNG_PACKED;
struct lttcomm_consumer_status_channel {
- enum lttng_error_code ret_code;
+ enum lttcomm_return_code ret_code;
uint64_t key;
unsigned int stream_count;
} LTTNG_PACKED;
struct lttng_consumer_channel *channel,
struct lttng_consumer_local_data *ctx, int *relayd_error)
{
- int ret, ret_code = LTTNG_OK;
+ int ret, ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttng_consumer_stream *stream;
assert(channel);
/* Inform sessiond that we are about to send channel and streams. */
ret = consumer_send_status_msg(sock, ret_code);
- if (ret < 0 || ret_code != LTTNG_OK) {
+ if (ret < 0 || ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
/*
* Either the session daemon is not responding or the relayd died so we
* stop now.
return 0;
error:
- if (ret_code != LTTNG_OK) {
+ if (ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
ret = -1;
}
return ret;
*/
static int _close_metadata(struct lttng_consumer_channel *channel)
{
- int ret = LTTNG_OK;
+ int ret = LTTCOMM_CONSUMERD_SUCCESS;
assert(channel);
assert(channel->type == CONSUMER_CHANNEL_TYPE_METADATA);
uint64_t len, struct lttng_consumer_channel *channel,
int timer)
{
- int ret, ret_code = LTTNG_OK;
+ int ret, ret_code = LTTCOMM_CONSUMERD_SUCCESS;
char *metadata_str;
DBG("UST consumer push metadata key %" PRIu64 " of len %" PRIu64, key, len);
int sock, struct pollfd *consumer_sockpoll)
{
ssize_t ret;
- enum lttng_error_code ret_code = LTTNG_OK;
+ enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttcomm_consumer_msg msg;
struct lttng_consumer_channel *channel = NULL;
attr.switch_timer_interval = msg.u.ask_channel.switch_timer_interval;
attr.read_timer_interval = msg.u.ask_channel.read_timer_interval;
attr.chan_id = msg.u.ask_channel.chan_id;
- attr.output = msg.u.ask_channel.output;
memcpy(attr.uuid, msg.u.ask_channel.uuid, sizeof(attr.uuid));
+ /* Match channel buffer type to the UST abi. */
+ switch (msg.u.ask_channel.output) {
+ case LTTNG_EVENT_MMAP:
+ default:
+ attr.output = LTTNG_UST_MMAP;
+ break;
+ }
+
/* Translate and save channel type. */
switch (msg.u.ask_channel.type) {
case LTTNG_UST_CHAN_PER_CPU:
}
/* Tell session daemon we are ready to receive the metadata. */
- ret = consumer_send_status_msg(sock, LTTNG_OK);
+ ret = consumer_send_status_msg(sock, LTTCOMM_CONSUMERD_SUCCESS);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
goto error_fatal;
{
struct lttcomm_metadata_request_msg request;
struct lttcomm_consumer_msg msg;
- enum lttng_error_code ret_code = LTTNG_OK;
+ enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
uint64_t len, key, offset;
int ret;
/* Tell session daemon we are ready to receive the metadata. */
ret = consumer_send_status_msg(ctx->consumer_metadata_socket,
- LTTNG_OK);
+ LTTCOMM_CONSUMERD_SUCCESS);
if (ret < 0 || len == 0) {
/*
* Somehow, the session daemon is not responding anymore or there is