X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Fust-consumer.c;h=df569368ae04f2e8faafb1b9ebbfde069fc618aa;hp=444ff6eeea9f6b79c1c93259890927b52a27bf28;hb=ba7f0ae55f6209514025bb538c6fe3faefc32f4b;hpb=5af2f756eb72d460d304318550afc782279452b9 diff --git a/lttng-sessiond/ust-consumer.c b/lttng-sessiond/ust-consumer.c index 444ff6eee..df569368a 100644 --- a/lttng-sessiond/ust-consumer.c +++ b/lttng-sessiond/ust-consumer.c @@ -38,7 +38,7 @@ static int send_channel_streams(int sock, { int ret, fd; struct lttcomm_consumer_msg lum; - struct ltt_ust_stream *stream; + struct ltt_ust_stream *stream, *tmp; DBG("Sending streams of channel %s to UST consumer", uchan->name); @@ -65,7 +65,7 @@ static int send_channel_streams(int sock, goto error; } - cds_list_for_each_entry(stream, &uchan->streams.head, list) { + cds_list_for_each_entry_safe(stream, tmp, &uchan->streams.head, list) { int fds[2]; if (!stream->obj->shm_fd) { @@ -75,7 +75,11 @@ static int send_channel_streams(int sock, lum.u.stream.channel_key = uchan->obj->shm_fd; lum.u.stream.stream_key = stream->obj->shm_fd; lum.u.stream.state = LTTNG_CONSUMER_ACTIVE_STREAM; - lum.u.stream.output = uchan->attr.output; + /* + * FIXME Hack alert! we force MMAP for now. Mixup + * between EVENT and UST enums elsewhere. + */ + lum.u.stream.output = DEFAULT_UST_CHANNEL_OUTPUT; lum.u.stream.mmap_len = stream->obj->memory_map_size; strncpy(lum.u.stream.path_name, stream->pathname, PATH_MAX - 1); lum.u.stream.path_name[PATH_MAX - 1] = '\0'; @@ -93,7 +97,18 @@ static int send_channel_streams(int sock, perror("send consumer stream ancillary data"); goto error; } + + /* + * We release the stream object here, as we have passed + * it to the consumer. + */ + /* Ensure we don't let the app know (sock = -1). */ + ustctl_release_object(-1, stream->obj); + cds_list_del(&stream->list); + free(stream); } + /* Ensure we don't let the app know (sock = -1). */ + ustctl_release_object(-1, uchan->obj); DBG("consumer channel streams sent"); @@ -161,6 +176,10 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) perror("send consumer stream"); goto error; } + /* Metadata fds passed to consumer, release them. */ + /* Ensure we don't let the app know (sock = -1). */ + ustctl_release_object(-1, usess->metadata->stream_obj); + ustctl_release_object(-1, usess->metadata->obj); } /* Send each channel fd streams of session */ @@ -171,6 +190,7 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess) ret = send_channel_streams(sock, uchan); if (ret < 0) { + rcu_read_unlock(); goto error; } hashtable_get_next(usess->channels, &iter);