X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fkernel-consumer%2Fkernel-consumer.c;h=5464822aaa58678377869a30d7c8bd9dbae1c6ba;hb=6e5e3c512dd7c4ead8ce89bff2de1a56a6d5e360;hp=46a9f52c0ac2406787f2743213da3380b2a503d4;hpb=091441eb540f7fe6cf23658d232cbec7a385f867;p=lttng-tools.git diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 46a9f52c0..5464822aa 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -403,16 +403,12 @@ static int lttng_kconsumer_snapshot_metadata( ret_read = lttng_consumer_read_subbuffer(metadata_stream, ctx, true); if (ret_read < 0) { - if (ret_read != -EAGAIN) { - ERR("Kernel snapshot reading metadata subbuffer (ret: %zd)", - ret_read); - ret = ret_read; - goto error_snapshot; - } - /* ret_read is negative at this point so we will exit the loop. */ - continue; + ERR("Kernel snapshot reading metadata subbuffer (ret: %zd)", + ret_read); + ret = ret_read; + goto error_snapshot; } - } while (ret_read >= 0); + } while (ret_read > 0); if (use_relayd) { close_relayd_stream(metadata_stream); @@ -1594,6 +1590,17 @@ int get_subbuffer_common(struct lttng_consumer_stream *stream, ret = kernctl_get_next_subbuf(stream->wait_fd); if (ret) { + /* + * The caller only expects -ENODATA when there is no data to + * read, but the kernel tracer returns -EAGAIN when there is + * currently no data for a non-finalized stream, and -ENODATA + * when there is no data for a finalized stream. Those can be + * combined into a -ENODATA return value. + */ + if (ret == -EAGAIN) { + ret = -ENODATA; + } + goto end; } @@ -1675,6 +1682,16 @@ int get_next_subbuffer_metadata_check(struct lttng_consumer_stream *stream, subbuffer->info.metadata.padded_subbuf_size, coherent ? "true" : "false"); end: + /* + * The caller only expects -ENODATA when there is no data to read, but + * the kernel tracer returns -EAGAIN when there is currently no data + * for a non-finalized stream, and -ENODATA when there is no data for a + * finalized stream. Those can be combined into a -ENODATA return value. + */ + if (ret == -EAGAIN) { + ret = -ENODATA; + } + return ret; }