X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Frelayd%2Frelayd.c;h=87782e99477af6b3321ca40d597ed7b5c521f9b0;hb=db1da059574b86008035b12968446863ab6de866;hp=b065f364eb67f3e06410b9c3043082abdd8f85ad;hpb=e5add6d004793894ef4c7e047bc0f8885763b205;p=lttng-tools.git diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index b065f364e..87782e994 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -130,7 +130,8 @@ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock, 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; @@ -176,6 +177,8 @@ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock, 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) { @@ -248,7 +251,8 @@ int relayd_create_session(struct lttcomm_relayd_sock *rsock, 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; @@ -270,7 +274,7 @@ int relayd_create_session(struct lttcomm_relayd_sock *rsock, ret = relayd_create_session_2_11(rsock, session_name, hostname, session_live_timer, snapshot, sessiond_session_id, sessiond_uuid, - current_chunk_id); + current_chunk_id, creation_time); } if (ret < 0) { @@ -1252,11 +1256,8 @@ int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock, } } - ret = send_command(sock, - RELAYD_CREATE_TRACE_CHUNK, - payload.data, - payload.size, - 0); + ret = send_command(sock, RELAYD_CREATE_TRACE_CHUNK, payload.data, + payload.size, 0); if (ret < 0) { ERR("Failed to send trace chunk creation command to relay daemon"); goto end; @@ -1283,3 +1284,78 @@ end: lttng_dynamic_buffer_reset(&payload); return ret; } + +int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock, + struct lttng_trace_chunk *chunk) +{ + int ret = 0; + enum lttng_trace_chunk_status status; + struct lttcomm_relayd_close_trace_chunk msg = {}; + struct lttcomm_relayd_generic_reply reply = {}; + uint64_t chunk_id; + time_t close_timestamp; + LTTNG_OPTIONAL(enum lttng_trace_chunk_command_type) close_command = {}; + + status = lttng_trace_chunk_get_id(chunk, &chunk_id); + if (status != LTTNG_TRACE_CHUNK_STATUS_OK) { + ERR("Failed to get trace chunk id"); + ret = -1; + goto end; + } + + status = lttng_trace_chunk_get_close_timestamp(chunk, &close_timestamp); + if (status != LTTNG_TRACE_CHUNK_STATUS_OK) { + ERR("Failed to get trace chunk close timestamp"); + ret = -1; + goto end; + } + + status = lttng_trace_chunk_get_close_command(chunk, + &close_command.value); + switch (status) { + case LTTNG_TRACE_CHUNK_STATUS_OK: + close_command.is_set = 1; + break; + case LTTNG_TRACE_CHUNK_STATUS_NONE: + break; + default: + ERR("Failed to get trace chunk close command"); + ret = -1; + goto end; + } + + msg = (typeof(msg)){ + .chunk_id = htobe64(chunk_id), + .close_timestamp = htobe64((uint64_t) close_timestamp), + .close_command = { + .value = htobe32((uint32_t) close_command.value), + .is_set = close_command.is_set, + }, + }; + + ret = send_command(sock, RELAYD_CLOSE_TRACE_CHUNK, &msg, sizeof(msg), + 0); + if (ret < 0) { + ERR("Failed to send trace chunk close command to relay daemon"); + goto end; + } + + ret = recv_reply(sock, &reply, sizeof(reply)); + if (ret < 0) { + ERR("Failed to receive relay daemon trace chunk close command reply"); + goto end; + } + + reply.ret_code = be32toh(reply.ret_code); + if (reply.ret_code != LTTNG_OK) { + ret = -1; + ERR("Relayd trace chunk close replied error %d", + reply.ret_code); + } else { + ret = 0; + DBG("Relayd successfully closed trace chunk: chunk_id = %" PRIu64, + chunk_id); + } +end: + return ret; +}