X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fcmd-2-2.c;h=f82166cf3c14b9d62fe5c0c03a2057f2d7fef890;hp=7dd99ad5f0dbee10c5c377ec536e93b7ff06b348;hb=7591bab11eceedc6a0d1e02fd6f85592267a63b5;hpb=d77dded285b058e4242c8a3d2233f80e725ceefc diff --git a/src/bin/lttng-relayd/cmd-2-2.c b/src/bin/lttng-relayd/cmd-2-2.c index 7dd99ad5f..f82166cf3 100644 --- a/src/bin/lttng-relayd/cmd-2-2.c +++ b/src/bin/lttng-relayd/cmd-2-2.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 - Julien Desfossez * David Goulet + * 2015 - Mathieu Desnoyers * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License, version 2 only, as @@ -30,14 +31,17 @@ #include "cmd-2-1.h" #include "utils.h" +/* + * cmd_recv_stream_2_2 allocates path_name and channel_name. + */ int cmd_recv_stream_2_2(struct relay_connection *conn, - struct relay_stream *stream) + char **ret_path_name, char **ret_channel_name, + uint64_t *tracefile_size, uint64_t *tracefile_count) { int ret; struct lttcomm_relayd_add_stream_2_2 stream_info; - - assert(conn); - assert(stream); + char *path_name = NULL; + char *channel_name = NULL; ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); if (ret < 0) { @@ -45,24 +49,27 @@ int cmd_recv_stream_2_2(struct relay_connection *conn, goto error; } - stream->path_name = create_output_path(stream_info.pathname); - if (stream->path_name == NULL) { + path_name = create_output_path(stream_info.pathname); + if (!path_name) { PERROR("Path name allocation"); ret = -ENOMEM; goto error; } - stream->channel_name = strdup(stream_info.channel_name); - if (stream->channel_name == NULL) { + channel_name = strdup(stream_info.channel_name); + if (!channel_name) { ret = -errno; PERROR("Path name allocation"); goto error; } - stream->tracefile_size = be64toh(stream_info.tracefile_size); - stream->tracefile_count = be64toh(stream_info.tracefile_count); - ret = 0; - + *tracefile_size = be64toh(stream_info.tracefile_size); + *tracefile_count = be64toh(stream_info.tracefile_count); + *ret_path_name = path_name; + *ret_channel_name = channel_name; + return 0; error: + free(path_name); + free(channel_name); return ret; }