/*
* Send all stream fds of UST channel to the consumer.
*/
-int ust_consumer_send_channel_streams(int sock,
+static int send_channel_streams(int sock,
struct ust_app_channel *uchan, struct ust_app_session *usess,
struct consumer_output *consumer)
{
/* Get the right path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
/* Set application path to the destination path */
- ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
- consumer->dst.trace_path, usess->path);
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s/%s",
+ consumer->dst.trace_path, consumer->subdir, usess->path);
if (ret < 0) {
PERROR("snprintf stream path");
goto error;
/*
* Sending metadata to the consumer with command ADD_CHANNEL and ADD_STREAM.
*/
-int ust_consumer_send_metadata(int sock, struct ust_app_session *usess,
+static int send_metadata(int sock, struct ust_app_session *usess,
struct consumer_output *consumer)
{
int ret, fd, fds[2];
/* Get correct path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
/* Set application path to the destination path */
- ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
- consumer->dst.trace_path, usess->path);
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s/%s",
+ consumer->dst.trace_path, consumer->subdir, usess->path);
if (ret < 0) {
PERROR("snprintf stream path");
goto error;
/*
* Send all stream fds of the UST session to the consumer.
*/
-int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess,
- struct consumer_output *consumer)
+int ust_consumer_send_session(struct ust_app_session *usess,
+ struct consumer_output *consumer, struct consumer_socket *sock)
{
int ret = 0;
- int sock = consumer_fd;
struct lttng_ht_iter iter;
struct ust_app_channel *ua_chan;
- DBG("Sending metadata stream fd");
+ assert(usess);
- if (consumer_fd < 0) {
- ERR("Consumer has negative file descriptor");
- return -EINVAL;
+ if (consumer == NULL || sock == NULL) {
+ /* There is no consumer so just ignoring the command. */
+ DBG("UST consumer does not exist. Not sending streams");
+ return 0;
}
+ DBG("Sending metadata stream fd to consumer on %d", sock->fd);
+
+ pthread_mutex_lock(sock->lock);
+
/* Sending metadata information to the consumer */
- ret = ust_consumer_send_metadata(consumer_fd, usess, consumer);
+ ret = send_metadata(sock->fd, usess, consumer);
if (ret < 0) {
goto error;
}
continue;
}
- ret = ust_consumer_send_channel_streams(sock, ua_chan, usess, consumer);
+ ret = send_channel_streams(sock->fd, ua_chan, usess, consumer);
if (ret < 0) {
rcu_read_unlock();
goto error;
DBG("consumer fds (metadata and channel streams) sent");
- return 0;
+ /* All good! */
+ ret = 0;
error:
+ pthread_mutex_unlock(sock->lock);
return ret;
}