X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer%2Fconsumer-stream.c;h=fb878d72cabb6a56e4ff5a8a0d0303062a99d165;hp=deebb58fe41b321cb5f41a76e4ee771c1b5ced4d;hb=577eea73132dee4da47752590ed535206678eb34;hpb=f5ba75b4f0c0b44092c76bc931b25b24a2e62718 diff --git a/src/common/consumer/consumer-stream.c b/src/common/consumer/consumer-stream.c index deebb58fe..fb878d72c 100644 --- a/src/common/consumer/consumer-stream.c +++ b/src/common/consumer/consumer-stream.c @@ -69,8 +69,7 @@ static int consumer_stream_update_stats(struct lttng_consumer_stream *stream, { int ret = 0; uint64_t sequence_number; - const uint64_t discarded_events = - LTTNG_OPTIONAL_GET(subbuf->info.data.sequence_number); + const uint64_t discarded_events = subbuf->info.data.events_discarded; if (!subbuf->info.data.sequence_number.is_set) { /* Command not supported by the tracer. */ @@ -197,6 +196,7 @@ static int do_sync_metadata(struct lttng_consumer_stream *metadata, struct lttng_consumer_local_data *ctx) { int ret; + enum sync_metadata_status status; assert(metadata); assert(metadata->metadata_flag); @@ -244,7 +244,7 @@ static int do_sync_metadata(struct lttng_consumer_stream *metadata, /* * Empty the metadata cache and flush the current stream. */ - ret = lttng_kconsumer_sync_metadata(metadata); + status = lttng_kconsumer_sync_metadata(metadata); break; case LTTNG_CONSUMER32_UST: case LTTNG_CONSUMER64_UST: @@ -252,18 +252,23 @@ static int do_sync_metadata(struct lttng_consumer_stream *metadata, * Ask the sessiond if we have new metadata waiting and update the * consumer metadata cache. */ - ret = lttng_ustconsumer_sync_metadata(ctx, metadata); + status = lttng_ustconsumer_sync_metadata(ctx, metadata); break; default: - assert(0); - ret = -1; - break; + abort(); } - /* - * Error or no new metadata, we exit here. - */ - if (ret <= 0 || ret == ENODATA) { + + switch (status) { + case SYNC_METADATA_STATUS_NEW_DATA: + break; + case SYNC_METADATA_STATUS_NO_DATA: + ret = 0; + goto end_unlock_mutex; + case SYNC_METADATA_STATUS_ERROR: + ret = -1; goto end_unlock_mutex; + default: + abort(); } /* @@ -285,7 +290,7 @@ static int do_sync_metadata(struct lttng_consumer_stream *metadata, */ pthread_cond_wait(&metadata->metadata_rdv, &metadata->metadata_rdv_lock); pthread_mutex_unlock(&metadata->metadata_rdv_lock); - } while (ret == EAGAIN); + } while (status == SYNC_METADATA_STATUS_NEW_DATA); /* Success */ return 0; @@ -393,12 +398,8 @@ int metadata_stream_check_version(struct lttng_consumer_stream *stream, } DBG("New metadata version detected"); - stream->metadata_version = subbuffer->info.metadata.version; - stream->reset_metadata_flag = 1; - - if (stream->metadata_bucket) { - metadata_bucket_reset(stream->metadata_bucket); - } + consumer_stream_metadata_set_version(stream, + subbuffer->info.metadata.version); if (stream->read_subbuffer_ops.reset_metadata) { stream->read_subbuffer_ops.reset_metadata(stream); @@ -1053,3 +1054,15 @@ int consumer_stream_enable_metadata_bucketization( end: return ret; } + +void consumer_stream_metadata_set_version( + struct lttng_consumer_stream *stream, uint64_t new_version) +{ + assert(new_version > stream->metadata_version); + stream->metadata_version = new_version; + stream->reset_metadata_flag = 1; + + if (stream->metadata_bucket) { + metadata_bucket_reset(stream->metadata_bucket); + } +}