X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fconsumer.c;h=4bd9d80abc5655283435fa34473ddbb0215eda5b;hp=d282f59c9266e1b22fc0aa581576c8e30d3fd32d;hb=26c468bba13ead8ab3fd8b28c7371a399fae0f31;hpb=a2814ea7573bf5edd5323d6f89c48ff14105db69 diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index d282f59c9..4bd9d80ab 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -93,7 +93,8 @@ error: * * Return 0 on success else a negative value on error. */ -int consumer_socket_send(struct consumer_socket *socket, void *msg, size_t len) +int consumer_socket_send( + struct consumer_socket *socket, const void *msg, size_t len) { int fd; ssize_t size; @@ -861,7 +862,7 @@ error: * The consumer socket lock must be held by the caller. */ int consumer_send_msg(struct consumer_socket *sock, - struct lttcomm_consumer_msg *msg) + const struct lttcomm_consumer_msg *msg) { int ret; @@ -937,19 +938,19 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, { assert(msg); - /* Zeroed structure */ + /* Zeroed structure */ memset(msg, 0, sizeof(struct lttcomm_consumer_msg)); msg->u.ask_channel.buffer_credentials.uid = UINT32_MAX; msg->u.ask_channel.buffer_credentials.gid = UINT32_MAX; - if (trace_chunk) { + if (trace_chunk) { uint64_t chunk_id; enum lttng_trace_chunk_status chunk_status; chunk_status = lttng_trace_chunk_get_id(trace_chunk, &chunk_id); assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK); LTTNG_OPTIONAL_SET(&msg->u.ask_channel.chunk_id, chunk_id); - } + } msg->u.ask_channel.buffer_credentials.uid = buffer_credentials->uid; msg->u.ask_channel.buffer_credentials.gid = buffer_credentials->gid; @@ -1025,14 +1026,14 @@ void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg, /* Zeroed structure */ memset(msg, 0, sizeof(struct lttcomm_consumer_msg)); - if (trace_chunk) { + if (trace_chunk) { uint64_t chunk_id; enum lttng_trace_chunk_status chunk_status; chunk_status = lttng_trace_chunk_get_id(trace_chunk, &chunk_id); assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK); LTTNG_OPTIONAL_SET(&msg->u.channel.chunk_id, chunk_id); - } + } /* Send channel */ msg->cmd_type = LTTNG_CONSUMER_ADD_CHANNEL; @@ -1721,6 +1722,32 @@ error: return ret; } +int consumer_open_channel_packets(struct consumer_socket *socket, uint64_t key) +{ + int ret; + const struct lttcomm_consumer_msg msg = { + .cmd_type = LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS, + .u.open_channel_packets.key = key, + }; + + assert(socket); + + DBG("Consumer open channel packets: channel key = %" PRIu64, key); + + health_code_update(); + + pthread_mutex_lock(socket->lock); + ret = consumer_send_msg(socket, &msg); + pthread_mutex_unlock(socket->lock); + if (ret < 0) { + goto error_socket; + } + +error_socket: + health_code_update(); + return ret; +} + int consumer_clear_channel(struct consumer_socket *socket, uint64_t key) { int ret;