projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: handle new streams in get_data_packet()
[babeltrace.git]
/
formats
/
lttng-live
/
lttng-live-comm.c
diff --git
a/formats/lttng-live/lttng-live-comm.c
b/formats/lttng-live/lttng-live-comm.c
index 8e701b2100ebadf1c2136bc7323a1814c29b737b..945df4317bdec9d0ca1aa324405f110d229d8143 100644
(file)
--- a/
formats/lttng-live/lttng-live-comm.c
+++ b/
formats/lttng-live/lttng-live-comm.c
@@
-33,6
+33,7
@@
#include <inttypes.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <inttypes.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <poll.h>
#include <babeltrace/ctf/ctf-index.h>
#include <babeltrace/ctf/ctf-index.h>
@@
-54,6
+55,8
@@
#include "lttng-live.h"
#include "lttng-viewer-abi.h"
#include "lttng-live.h"
#include "lttng-viewer-abi.h"
+#define ACTIVE_POLL_DELAY 100 /* ms */
+
/*
* Memory allocation zeroed
*/
/*
* Memory allocation zeroed
*/
@@
-586,10
+589,12
@@
int append_metadata(struct lttng_live_ctx *ctx,
ret = ctf_append_trace_metadata(
viewer_stream->ctf_trace->handle->td,
metadata->ctf_trace->metadata_fp);
ret = ctf_append_trace_metadata(
viewer_stream->ctf_trace->handle->td,
metadata->ctf_trace->metadata_fp);
- if (ret != 0) {
+ /* We accept empty metadata packets */
+ if (ret != 0 && ret != -ENOENT) {
fprintf(stderr, "[error] Appending metadata\n");
goto error;
}
fprintf(stderr, "[error] Appending metadata\n");
goto error;
}
+ ret = 0;
error:
return ret;
error:
return ret;
@@
-671,15
+676,19
@@
retry:
ret = append_metadata(ctx, stream);
if (ret)
goto error;
ret = append_metadata(ctx, stream);
if (ret)
goto error;
- goto retry;
}
if (rp.flags & LTTNG_VIEWER_FLAG_NEW_STREAM) {
}
if (rp.flags & LTTNG_VIEWER_FLAG_NEW_STREAM) {
+ printf_verbose("get_data_packet: new streams needed\n");
ret = ask_new_streams(ctx);
if (ret < 0)
goto error;
g_hash_table_foreach(ctx->session->ctf_traces, add_traces,
ctx->bt_ctx);
}
ret = ask_new_streams(ctx);
if (ret < 0)
goto error;
g_hash_table_foreach(ctx->session->ctf_traces, add_traces,
ctx->bt_ctx);
}
+ if (rp.flags & (LTTNG_VIEWER_FLAG_NEW_METADATA
+ | LTTNG_VIEWER_FLAG_NEW_STREAM)) {
+ goto retry;
+ }
fprintf(stderr, "[error] get_data_packet: error\n");
ret = -1;
goto end;
fprintf(stderr, "[error] get_data_packet: error\n");
ret = -1;
goto end;
@@
-740,7
+749,7
@@
retry:
goto error;
}
assert(ret_len == len);
goto error;
}
assert(ret_len == len);
-
+ ret = 0;
end:
error:
return ret;
end:
error:
return ret;
@@
-893,6
+902,9
@@
int get_new_metadata(struct lttng_live_ctx *ctx,
if (ret > 0) {
len_read += ret;
}
if (ret > 0) {
len_read += ret;
}
+ if (!len_read) {
+ (void) poll(NULL, 0, ACTIVE_POLL_DELAY);
+ }
} while (ret > 0 || !len_read);
if (fclose(metadata_stream->metadata_fp_write))
} while (ret > 0 || !len_read);
if (fclose(metadata_stream->metadata_fp_write))
@@
-989,7
+1001,7
@@
retry:
break;
case LTTNG_VIEWER_INDEX_RETRY:
printf_verbose("get_next_index: retry\n");
break;
case LTTNG_VIEWER_INDEX_RETRY:
printf_verbose("get_next_index: retry\n");
-
sleep(1
);
+
(void) poll(NULL, 0, ACTIVE_POLL_DELAY
);
goto retry;
case LTTNG_VIEWER_INDEX_HUP:
printf_verbose("get_next_index: stream hung up\n");
goto retry;
case LTTNG_VIEWER_INDEX_HUP:
printf_verbose("get_next_index: stream hung up\n");
@@
-1488,6
+1500,8
@@
void lttng_live_read(struct lttng_live_ctx *ctx)
ret = ask_new_streams(ctx);
if (ret < 0)
goto end_free;
ret = ask_new_streams(ctx);
if (ret < 0)
goto end_free;
+ if (!ctx->session->stream_count)
+ (void) poll(NULL, 0, ACTIVE_POLL_DELAY);
}
g_hash_table_foreach(ctx->session->ctf_traces, add_traces,
}
g_hash_table_foreach(ctx->session->ctf_traces, add_traces,
This page took
0.028924 seconds
and
4
git commands to generate.