char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
- uint64_t *current_chunk_id)
+ bool *has_current_chunk, uint64_t *current_chunk_id)
{
int ret;
struct lttcomm_relayd_create_session_2_11 header;
header.session_name_len = be32toh(header.session_name_len);
header.hostname_len = be32toh(header.hostname_len);
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;
lttng_uuid_copy(sessiond_uuid, header.sessiond_uuid);
*live_timer = header.live_timer;
*snapshot = !!header.snapshot;
+ *current_chunk_id = header.current_chunk_id.value;
+ *has_current_chunk = header.current_chunk_id.is_set;
ret = 0;
char *session_name, char *hostname,
uint32_t *live_timer, bool *snapshot,
uint64_t *id_sessiond, lttng_uuid sessiond_uuid,
- uint64_t *current_chunk_id);
+ bool *has_current_chunk, uint64_t *current_chunk_id);
int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
char **ret_path_name, char **ret_channel_name,
ret = cmd_create_session_2_4(payload, session_name,
hostname, &live_timer, &snapshot);
} else {
+ bool has_current_chunk;
+
/* From 2.11 to ... */
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);
if (lttng_uuid_is_nil(sessiond_uuid)) {
/* The nil UUID is reserved for pre-2.11 clients. */
goto send_reply;
}
id_sessiond.is_set = true;
- current_chunk_id.is_set = true;
+ current_chunk_id.is_set = has_current_chunk;
}
if (ret < 0) {
reply.session_id = htobe64(session->id);
- session->current_trace_chunk =
- sessiond_trace_chunk_registry_get_anonymous_chunk(
- sessiond_trace_chunk_registry, sessiond_uuid,
- session->id);
- if (!session->current_trace_chunk) {
- ret = -1;
- }
-
send_reply:
if (ret < 0) {
reply.ret_code = htobe32(LTTNG_ERR_FATAL);
return status;
}
+static
+bool is_valid_chunk_name(const char *name)
+{
+ size_t len;
+
+ if (!name) {
+ return false;
+ }
+
+ len = strnlen(name, LTTNG_NAME_MAX);
+ if (len == 0 || len == LTTNG_NAME_MAX) {
+ return false;
+ }
+
+ if (strchr(name, '/') || strchr(name, '.')) {
+ return false;
+ }
+
+ return true;
+}
+
LTTNG_HIDDEN
enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
struct lttng_trace_chunk *chunk, const char *name)
char *new_name;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
- if (!name || !*name || strnlen(name, LTTNG_NAME_MAX) == LTTNG_NAME_MAX) {
+ if (!is_valid_chunk_name(name)) {
ERR("Attempted to set an invalid name on a trace chunk: name = %s",
name ? : "NULL");
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT;