X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fcmd-2-1.c;h=7c589cf8848b62373e4401ee8fd454ec713f64b9;hb=fcf4d551b695cfdb6fe26d21f0509d08ef89b312;hp=de70c51729425d8c5e0251af41c9979535864f55;hpb=58eb9381cd933f0644e6a5b89750dbd6d9b14570;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/cmd-2-1.c b/src/bin/lttng-relayd/cmd-2-1.c index de70c5172..7c589cf88 100644 --- a/src/bin/lttng-relayd/cmd-2-1.c +++ b/src/bin/lttng-relayd/cmd-2-1.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 @@ -27,14 +28,16 @@ #include "cmd-2-1.h" #include "utils.h" +/* + * cmd_recv_stream_2_1 allocates path_name and channel_name. + */ int cmd_recv_stream_2_1(struct relay_connection *conn, - struct relay_stream *stream) + char **ret_path_name, char **ret_channel_name) { int ret; struct lttcomm_relayd_add_stream 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) { @@ -42,21 +45,25 @@ int cmd_recv_stream_2_1(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; } - ret = 0; + *ret_path_name = path_name; + *ret_channel_name = channel_name; + return 0; error: + free(path_name); + free(channel_name); return ret; }