From: jeremie.galarneau@efficios.com (Jérémie Galarneau)
Subject: [lttng-dev] [PATCH babeltrace] Fix: lttng-live flush when output to file
Date: Wed, 20 Apr 2016 17:03:42 -0400 [thread overview]
Message-ID: <CA+jJMxvU=rn+sw8dDCWJUoCfCnXP+cnjXurfd=uZvhOyH-qzVg@mail.gmail.com> (raw)
In-Reply-To: <1461105726-13108-1-git-send-email-mathieu.desnoyers@efficios.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4355 bytes --]
Merged in master and stable-1.3. Thanks!
Jérémie
On Tue, Apr 19, 2016 at 6:42 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> When the standard output is redirected to a file, we need to flush the
> output between each packet, otherwise the stream buffering may keep us
> from seeing events for a while in a low-throughput trace.
>
> While we are there, document that lttng-live does now support the
> --output option in babeltrace 1.x.
>
> Fixes #1010
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> doc/babeltrace.1 | 3 ++-
> formats/lttng-live/lttng-live-comm.c | 13 ++++++++++++-
> formats/lttng-live/lttng-live-plugin.c | 6 ++++++
> formats/lttng-live/lttng-live.h | 7 +++++++
> 4 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/doc/babeltrace.1 b/doc/babeltrace.1
> index f783105..cee9f7b 100644
> --- a/doc/babeltrace.1
> +++ b/doc/babeltrace.1
> @@ -100,7 +100,8 @@ babeltrace-log(1), lttng(1), lttng-ust(3), lttng-sessiond(8)
> .SH "BUGS"
>
> .PP
> -No known bugs at this point.
> +The lttng-live plugin does not honor the the "--output" command line
> +option.
>
> If you encounter any issues or usability problem, please report it on
> our mailing list <lttng-dev at lists.lttng.org> to help improve this
> diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c
> index cea50ff..729df6f 100644
> --- a/formats/lttng-live/lttng-live-comm.c
> +++ b/formats/lttng-live/lttng-live-comm.c
> @@ -246,7 +246,7 @@ void print_session_list(GPtrArray *session_list, const char *path)
>
> for (i = 0; i < session_list->len; i++) {
> relay_session = g_ptr_array_index(session_list, i);
> - fprintf(stdout, "%s/host/%s/%s (timer = %u, "
> + fprintf(LTTNG_LIVE_OUTPUT_FP, "%s/host/%s/%s (timer = %u, "
> "%u stream(s), %u client(s) connected)\n",
> path, relay_session->hostname,
> relay_session->name, relay_session->timer,
> @@ -649,6 +649,17 @@ retry:
> ret = -1;
> goto end;
> }
> +
> + /*
> + * Flush the output between attempt to grab a packet, thus
> + * ensuring we flush at least at the periodical timer period.
> + * This is useful when the output is redirected to a file.
> + */
> + if (fflush(LTTNG_LIVE_OUTPUT_FP) < 0) {
> + perror("fflush");
> + goto error;
> + }
> +
> cmd.cmd = htobe32(LTTNG_VIEWER_GET_PACKET);
> cmd.data_size = htobe64(sizeof(rq));
> cmd.cmd_version = htobe32(0);
> diff --git a/formats/lttng-live/lttng-live-plugin.c b/formats/lttng-live/lttng-live-plugin.c
> index bf71b2b..771801c 100644
> --- a/formats/lttng-live/lttng-live-plugin.c
> +++ b/formats/lttng-live/lttng-live-plugin.c
> @@ -292,6 +292,12 @@ struct bt_trace_descriptor *lttng_live_open_trace(const char *path, int flags,
> pos->parent.rw_table = NULL;
> pos->parent.event_cb = NULL;
> pos->parent.trace = &pos->trace_descriptor;
> + /*
> + * Since we do *everything* in this function, we are skipping
> + * the output plugin handling that is part of Babeltrace 1.x.
> + * Therefore, don't expect the --output cmd line option to work.
> + * This limits the output of lttng-live to stderr and stdout.
> + */
> if (lttng_live_open_trace_read(path) < 0) {
> goto error;
> }
> diff --git a/formats/lttng-live/lttng-live.h b/formats/lttng-live/lttng-live.h
> index 553cd34..e00a51e 100644
> --- a/formats/lttng-live/lttng-live.h
> +++ b/formats/lttng-live/lttng-live.h
> @@ -32,6 +32,13 @@
> #define LTTNG_LIVE_MAJOR 2
> #define LTTNG_LIVE_MINOR 4
>
> +/*
> + * The lttng-live output file pointer is currently hardcoded to stdout,
> + * and is expected to be hardcoded to this by fflush() performed between
> + * each packet.
> + */
> +#define LTTNG_LIVE_OUTPUT_FP stdout
> +
> struct lttng_live_ctx {
> char traced_hostname[MAXNAMLEN];
> char session_name[MAXNAMLEN];
> --
> 2.1.4
>
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
prev parent reply other threads:[~2016-04-20 21:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 22:42 Mathieu Desnoyers
2016-04-20 21:03 ` Jérémie Galarneau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+jJMxvU=rn+sw8dDCWJUoCfCnXP+cnjXurfd=uZvhOyH-qzVg@mail.gmail.com' \
--to=jeremie.galarneau@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox