Fix: warnings on Solaris10
[babeltrace.git] / formats / lttng-live / lttng-live-comm.c
index 492125a7b058bdfcd03d940c3d5d34d536d25885..6541facfea57abd01ec711b2426d2ed0bfd3045a 100644 (file)
@@ -166,7 +166,7 @@ int lttng_live_establish_connection(struct lttng_live_ctx *ctx)
        }
 
        cmd.cmd = htobe32(LTTNG_VIEWER_CONNECT);
-       cmd.data_size = htobe64(sizeof(connect));
+       cmd.data_size = htobe64((uint64_t) sizeof(connect));
        cmd.cmd_version = htobe32(0);
 
        connect.viewer_session_id = -1ULL;      /* will be set on recv */
@@ -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,
@@ -307,7 +307,7 @@ int lttng_live_list_sessions(struct lttng_live_ctx *ctx, const char *path)
        }
 
        cmd.cmd = htobe32(LTTNG_VIEWER_LIST_SESSIONS);
-       cmd.data_size = htobe64(0);
+       cmd.data_size = htobe64((uint64_t) 0);
        cmd.cmd_version = htobe32(0);
 
        ret_len = lttng_live_send(ctx->control_sock, &cmd, sizeof(cmd));
@@ -432,7 +432,7 @@ int lttng_live_attach_session(struct lttng_live_ctx *ctx, uint64_t id)
        }
 
        cmd.cmd = htobe32(LTTNG_VIEWER_ATTACH_SESSION);
-       cmd.data_size = htobe64(sizeof(rq));
+       cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
 
        memset(&rq, 0, sizeof(rq));
@@ -649,8 +649,20 @@ retry:
                ret = -1;
                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(sizeof(rq));
+       cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
 
        memset(&rq, 0, sizeof(rq));
@@ -802,7 +814,7 @@ int get_one_metadata_packet(struct lttng_live_ctx *ctx,
 
        rq.stream_id = htobe64(metadata_stream->id);
        cmd.cmd = htobe32(LTTNG_VIEWER_GET_METADATA);
-       cmd.data_size = htobe64(sizeof(rq));
+       cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
 
        ret_len = lttng_live_send(ctx->control_sock, &cmd, sizeof(cmd));
@@ -977,7 +989,7 @@ int get_next_index(struct lttng_live_ctx *ctx,
        struct lttng_viewer_index *rp = &viewer_stream->current_index;
 
        cmd.cmd = htobe32(LTTNG_VIEWER_GET_NEXT_INDEX);
-       cmd.data_size = htobe64(sizeof(rq));
+       cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
 
        memset(&rq, 0, sizeof(rq));
@@ -1320,7 +1332,7 @@ int lttng_live_create_viewer_session(struct lttng_live_ctx *ctx)
        }
 
        cmd.cmd = htobe32(LTTNG_VIEWER_CREATE_SESSION);
-       cmd.data_size = htobe64(0);
+       cmd.data_size = htobe64((uint64_t) 0);
        cmd.cmd_version = htobe32(0);
 
        ret_len = lttng_live_send(ctx->control_sock, &cmd, sizeof(cmd));
@@ -1510,7 +1522,7 @@ int lttng_live_get_new_streams(struct lttng_live_ctx *ctx, uint64_t id)
        }
 
        cmd.cmd = htobe32(LTTNG_VIEWER_GET_NEW_STREAMS);
-       cmd.data_size = htobe64(sizeof(rq));
+       cmd.data_size = htobe64((uint64_t) sizeof(rq));
        cmd.cmd_version = htobe32(0);
 
        memset(&rq, 0, sizeof(rq));
This page took 0.026375 seconds and 4 git commands to generate.