X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=6e99a7f52d0d24ac1473db3f1c2bf12880a8df78;hb=f82d9449a304561c5914b2c5f9471a640ca99248;hp=94a0cc3efb1d557da732ed9a201848b0ee4dc3e4;hpb=774d490c42598710944f54a53d81d1cab2a1dfaa;p=lttng-tools.git diff --git a/src/common/consumer.c b/src/common/consumer.c index 94a0cc3ef..6e99a7f52 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1153,6 +1153,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( ctx->consumer_error_socket = -1; ctx->consumer_metadata_socket = -1; + pthread_mutex_init(&ctx->metadata_socket_lock, NULL); /* assign the callbacks */ ctx->on_buffer_ready = buffer_ready; ctx->on_recv_channel = recv_channel; @@ -1880,6 +1881,13 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, break; case LTTNG_CONSUMER32_UST: case LTTNG_CONSUMER64_UST: + if (stream->monitor) { + /* close the write-side in close_metadata */ + ret = close(stream->ust_metadata_poll_pipe[0]); + if (ret < 0) { + PERROR("Close UST metadata read-side poll pipe"); + } + } lttng_ustconsumer_del_stream(stream); break; default: @@ -2252,14 +2260,21 @@ restart: DBG("Metadata available on fd %d", pollfd); assert(stream->wait_fd == pollfd); - len = ctx->on_buffer_ready(stream, ctx); + do { + len = ctx->on_buffer_ready(stream, ctx); + /* + * We don't check the return value here since if we get + * a negative len, it means an error occured thus we + * simply remove it from the poll set and free the + * stream. + */ + } while (len > 0); + /* It's ok to have an unavailable sub-buffer */ if (len < 0 && len != -EAGAIN && len != -ENODATA) { /* Clean up stream from consumer and free it. */ lttng_poll_del(&events, stream->wait_fd); consumer_del_metadata_stream(stream, metadata_ht); - } else if (len > 0) { - stream->data_read = 1; } }