X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-consumer.c;h=9a577b61671aa8c04e2aec286ce56e0e20d0c7f8;hb=6684bfa4a76f566ff024d4f2159f59f2e783d8c2;hp=63381cea4df702a4bf998702fdbead9429fd8275;hpb=990570edd474b304d4c935d82be6201d872025e4;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 63381cea4..9a577b616 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2011 - David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; only version 2 of the License. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _GNU_SOURCE @@ -22,11 +22,10 @@ #include #include -#include #include +#include #include #include -#include #include "ust-consumer.h" @@ -37,7 +36,7 @@ static int send_channel_streams(int sock, struct ust_app_channel *uchan, uid_t uid, gid_t gid) { - int ret, fd; + int ret; struct lttcomm_consumer_msg lum; struct ltt_ust_stream *stream, *tmp; @@ -59,18 +58,20 @@ static int send_channel_streams(int sock, DBG("Sending channel %d to consumer", lum.u.channel.channel_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer channel"); + PERROR("send consumer channel"); goto error; } - fd = uchan->obj->shm_fd; - ret = lttcomm_send_fds_unix_sock(sock, &fd, 1); + + DBG("Sending channel shm path: %s\n", uchan->obj->shm_path); + ret = lttcomm_send_string(sock, + uchan->obj->shm_path, + strlen(uchan->obj->shm_path)); if (ret < 0) { - perror("send consumer channel ancillary data"); + PERROR("send consumer channel shm path"); goto error; } cds_list_for_each_entry_safe(stream, tmp, &uchan->streams.head, list) { - int fds[2]; if (!stream->obj->shm_fd) { continue; @@ -92,15 +93,26 @@ static int send_channel_streams(int sock, DBG("Sending stream %d to consumer", lum.u.stream.stream_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer stream"); + PERROR("send consumer stream"); + goto error; + } + + DBG("Sending stream shm path: %s\n", stream->obj->shm_path); + ret = lttcomm_send_string(sock, + stream->obj->shm_path, + strlen(stream->obj->shm_path)); + if (ret < 0) { + PERROR("send consumer stream shm path"); goto error; } - fds[0] = stream->obj->shm_fd; - fds[1] = stream->obj->wait_fd; - ret = lttcomm_send_fds_unix_sock(sock, fds, 2); + DBG("Sending stream wait pipe path: %s\n", stream->obj->wait_pipe_path); + ret = lttcomm_send_string(sock, + stream->obj->wait_pipe_path, + strlen(stream->obj->wait_pipe_path)); + if (ret < 0) { - perror("send consumer stream ancillary data"); + PERROR("send consumer stream wait pipe path"); goto error; } } @@ -132,9 +144,6 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) } if (usess->metadata->obj->shm_fd != 0) { - int fd; - int fds[2]; - /* Send metadata channel fd */ lum.cmd_type = LTTNG_CONSUMER_ADD_CHANNEL; lum.u.channel.channel_key = usess->metadata->obj->shm_fd; @@ -143,13 +152,16 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) DBG("Sending metadata channel %d to consumer", lum.u.channel.channel_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer channel"); + PERROR("send consumer channel"); goto error; } - fd = usess->metadata->obj->shm_fd; - ret = lttcomm_send_fds_unix_sock(sock, &fd, 1); + + DBG("Sending metadata channel shm path: %s\n", usess->metadata->obj->shm_path); + ret = lttcomm_send_string(sock, + usess->metadata->obj->shm_path, + strlen(usess->metadata->obj->shm_path)); if (ret < 0) { - perror("send consumer metadata channel"); + PERROR("send consumer metadata channel"); goto error; } @@ -167,22 +179,46 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) DBG("Sending metadata stream %d to consumer", lum.u.stream.stream_key); ret = lttcomm_send_unix_sock(sock, &lum, sizeof(lum)); if (ret < 0) { - perror("send consumer metadata stream"); + PERROR("send consumer metadata stream"); goto error; } - fds[0] = usess->metadata->stream_obj->shm_fd; - fds[1] = usess->metadata->stream_obj->wait_fd; - ret = lttcomm_send_fds_unix_sock(sock, fds, 2); + + DBG("Sending metadata stream shm path: %s\n", + usess->metadata->stream_obj->shm_path); + ret = lttcomm_send_string(sock, + usess->metadata->stream_obj->shm_path, + strlen(usess->metadata->stream_obj->shm_path)); + if (ret < 0) { - perror("send consumer stream"); + PERROR("send consumer shm stream"); goto error; } + + DBG("Sending metadata stream wait pipe path: %s\n", + usess->metadata->stream_obj->wait_pipe_path); + ret = lttcomm_send_string(sock, + usess->metadata->stream_obj->wait_pipe_path, + strlen(usess->metadata->stream_obj->wait_pipe_path)); + + if (ret < 0) { + PERROR("send consumer shm stream"); + goto error; + } + } /* Send each channel fd streams of session */ rcu_read_lock(); cds_lfht_for_each_entry(usess->channels->ht, &iter.iter, ua_chan, node.node) { + /* + * Indicate that the channel was not created on the tracer side so skip + * sending unexisting streams. + */ + if (ua_chan->obj == NULL) { + continue; + } + ret = send_channel_streams(sock, ua_chan, usess->uid, usess->gid); if (ret < 0) { rcu_read_unlock();