int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
char *session_name, char *hostname,
- uint32_t *live_timer, bool *snapshot)
+ uint32_t *live_timer, bool *snapshot,
+ lttng_uuid sessiond_uuid)
{
int ret;
struct lttcomm_relayd_create_session_2_11 header;
header.hostname_len = be32toh(header.hostname_len);
header.live_timer = be32toh(header.live_timer);
+ lttng_uuid_copy(sessiond_uuid, header.sessiond_uuid);
+
received_names_size = header.session_name_len + header.hostname_len;
if (payload->size < header_len + received_names_size) {
ERR("Unexpected payload size in \"cmd_create_session_2_11\": expected >= %zu bytes, got %zu bytes",
#include "lttng-relayd.h"
#include <common/buffer-view.h>
+#include <common/compat/uuid.h>
int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
char *session_name, char *hostname,
- uint32_t *live_timer, bool *snapshot);
+ uint32_t *live_timer, bool *snapshot,
+ lttng_uuid sessiond_uuid);
int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
char **ret_path_name, char **ret_channel_name,
#include <common/hashtable/hashtable.h>
+struct sessiond_trace_chunk_registry;
+
/*
* Queue used to enqueue relay requests
*/
extern struct lttng_ht *sessions_ht;
extern struct lttng_ht *relay_streams_ht;
extern struct lttng_ht *viewer_streams_ht;
+extern struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
extern char *opt_output_path;
extern const char *tracing_group_name;
#include "connection.h"
#include "tracefile-array.h"
#include "tcp_keep_alive.h"
+#include "sessiond-trace-chunks.h"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
/* Relayd health monitoring */
struct health_app *health_relayd;
+struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
+
static struct option long_options[] = {
{ "control-port", 1, 0, 'C', },
{ "data-port", 1, 0, 'D', },
char hostname[LTTNG_HOST_NAME_MAX];
uint32_t live_timer = 0;
bool snapshot = false;
+ /* Left nil for peers < 2.11. */
+ lttng_uuid sessiond_uuid = {};
memset(session_name, 0, LTTNG_NAME_MAX);
memset(hostname, 0, LTTNG_HOST_NAME_MAX);
} else {
/* From 2.11 to ... */
ret = cmd_create_session_2_11(payload, session_name,
- hostname, &live_timer, &snapshot);
+ hostname, &live_timer, &snapshot,
+ sessiond_uuid);
+ if (lttng_uuid_is_nil(sessiond_uuid)) {
+ /* The nil UUID is reserved for pre-2.11 clients. */
+ ERR("Illegal nil UUID announced by peer in create session command");
+ ret = -1;
+ goto send_reply;
+ }
}
if (ret < 0) {
}
session = session_create(session_name, hostname, live_timer,
- snapshot, conn->major, conn->minor);
+ snapshot, sessiond_uuid, conn->major, conn->minor);
if (!session) {
ret = -1;
goto send_reply;
}
}
+ sessiond_trace_chunk_registry = sessiond_trace_chunk_registry_create();
+ if (!sessiond_trace_chunk_registry) {
+ ERR("Failed to initialize session daemon trace chunk registry");
+ retval = -1;
+ goto exit_sessiond_trace_chunk_registry;
+ }
+
/* Initialize thread health monitoring */
health_relayd = health_app_create(NR_HEALTH_RELAYD_TYPES);
if (!health_relayd) {
exit_init_data:
health_app_destroy(health_relayd);
+ sessiond_trace_chunk_registry_destroy(sessiond_trace_chunk_registry);
exit_health_app_create:
+exit_sessiond_trace_chunk_registry:
exit_options:
/*
* Wait for all pending call_rcu work to complete before tearing
#include "ctf-trace.h"
#include "session.h"
#include "stream.h"
+#include "sessiond-trace-chunks.h"
/* Global session id used in the session creation. */
static uint64_t last_relay_session_id;
*/
struct relay_session *session_create(const char *session_name,
const char *hostname, uint32_t live_timer,
- bool snapshot, uint32_t major, uint32_t minor)
+ bool snapshot, const lttng_uuid sessiond_uuid,
+ uint32_t major, uint32_t minor)
{
+ int ret;
struct relay_session *session;
session = zmalloc(sizeof(*session));
session->live_timer = live_timer;
session->snapshot = snapshot;
+ lttng_uuid_copy(session->sessiond_uuid, sessiond_uuid);
+
+ ret = sessiond_trace_chunk_registry_session_created(
+ sessiond_trace_chunk_registry, sessiond_uuid);
+ if (ret) {
+ goto error;
+ }
lttng_ht_add_unique_u64(sessions_ht, &session->session_n);
return session;
ret = session_delete(session);
assert(!ret);
+ ret = sessiond_trace_chunk_registry_session_destroyed(
+ sessiond_trace_chunk_registry, session->sessiond_uuid);
+ assert(!ret);
call_rcu(&session->rcu_node, rcu_destroy_session);
}
#include <lttng/constant.h>
#include <common/hashtable/hashtable.h>
+#include <common/compat/uuid.h>
/*
* Represents a session for the relay point of view
* It is used to match a set of streams to their session.
*/
uint64_t id;
+ lttng_uuid sessiond_uuid;
char session_name[LTTNG_NAME_MAX];
char hostname[LTTNG_HOST_NAME_MAX];
uint32_t live_timer;
struct relay_session *session_create(const char *session_name,
const char *hostname, uint32_t live_timer,
- bool snapshot, uint32_t major, uint32_t minor);
+ bool snapshot, const lttng_uuid sessiond_uuid,
+ uint32_t major, uint32_t minor);
struct relay_session *session_get_by_id(uint64_t id);
bool session_get(struct relay_session *session);
void session_put(struct relay_session *session);