cmd.data_size = sizeof(connect);
cmd.cmd_version = 0;
+ connect.viewer_session_id = -1ULL; /* will be set on recv */
connect.major = htobe32(LTTNG_LIVE_MAJOR);
connect.minor = htobe32(LTTNG_LIVE_MINOR);
connect.type = htobe32(LTTNG_VIEWER_CLIENT_COMMAND);
goto error;
}
assert(ret_len == sizeof(lsession));
+ lsession.hostname[LTTNG_VIEWER_HOST_NAME_MAX - 1] = '\0';
+ lsession.session_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
fprintf(stdout, "%s/%" PRIu64 " : %s on host %s (timer = %u, "
"%u stream(s), %u client(s) connected)\n",
(gpointer) ctf_trace_id);
if (!trace) {
trace = g_new0(struct lttng_live_ctf_trace, 1);
- if (!trace) {
- ret = -1;
- fprintf(stderr, "[error] ctf_trace allocation\n");
- goto error;
- }
trace->ctf_trace_id = ctf_trace_id;
trace->streams = g_ptr_array_new();
g_hash_table_insert(stream->session->ctf_traces,
stream->ctf_trace = trace;
g_ptr_array_add(trace->streams, stream);
-error:
return ret;
}
ctx->session->stream_count);
ctx->session->streams = g_new0(struct lttng_live_viewer_stream,
ctx->session->stream_count);
- if (!ctx->session->streams) {
- ret = -1;
- goto error;
- }
-
for (i = 0; i < be32toh(rp.streams_count); i++) {
do {
ret_len = recv(ctx->control_sock, &stream, sizeof(stream), 0);
goto error;
}
assert(ret_len == sizeof(stream));
+ stream.path_name[LTTNG_VIEWER_PATH_MAX - 1] = '\0';
+ stream.channel_name[LTTNG_VIEWER_NAME_MAX - 1] = '\0';
printf_verbose(" stream %" PRIu64 " : %s/%s\n",
be64toh(stream.id), stream.path_name,
char *path;
path = strdup(LTTNG_METADATA_PATH_TEMPLATE);
- path = mkdtemp(path);
+ if (!path) {
+ perror("strdup");
+ ret = -1;
+ goto error;
+ }
+ if (!mkdtemp(path)) {
+ perror("mkdtemp");
+ free(path);
+ ret = -1;
+ goto error;
+ }
ctx->session->streams[i].metadata_flag = 1;
- mkdir(path, S_IRWXU | S_IRWXG);
snprintf(ctx->session->streams[i].path,
sizeof(ctx->session->streams[i].path),
"%s/%s", path,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
+ perror("open");
+ free(path);
goto error;
}
ctx->session->streams[i].fd = ret;
+ free(path);
}
ret = lttng_live_ctf_trace_assign(&ctx->session->streams[i],
be64toh(stream.ctf_trace_id));
ret = ret_len;
goto error;
}
- assert(ret_len == sizeof(rp));
+ if (ret_len != sizeof(rp)) {
+ fprintf(stderr, "[error] get_data_packet: expected %" PRId64
+ ", received %" PRId64 "\n", ret_len,
+ sizeof(rp));
+ ret = -1;
+ goto error;
+ }
rp.flags = be32toh(rp.flags);