ctf.fs: bt_ctf_notif_iter_create(): assert() that all medops exist
[babeltrace.git] / formats / lttng-live / lttng-live-comm.c
index cd146d764886d21032dbe4e0dfe8e0e01fc7c385..6c5d4fd296f55fc9f23f4bba506432c3889f367c 100644 (file)
 #include <babeltrace/compat/send.h>
 #include <babeltrace/compat/string.h>
 #include <babeltrace/compat/mman.h>
+#include <babeltrace/babeltrace-internal.h>
 
 #include "lttng-live.h"
 #include "lttng-viewer-abi.h"
 
 #define ACTIVE_POLL_DELAY      100     /* ms */
 
-/*
- * Memory allocation zeroed
- */
-#define zmalloc(x) calloc(1, x)
-
-#ifndef max_t
-#define max_t(type, a, b)      \
-       ((type) (a) > (type) (b) ? (type) (a) : (type) (b))
-#endif
-
 static void ctf_live_packet_seek(struct bt_stream_pos *stream_pos,
                size_t index, int whence);
 static int add_traces(struct lttng_live_ctx *ctx);
@@ -408,7 +399,7 @@ int open_metadata_fp_write(struct lttng_live_viewer_stream *stream,
        int ret = 0;
 
        stream->metadata_fp_write =
-               babeltrace_open_memstream(metadata_buf, size);
+               bt_open_memstream(metadata_buf, size);
        if (!stream->metadata_fp_write) {
                perror("Metadata open_memstream");
                ret = -1;
@@ -610,7 +601,7 @@ int append_metadata(struct lttng_live_ctx *ctx,
 
        metadata = viewer_stream->ctf_trace->metadata_stream;
        metadata->ctf_trace->metadata_fp =
-               babeltrace_fmemopen(metadata_buf,
+               bt_fmemopen(metadata_buf,
                                metadata->metadata_len, "rb");
        if (!metadata->ctf_trace->metadata_fp) {
                perror("Metadata fmemopen");
@@ -650,17 +641,6 @@ retry:
                goto end;
        }
 
-       /*
-        * Flush the output between attempts to grab a packet, thus
-        * ensuring we flush at least at the periodical timer period.
-        * This ensures the output remains reactive for interactive users and
-        * that the output is flushed when redirected to a file by the shell.
-        */
-       if (fflush(LTTNG_LIVE_OUTPUT_FP) < 0) {
-               perror("fflush");
-               goto error;
-       }
-
        cmd.cmd = htobe32(LTTNG_VIEWER_GET_PACKET);
        cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
@@ -944,9 +924,9 @@ int get_new_metadata(struct lttng_live_ctx *ctx,
                }
        } while (ret > 0 || !len_read);
 
-       if (babeltrace_close_memstream(metadata_buf, &size,
+       if (bt_close_memstream(metadata_buf, &size,
                        metadata_stream->metadata_fp_write)) {
-               perror("babeltrace_close_memstream");
+               perror("bt_close_memstream");
        }
        metadata_stream->metadata_fp_write = NULL;
 
@@ -1293,6 +1273,17 @@ retry:
                                cur_index->ts_real.timestamp_begin;
        }
 
+       /*
+        * Flush the output between attempts to grab a packet, thus
+        * ensuring we flush at least at the periodical timer period.
+        * This ensures the output remains reactive for interactive users and
+        * that the output is flushed when redirected to a file by the shell.
+        */
+       if (fflush(LTTNG_LIVE_OUTPUT_FP) < 0) {
+               perror("fflush");
+               goto end;
+       }
+
        if (pos->packet_size == 0 || pos->offset == EOF) {
                goto end;
        }
@@ -1432,7 +1423,7 @@ int add_one_trace(struct lttng_live_ctx *ctx,
                                goto end_free;
                        }
 
-                       trace->metadata_fp = babeltrace_fmemopen(metadata_buf,
+                       trace->metadata_fp = bt_fmemopen(metadata_buf,
                                        stream->metadata_len, "rb");
                        if (!trace->metadata_fp) {
                                perror("Metadata fmemopen");
This page took 0.024219 seconds and 4 git commands to generate.