X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fmain.c;h=4e30ac49882e5c392097b51dfedf95b0d7207686;hp=749feb6f6f319a95c86d62a68af0b5f693a7c4d3;hb=f77a6ec2ae90f5d58e9389e47228c18b081cf97a;hpb=a7ceb342d473cc37e00d74c45b04b5378965e055 diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 749feb6f6..4e30ac498 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2372,7 +2372,6 @@ static int relay_rotate_session_streams( } else { chunk_id_str = chunk_id_buf; } - session->has_rotated = true; } DBG("Rotate %" PRIu32 " streams of session \"%s\" to chunk \"%s\"", @@ -2700,6 +2699,20 @@ static int relay_close_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr, } pthread_mutex_lock(&session->lock); + if (close_command.is_set && + close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE) { + /* + * Clear command. It is a protocol error to ask for a + * clear on a relay which does not allow it. Querying + * the configuration allows figuring out whether + * clearing is allowed before doing the clear. + */ + if (!opt_allow_clear) { + ret = -1; + reply_code = LTTNG_ERR_INVALID_PROTOCOL; + goto end_unlock_session; + } + } if (session->pending_closure_trace_chunk && session->pending_closure_trace_chunk != chunk) { ERR("Trace chunk close command for session \"%s\" does not target the trace chunk pending closure", @@ -2803,6 +2816,10 @@ static int relay_close_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr, goto end_unlock_session; } } + if (close_command.is_set && + close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED) { + session->has_rotated = true; + } DBG("Reply chunk path on close: %s", closed_trace_chunk_path); path_length = strlen(closed_trace_chunk_path) + 1; if (path_length > UINT32_MAX) {