A recent commit changed the way the creation timestamp was added to a
session's output path; the session creation timestamp is now (2.11+)
sampled at creation time and formatted when the session's output
directory is created.
The 2.11+ version of the session and stream creation commands allow
the relay daemon to use all components of the path independently to
format an output path rather than relying on the session daemon peer
to format it ahead of time.
In order to maintain the timestamped session folder name created by
previous versions, the relay daemon now receives the session's
creation timestamp and formats it rather than relying on it being
"cooked" into the transmitted session name.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
- bool *has_current_chunk, uint64_t *current_chunk_id)
+ bool *has_current_chunk, uint64_t *current_chunk_id,
+ time_t *creation_time)
{
int ret;
struct lttcomm_relayd_create_session_2_11 header;
{
int ret;
struct lttcomm_relayd_create_session_2_11 header;
header.live_timer = be32toh(header.live_timer);
header.current_chunk_id.value = be64toh(header.current_chunk_id.value);
header.current_chunk_id.is_set = !!header.current_chunk_id.is_set;
header.live_timer = be32toh(header.live_timer);
header.current_chunk_id.value = be64toh(header.current_chunk_id.value);
header.current_chunk_id.is_set = !!header.current_chunk_id.is_set;
+ header.creation_time = be64toh(header.creation_time);
lttng_uuid_copy(sessiond_uuid, header.sessiond_uuid);
lttng_uuid_copy(sessiond_uuid, header.sessiond_uuid);
*snapshot = !!header.snapshot;
*current_chunk_id = header.current_chunk_id.value;
*has_current_chunk = header.current_chunk_id.is_set;
*snapshot = !!header.snapshot;
*current_chunk_id = header.current_chunk_id.value;
*has_current_chunk = header.current_chunk_id.is_set;
+ *creation_time = (time_t) header.creation_time;
char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
- bool *has_current_chunk, uint64_t *current_chunk_id);
+ bool *has_current_chunk, uint64_t *current_chunk_id,
+ time_t *creation_time);
int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
char **ret_path_name, char **ret_channel_name,
int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
char **ret_path_name, char **ret_channel_name,
lttng_uuid sessiond_uuid = {};
LTTNG_OPTIONAL(uint64_t) id_sessiond = {};
LTTNG_OPTIONAL(uint64_t) current_chunk_id = {};
lttng_uuid sessiond_uuid = {};
LTTNG_OPTIONAL(uint64_t) id_sessiond = {};
LTTNG_OPTIONAL(uint64_t) current_chunk_id = {};
+ LTTNG_OPTIONAL(time_t) creation_time = {};
if (conn->minor < 4) {
/* From 2.1 to 2.3 */
if (conn->minor < 4) {
/* From 2.1 to 2.3 */
hostname, &live_timer, &snapshot);
} else {
bool has_current_chunk;
hostname, &live_timer, &snapshot);
} else {
bool has_current_chunk;
+ uint64_t current_chunk_id_value;
+ time_t creation_time_value;
+ uint64_t id_sessiond_value;
- ret = cmd_create_session_2_11(payload, session_name,
- hostname, &live_timer, &snapshot,
- &id_sessiond.value, sessiond_uuid,
- &has_current_chunk,
- ¤t_chunk_id.value);
+ ret = cmd_create_session_2_11(payload, session_name, hostname,
+ &live_timer, &snapshot, &id_sessiond_value,
+ sessiond_uuid, &has_current_chunk,
+ ¤t_chunk_id_value, &creation_time_value);
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 (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;
}
- id_sessiond.is_set = true;
- current_chunk_id.is_set = has_current_chunk;
+ LTTNG_OPTIONAL_SET(&id_sessiond, id_sessiond_value);
+ LTTNG_OPTIONAL_SET(&creation_time, creation_time_value);
+ if (has_current_chunk) {
+ LTTNG_OPTIONAL_SET(¤t_chunk_id,
+ current_chunk_id_value);
+ }
snapshot, sessiond_uuid,
id_sessiond.is_set ? &id_sessiond.value : NULL,
current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
snapshot, sessiond_uuid,
id_sessiond.is_set ? &id_sessiond.value : NULL,
current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ creation_time.is_set ? &creation_time.value : NULL,
conn->major, conn->minor);
if (!session) {
ret = -1;
conn->major, conn->minor);
if (!session) {
ret = -1;
* Return allocated session or else NULL.
*/
struct relay_session *session_create(const char *session_name,
* Return allocated session or else NULL.
*/
struct relay_session *session_create(const char *session_name,
- const char *hostname, uint32_t live_timer,
- bool snapshot, const lttng_uuid sessiond_uuid,
- uint64_t *id_sessiond, uint64_t *current_chunk_id,
- uint32_t major, uint32_t minor)
+ const char *hostname,
+ uint32_t live_timer,
+ bool snapshot,
+ const lttng_uuid sessiond_uuid,
+ const uint64_t *id_sessiond,
+ const uint64_t *current_chunk_id,
+ const time_t *creation_time,
+ uint32_t major,
+ uint32_t minor)
{
int ret;
struct relay_session *session;
{
int ret;
struct relay_session *session;
}
lttng_ht_add_unique_u64(sessions_ht, &session->session_n);
}
lttng_ht_add_unique_u64(sessions_ht, &session->session_n);
+ if (creation_time) {
+ LTTNG_OPTIONAL_SET(&session->creation_time, *creation_time);
+ }
* the other cases.
*/
lttng_uuid sessiond_uuid;
* the other cases.
*/
lttng_uuid sessiond_uuid;
+ LTTNG_OPTIONAL(time_t) creation_time;
char session_name[LTTNG_NAME_MAX];
char hostname[LTTNG_HOST_NAME_MAX];
uint32_t live_timer;
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,
};
struct relay_session *session_create(const char *session_name,
- const char *hostname, uint32_t live_timer,
- bool snapshot, const lttng_uuid sessiond_uuid,
- uint64_t *id_sessiond, uint64_t *current_chunk_id,
- uint32_t major, uint32_t minor);
+ const char *hostname,
+ uint32_t live_timer,
+ bool snapshot,
+ const lttng_uuid sessiond_uuid,
+ const uint64_t *id_sessiond,
+ const uint64_t *current_chunk_id,
+ const time_t *creation_time,
+ 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);
struct relay_session *session_get_by_id(uint64_t id);
bool session_get(struct relay_session *session);
void session_put(struct relay_session *session);
struct consumer_socket *consumer_sock,
const char *session_name, const char *hostname,
int session_live_timer,
struct consumer_socket *consumer_sock,
const char *session_name, const char *hostname,
int session_live_timer,
- const uint64_t *current_chunk_id)
+ const uint64_t *current_chunk_id,
+ time_t session_creation_time)
{
int ret;
struct lttcomm_relayd_sock *rsock = NULL;
{
int ret;
struct lttcomm_relayd_sock *rsock = NULL;
ret = consumer_send_relayd_socket(consumer_sock, rsock, consumer,
relayd_uri->stype, session_id,
session_name, hostname, session_live_timer,
ret = consumer_send_relayd_socket(consumer_sock, rsock, consumer,
relayd_uri->stype, session_id,
session_name, hostname, session_live_timer,
+ current_chunk_id, session_creation_time);
if (ret < 0) {
status = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
goto close_sock;
if (ret < 0) {
status = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
goto close_sock;
unsigned int session_id, struct consumer_output *consumer,
struct consumer_socket *sock, const char *session_name,
const char *hostname, int session_live_timer,
unsigned int session_id, struct consumer_output *consumer,
struct consumer_socket *sock, const char *session_name,
const char *hostname, int session_live_timer,
- const uint64_t *current_chunk_id)
+ const uint64_t *current_chunk_id, time_t session_creation_time)
{
enum lttng_error_code status = LTTNG_OK;
{
enum lttng_error_code status = LTTNG_OK;
status = send_consumer_relayd_socket(session_id,
&consumer->dst.net.control, consumer, sock,
session_name, hostname, session_live_timer,
status = send_consumer_relayd_socket(session_id,
&consumer->dst.net.control, consumer, sock,
session_name, hostname, session_live_timer,
+ current_chunk_id, session_creation_time);
if (status != LTTNG_OK) {
goto error;
}
if (status != LTTNG_OK) {
goto error;
}
status = send_consumer_relayd_socket(session_id,
&consumer->dst.net.data, consumer, sock,
session_name, hostname, session_live_timer,
status = send_consumer_relayd_socket(session_id,
&consumer->dst.net.data, consumer, sock,
session_name, hostname, session_live_timer,
+ current_chunk_id, session_creation_time);
if (status != LTTNG_OK) {
goto error;
}
if (status != LTTNG_OK) {
goto error;
}
usess->consumer, socket,
session->name, session->hostname,
session->live_timer,
usess->consumer, socket,
session->name, session->hostname,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL);
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time);
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
ksess->consumer, socket,
session->name, session->hostname,
session->live_timer,
ksess->consumer, socket,
session->name, session->hostname,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL);
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time);
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
snap_output->consumer, socket,
session->name, session->hostname,
session->live_timer,
snap_output->consumer, socket,
session->name, session->hostname,
session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL);
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time);
pthread_mutex_unlock(socket->lock);
if (status != LTTNG_OK) {
rcu_read_unlock();
pthread_mutex_unlock(socket->lock);
if (status != LTTNG_OK) {
rcu_read_unlock();
struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
enum lttng_stream_type type, uint64_t session_id,
const char *session_name, const char *hostname,
struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
enum lttng_stream_type type, uint64_t session_id,
const char *session_name, const char *hostname,
- int session_live_timer, const uint64_t *current_chunk_id)
+ int session_live_timer, const uint64_t *current_chunk_id,
+ time_t session_creation_time)
{
int ret;
struct lttcomm_consumer_msg msg;
{
int ret;
struct lttcomm_consumer_msg msg;
&msg.u.relayd_sock.relayd_session_id,
session_name, hostname, session_live_timer,
consumer->snapshot, session_id,
&msg.u.relayd_sock.relayd_session_id,
session_name, hostname, session_live_timer,
consumer->snapshot, session_id,
- sessiond_uuid, current_chunk_id);
+ sessiond_uuid, current_chunk_id,
+ session_creation_time);
if (ret < 0) {
/* Close the control socket. */
(void) relayd_close(rsock);
if (ret < 0) {
/* Close the control socket. */
(void) relayd_close(rsock);
struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
enum lttng_stream_type type, uint64_t session_id,
const char *session_name, const char *hostname,
struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
enum lttng_stream_type type, uint64_t session_id,
const char *session_name, const char *hostname,
- int session_live_timer, const uint64_t *current_chunk_id);
+ int session_live_timer, const uint64_t *current_chunk_id,
+ time_t session_creation_time);
int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
int pipe);
int consumer_send_destroy_relayd(struct consumer_socket *sock,
int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
int pipe);
int consumer_send_destroy_relayd(struct consumer_socket *sock,
const char *session_name, const char *hostname,
int session_live_timer, unsigned int snapshot,
uint64_t sessiond_session_id, const lttng_uuid sessiond_uuid,
const char *session_name, const char *hostname,
int session_live_timer, unsigned int snapshot,
uint64_t sessiond_session_id, const lttng_uuid sessiond_uuid,
- const uint64_t *current_chunk_id)
+ const uint64_t *current_chunk_id,
+ time_t creation_time)
{
int ret;
struct lttcomm_relayd_create_session_2_11 *msg = NULL;
{
int ret;
struct lttcomm_relayd_create_session_2_11 *msg = NULL;
htobe64(*current_chunk_id));
}
htobe64(*current_chunk_id));
}
+ msg->creation_time = htobe64((uint64_t) creation_time);
+
/* Send command */
ret = send_command(rsock, RELAYD_CREATE_SESSION, msg, msg_length, 0);
if (ret < 0) {
/* Send command */
ret = send_command(rsock, RELAYD_CREATE_SESSION, msg, msg_length, 0);
if (ret < 0) {
int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
const lttng_uuid sessiond_uuid,
int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
const lttng_uuid sessiond_uuid,
- const uint64_t *current_chunk_id)
+ const uint64_t *current_chunk_id,
+ time_t creation_time)
{
int ret;
struct lttcomm_relayd_status_session reply;
{
int ret;
struct lttcomm_relayd_status_session reply;
ret = relayd_create_session_2_11(rsock, session_name,
hostname, session_live_timer, snapshot,
sessiond_session_id, sessiond_uuid,
ret = relayd_create_session_2_11(rsock, session_name,
hostname, session_live_timer, snapshot,
sessiond_session_id, sessiond_uuid,
+ current_chunk_id, creation_time);
int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
const lttng_uuid sessiond_uuid,
int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
const lttng_uuid sessiond_uuid,
- const uint64_t *current_chunk_id);
+ const uint64_t *current_chunk_id,
+ time_t creation_time);
int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
const char *pathname, uint64_t *stream_id,
uint64_t tracefile_size, uint64_t tracefile_count,
int relayd_add_stream(struct lttcomm_relayd_sock *sock, const char *channel_name,
const char *pathname, uint64_t *stream_id,
uint64_t tracefile_size, uint64_t tracefile_count,
lttng_uuid sessiond_uuid;
/* Sessiond session id */
uint64_t session_id;
lttng_uuid sessiond_uuid;
/* Sessiond session id */
uint64_t session_id;
- LTTNG_OPTIONAL_COMM(uint64_t) current_chunk_id;
+ /* Session creation time, in seconds since UNIX Epoch. */
+ uint64_t creation_time;
+ LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id;
/* Contains the session_name and hostname */
char names[];
} LTTNG_PACKED;
/* Contains the session_name and hostname */
char names[];
} LTTNG_PACKED;