lttng_consumerd_SOURCES = lttng-consumerd.c lttng-consumerd.h
-lttng_consumerd_LDADD = \
+lttng_consumerd_LDADD = -lrt \
$(top_builddir)/src/common/libconsumer.la \
$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
$(top_builddir)/src/common/libcommon.la
bin_PROGRAMS = lttng-relayd
-lttng_relayd_SOURCES = main.c lttng-relayd.h
+lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c \
+ cmd-generic.c cmd-generic.h \
+ cmd-2-1.c cmd-2-1.h \
+ cmd-2-2.c cmd-2-2.h
# link on liblttngctl for check if relayd is already alive.
lttng_relayd_LDADD = -lrt -lurcu-common -lurcu \
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <string.h>
+
+#include <common/common.h>
+#include <common/sessiond-comm/relayd.h>
+
+#include "cmd-generic.h"
+#include "cmd-2-1.h"
+#include "utils.h"
+
+int cmd_recv_stream_2_1(struct relay_command *cmd, struct relay_stream *stream)
+{
+ int ret;
+ struct lttcomm_relayd_add_stream stream_info;
+
+ assert(cmd);
+ assert(stream);
+
+ ret = cmd_recv(cmd->sock, &stream_info, sizeof(stream_info));
+ if (ret < 0) {
+ ERR("Unable to recv stream version 2.1");
+ goto error;
+ }
+
+ stream->path_name = create_output_path(stream_info.pathname);
+ if (stream->path_name == NULL) {
+ PERROR("Path name allocation");
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ stream->channel_name = strdup(stream_info.channel_name);
+ if (stream->channel_name == NULL) {
+ ret = -errno;
+ PERROR("Path name allocation");
+ goto error;
+ }
+ ret = 0;
+
+error:
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RELAYD_CMD_2_1_H
+#define RELAYD_CMD_2_1_H
+
+#include "lttng-relayd.h"
+
+int cmd_recv_stream_2_1(struct relay_command *cmd, struct relay_stream *stream);
+
+#endif /* RELAYD_CMD_2_1_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <string.h>
+
+#include <common/common.h>
+#include <common/sessiond-comm/relayd.h>
+
+#include "cmd-generic.h"
+#include "cmd-2-1.h"
+#include "utils.h"
+
+int cmd_recv_stream_2_2(struct relay_command *cmd, struct relay_stream *stream)
+{
+ int ret;
+ struct lttcomm_relayd_add_stream_2_2 stream_info;
+
+ assert(cmd);
+ assert(stream);
+
+ ret = cmd_recv(cmd->sock, &stream_info, sizeof(stream_info));
+ if (ret < 0) {
+ ERR("Unable to recv stream version 2.2");
+ goto error;
+ }
+
+ stream->path_name = create_output_path(stream_info.pathname);
+ if (stream->path_name == NULL) {
+ PERROR("Path name allocation");
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ stream->channel_name = strdup(stream_info.channel_name);
+ if (stream->channel_name == NULL) {
+ 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;
+
+error:
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RELAYD_CMD_2_2_H
+#define RELAYD_CMD_2_2_H
+
+#include "lttng-relayd.h"
+
+int cmd_recv_stream_2_2(struct relay_command *cmd, struct relay_stream *stream);
+
+#endif /* RELAYD_CMD_2_2_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+
+#include <common/common.h>
+
+#include "cmd-generic.h"
+
+int cmd_recv(struct lttcomm_sock *sock, void *buf, size_t len)
+{
+ int ret;
+
+ assert(sock);
+ assert(buf);
+
+ ret = sock->ops->recvmsg(sock, buf, len, 0);
+ if (ret < len) {
+ if (ret == 0) {
+ /* Orderly shutdown. Not necessary to print an error. */
+ DBG("Socket %d did an orderly shutdown", sock->fd);
+ } else {
+ ERR("Relay didn't receive valid add_stream struct size. "
+ "Expected %lu, got %d", len, ret);
+ }
+ ret = -1;
+ goto error;
+ }
+
+error:
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RELAYD_CMD_GENERIC_H
+#define RELAYD_CMD_GENERIC_H
+
+#include <common/sessiond-comm/sessiond-comm.h>
+
+int cmd_recv(struct lttcomm_sock *sock, void *buf, size_t len);
+
+#endif /* RELAYD_CMD_GENERIC_H */
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RELAYD_CMD_H
+#define RELAYD_CMD_H
+
+#include "cmd-generic.h"
+#include "cmd-2-1.h"
+#include "cmd-2-2.h"
+
+#endif /* RELAYD_CMD_H */
#define _LGPL_SOURCE
#include <urcu.h>
#include <urcu/wfqueue.h>
+#include <common/hashtable/hashtable.h>
/*
* Queue used to enqueue relay requests
*/
uint64_t id;
struct lttcomm_sock *sock;
- /* protocol version to use for this session */
- uint32_t major;
- uint32_t minor;
};
/*
struct rcu_head rcu_node;
int fd;
+ char *path_name;
+ char *channel_name;
+ /* on-disk circular buffer of tracefiles */
+ uint64_t tracefile_size;
+ uint64_t tracefile_size_current;
+ uint64_t tracefile_count;
+ uint64_t tracefile_count_current;
+
/* Information telling us when to close the stream */
unsigned int close_flag:1;
uint64_t last_net_seq_num;
struct rcu_head rcu_node;
enum connection_type type;
unsigned int version_check_done:1;
+ /* protocol version to use for this session */
+ uint32_t major;
+ uint32_t minor;
};
+extern char *opt_output_path;
+
#endif /* LTTNG_RELAYD_H */
#include <common/futex.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/sessiond-comm/inet.h>
-#include <common/hashtable/hashtable.h>
#include <common/sessiond-comm/relayd.h>
#include <common/uri.h>
#include <common/utils.h>
+#include "cmd.h"
+#include "utils.h"
#include "lttng-relayd.h"
/* command line options */
+char *opt_output_path;
static int opt_daemon;
-static char *opt_output_path;
static struct lttng_uri *control_uri;
static struct lttng_uri *data_uri;
return NULL;
}
-/*
- * config_get_default_path
- *
- * Returns the HOME directory path. Caller MUST NOT free(3) the return pointer.
- */
-static
-char *config_get_default_path(void)
-{
- return getenv("HOME");
-}
-
-static
-char *create_output_path_auto(char *path_name)
-{
- int ret;
- char *traces_path = NULL;
- char *alloc_path = NULL;
- char *default_path;
-
- default_path = config_get_default_path();
- if (default_path == NULL) {
- ERR("Home path not found.\n \
- Please specify an output path using -o, --output PATH");
- goto exit;
- }
- alloc_path = strdup(default_path);
- if (alloc_path == NULL) {
- PERROR("Path allocation");
- goto exit;
- }
- ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME
- "/%s", alloc_path, path_name);
- if (ret < 0) {
- PERROR("asprintf trace dir name");
- goto exit;
- }
-exit:
- free(alloc_path);
- return traces_path;
-}
-
-static
-char *create_output_path_noauto(char *path_name)
-{
- int ret;
- char *traces_path = NULL;
- char *full_path;
-
- full_path = utils_expand_path(opt_output_path);
- if (!full_path) {
- goto exit;
- }
-
- ret = asprintf(&traces_path, "%s/%s", full_path, path_name);
- if (ret < 0) {
- PERROR("asprintf trace dir name");
- goto exit;
- }
-exit:
- free(full_path);
- return traces_path;
-}
-
-/*
- * create_output_path: create the output trace directory
- */
-static
-char *create_output_path(char *path_name)
-{
- if (opt_output_path == NULL) {
- return create_output_path_auto(path_name);
- } else {
- return create_output_path_noauto(path_name);
- }
-}
-
/*
* Get stream from stream id.
* Need to be called with RCU read-side lock held.
{
struct relay_stream *stream =
caa_container_of(head, struct relay_stream, rcu_node);
+ free(stream->path_name);
+ free(stream->channel_name);
free(stream);
}
struct relay_command *cmd, struct lttng_ht *streams_ht)
{
struct relay_session *session = cmd->session;
- struct lttcomm_relayd_add_stream stream_info;
struct relay_stream *stream = NULL;
struct lttcomm_relayd_status_stream reply;
- char *path = NULL, *root_path = NULL;
int ret, send_ret;
if (!session || cmd->version_check_done == 0) {
goto end_no_session;
}
- ret = cmd->sock->ops->recvmsg(cmd->sock, &stream_info,
- sizeof(struct lttcomm_relayd_add_stream), 0);
- if (ret < sizeof(struct lttcomm_relayd_add_stream)) {
- if (ret == 0) {
- /* Orderly shutdown. Not necessary to print an error. */
- DBG("Socket %d did an orderly shutdown", cmd->sock->fd);
- } else {
- ERR("Relay didn't receive valid add_stream struct size : %d", ret);
- }
- ret = -1;
- goto end_no_session;
- }
stream = zmalloc(sizeof(struct relay_stream));
if (stream == NULL) {
PERROR("relay stream zmalloc");
goto end_no_session;
}
+ switch (cmd->minor) {
+ case 1: /* LTTng sessiond 2.1 */
+ ret = cmd_recv_stream_2_1(cmd, stream);
+ break;
+ case 2: /* LTTng sessiond 2.2 */
+ default:
+ ret = cmd_recv_stream_2_2(cmd, stream);
+ break;
+ }
+ if (ret < 0) {
+ goto err_free_stream;
+ }
+
rcu_read_lock();
stream->stream_handle = ++last_relay_stream_id;
stream->prev_seq = -1ULL;
stream->session = session;
- root_path = create_output_path(stream_info.pathname);
- if (!root_path) {
- ret = -1;
- goto end;
- }
- ret = utils_mkdir_recursive(root_path, S_IRWXU | S_IRWXG);
+ ret = utils_mkdir_recursive(stream->path_name, S_IRWXU | S_IRWXG);
if (ret < 0) {
ERR("relay creating output directory");
goto end;
}
- ret = asprintf(&path, "%s/%s", root_path, stream_info.channel_name);
- if (ret < 0) {
- PERROR("asprintf stream path");
- path = NULL;
- goto end;
- }
-
- ret = open(path, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU|S_IRWXG|S_IRWXO);
+ ret = utils_create_stream_file(stream->path_name, stream->channel_name,
+ stream->tracefile_size, 0, getuid(), getgid());
if (ret < 0) {
- PERROR("Relay creating trace file");
+ ERR("Create output file");
goto end;
}
-
stream->fd = ret;
- DBG("Tracefile %s created", path);
+ if (stream->tracefile_size) {
+ DBG("Tracefile %s/%s_0 created", stream->path_name, stream->channel_name);
+ } else {
+ DBG("Tracefile %s/%s created", stream->path_name, stream->channel_name);
+ }
lttng_ht_node_init_ulong(&stream->stream_n,
(unsigned long) stream->stream_handle);
lttng_ht_add_unique_ulong(streams_ht,
&stream->stream_n);
- DBG("Relay new stream added %s", stream_info.channel_name);
+ DBG("Relay new stream added %s", stream->channel_name);
end:
- free(path);
- free(root_path);
-
reply.handle = htobe64(stream->stream_handle);
/* send the session id to the client or a negative return code on error */
if (ret < 0) {
end_no_session:
return ret;
+
+err_free_stream:
+ free(stream->path_name);
+ free(stream->channel_name);
+ free(stream);
+ return ret;
}
/*
goto end;
}
+ cmd->major = reply.major;
+ /* We adapt to the lowest compatible version */
+ if (reply.minor <= be32toh(msg.minor)) {
+ cmd->minor = reply.minor;
+ } else {
+ cmd->minor = be32toh(msg.minor);
+ }
+
reply.major = htobe32(reply.major);
reply.minor = htobe32(reply.minor);
ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,
ERR("Relay sending version");
}
-#if 0
- cmd->session->major = reply.major;
- /* We adapt to the lowest compatible version */
- if (reply.minor <= be32toh(msg.minor)) {
- cmd->session->minor = reply.minor;
- } else {
- cmd->session->minor = be32toh(msg.minor);
- }
-
- DBG("Version check done using protocol %u.%u", cmd->session->major,
- cmd->session->minor);
-#endif
+ DBG("Version check done using protocol %u.%u", cmd->major,
+ cmd->minor);
end:
return ret;
goto end_unlock;
}
+ if (stream->tracefile_size > 0 &&
+ (stream->tracefile_size_current + data_size) >
+ stream->tracefile_size) {
+ ret = utils_rotate_stream_file(stream->path_name,
+ stream->channel_name, stream->tracefile_size,
+ stream->tracefile_count, getuid(), getgid(),
+ stream->fd, &(stream->tracefile_count_current));
+ if (ret < 0) {
+ ERR("Rotating output file");
+ goto end;
+ }
+ stream->fd = ret;
+ }
+ stream->tracefile_size_current += data_size;
do {
ret = write(stream->fd, data_buffer, data_size);
} while (ret < 0 && errno == EINTR);
--- /dev/null
+/*
+ * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <common/common.h>
+#include <common/defaults.h>
+#include <common/utils.h>
+
+#include "lttng-relayd.h"
+#include "utils.h"
+
+/*
+ * Returns the HOME directory path. Caller MUST NOT free(3) the return pointer.
+ */
+static char *get_default_path(void)
+{
+ return getenv("HOME");
+}
+
+static char *create_output_path_auto(char *path_name)
+{
+ int ret;
+ char *traces_path = NULL;
+ char *alloc_path = NULL;
+ char *default_path;
+
+ default_path = get_default_path();
+ if (default_path == NULL) {
+ ERR("Home path not found.\n \
+ Please specify an output path using -o, --output PATH");
+ goto exit;
+ }
+ alloc_path = strdup(default_path);
+ if (alloc_path == NULL) {
+ PERROR("Path allocation");
+ goto exit;
+ }
+ ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME
+ "/%s", alloc_path, path_name);
+ if (ret < 0) {
+ PERROR("asprintf trace dir name");
+ goto exit;
+ }
+exit:
+ free(alloc_path);
+ return traces_path;
+}
+
+static char *create_output_path_noauto(char *path_name)
+{
+ int ret;
+ char *traces_path = NULL;
+ char *full_path;
+
+ full_path = utils_expand_path(opt_output_path);
+ if (!full_path) {
+ goto exit;
+ }
+
+ ret = asprintf(&traces_path, "%s/%s", full_path, path_name);
+ if (ret < 0) {
+ PERROR("asprintf trace dir name");
+ goto exit;
+ }
+exit:
+ free(full_path);
+ return traces_path;
+}
+
+/*
+ * Create the output trace directory path name string.
+ *
+ * Return the allocated string containing the path name or else NULL.
+ */
+char *create_output_path(char *path_name)
+{
+ assert(path_name);
+
+ if (opt_output_path == NULL) {
+ return create_output_path_auto(path_name);
+ } else {
+ return create_output_path_noauto(path_name);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 - Julien Desfossez <jdesfossez@efficios.com>
+ * David Goulet <dgoulet@efficios.com>
+ *
+ * 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 published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef RELAYD_UTILS_H
+#define RELAYD_UTILS_H
+
+char *create_output_path(char *path_name);
+
+#endif /* RELAYD_UTILS_H */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
ret = relayd_add_stream(&relayd->control_sock,
new_stream->name, new_stream->chan->pathname,
- &new_stream->relayd_stream_id);
+ &new_stream->relayd_stream_id,
+ new_stream->chan->tracefile_size,
+ new_stream->chan->tracefile_count);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
consumer_del_stream(new_stream, NULL);
* On success return 0 else return ret_code negative value.
*/
int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
- const char *pathname, uint64_t *stream_id)
+ const char *pathname, uint64_t *stream_id,
+ uint64_t tracefile_size, uint64_t tracefile_count)
{
int ret;
struct lttcomm_relayd_add_stream msg;
+ struct lttcomm_relayd_add_stream_2_2 msg_2_2;
struct lttcomm_relayd_status_stream reply;
/* Code flow error. Safety net. */
DBG("Relayd adding stream for channel name %s", channel_name);
- strncpy(msg.channel_name, channel_name, sizeof(msg.channel_name));
- strncpy(msg.pathname, pathname, sizeof(msg.pathname));
+ /* Compat with relayd 2.1 */
+ if (rsock->minor == 1) {
+ strncpy(msg.channel_name, channel_name, sizeof(msg.channel_name));
+ strncpy(msg.pathname, pathname, sizeof(msg.pathname));
- /* Send command */
- ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg, sizeof(msg), 0);
- if (ret < 0) {
- goto error;
+ /* Send command */
+ ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg, sizeof(msg), 0);
+ if (ret < 0) {
+ goto error;
+ }
+ } else {
+ /* Compat with relayd 2.2+ */
+ strncpy(msg_2_2.channel_name, channel_name, sizeof(msg_2_2.channel_name));
+ strncpy(msg_2_2.pathname, pathname, sizeof(msg_2_2.pathname));
+ msg_2_2.tracefile_size = htobe64(tracefile_size);
+ msg_2_2.tracefile_count = htobe64(tracefile_count);
+
+ /* Send command */
+ ret = send_command(rsock, RELAYD_ADD_STREAM, (void *) &msg_2_2, sizeof(msg_2_2), 0);
+ if (ret < 0) {
+ goto error;
+ }
}
/* Waiting for reply */
int relayd_close(struct lttcomm_relayd_sock *sock);
int relayd_create_session(struct lttcomm_relayd_sock *sock, uint64_t *session_id);
int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
- const char *pathname, uint64_t *stream_id);
+ const char *pathname, uint64_t *stream_id,
+ uint64_t tracefile_size, uint64_t tracefile_count);
int relayd_send_close_stream(struct lttcomm_relayd_sock *sock, uint64_t stream_id,
uint64_t last_net_seq_num);
int relayd_version_check(struct lttcomm_relayd_sock *sock);
char pathname[PATH_MAX];
} LTTNG_PACKED;
+/*
+ * Used to add a stream on the relay daemon.
+ * Protocol version 2.2
+ */
+struct lttcomm_relayd_add_stream_2_2 {
+ char channel_name[DEFAULT_STREAM_NAME_LEN];
+ char pathname[PATH_MAX];
+ uint64_t tracefile_size;
+ uint64_t tracefile_count;
+} LTTNG_PACKED;
+
/*
* Answer from an add stream command.
*/
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
/* Add stream on the relayd */
ret = relayd_add_stream(&relayd->control_sock, stream->name,
- stream->chan->pathname, &stream->relayd_stream_id);
+ stream->chan->pathname, &stream->relayd_stream_id,
+ stream->chan->tracefile_size,
+ stream->chan->tracefile_count);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
goto error;
path = full_path;
}
+ /* Open with 660 mode */
out_fd = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC,
- S_IRWXU | S_IRWXG | S_IRWXO, uid, gid);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, uid, gid);
if (out_fd < 0) {
PERROR("open stream path %s", path);
goto error_open;