Port: Remove _GNU_SOURCE, defined in config.h
[lttng-tools.git] / src / bin / lttng-relayd / cmd-2-1.c
1 /*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License, version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #define _LGPL_SOURCE
21 #include <assert.h>
22 #include <string.h>
23
24 #include <common/common.h>
25 #include <common/sessiond-comm/relayd.h>
26
27 #include "cmd-generic.h"
28 #include "cmd-2-1.h"
29 #include "utils.h"
30
31 /*
32 * cmd_recv_stream_2_1 allocates path_name and channel_name.
33 */
34 int cmd_recv_stream_2_1(struct relay_connection *conn,
35 char **ret_path_name, char **ret_channel_name)
36 {
37 int ret;
38 struct lttcomm_relayd_add_stream stream_info;
39 char *path_name = NULL;
40 char *channel_name = NULL;
41
42 ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info));
43 if (ret < 0) {
44 ERR("Unable to recv stream version 2.1");
45 goto error;
46 }
47
48 path_name = create_output_path(stream_info.pathname);
49 if (!path_name) {
50 PERROR("Path name allocation");
51 ret = -ENOMEM;
52 goto error;
53 }
54
55 channel_name = strdup(stream_info.channel_name);
56 if (!channel_name) {
57 ret = -errno;
58 PERROR("Path name allocation");
59 goto error;
60 }
61
62 *ret_path_name = path_name;
63 *ret_channel_name = channel_name;
64 return 0;
65 error:
66 free(path_name);
67 free(channel_name);
68 return ret;
69 }
This page took 0.029675 seconds and 4 git commands to generate.