- int ret;
- struct lttcomm_relayd_rotate_pending msg;
- struct lttcomm_relayd_rotate_pending_reply reply;
-
- /* Code flow error. Safety net. */
- assert(rsock);
-
- DBG("Querying relayd for rotate pending with chunk_id %" PRIu64,
- chunk_id);
-
- memset(&msg, 0, sizeof(msg));
- msg.chunk_id = htobe64(chunk_id);
-
- /* Send command */
- ret = send_command(rsock, RELAYD_ROTATE_PENDING, (void *) &msg,
- sizeof(msg), 0);
- if (ret < 0) {
- goto error;
- }
-
- /* Receive response */
- ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
- if (ret < 0) {
- goto error;
- }
-
- reply.generic.ret_code = be32toh(reply.generic.ret_code);
-
- /* Return session id or negative ret code. */
- if (reply.generic.ret_code != LTTNG_OK) {
- ret = -reply.generic.ret_code;
- ERR("Relayd rotate pending replied with error %d", ret);
- goto error;
- } else {
- /* No error, just rotate pending state */
- if (reply.is_pending == 0 || reply.is_pending == 1) {
- ret = reply.is_pending;
- DBG("Relayd rotate pending command completed successfully with result \"%s\"",
- ret ? "rotation pending" : "rotation NOT pending");
- } else {
- ret = -LTTNG_ERR_UNK;
- }
+ 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;