- if (session->rotation_status == LTTNG_ROTATION_STATUS_ERROR) {
- DBG("An error occurred during rotation");
- (*pending_return)->status = LTTNG_ROTATION_STATUS_ERROR;
- /* Rotate with a relay */
- } else if (session->rotate_pending_relay) {
- DBG("Session %s, rotate_id %" PRIu64 " still pending",
- session->name, session->rotate_count);
- (*pending_return)->status = LTTNG_ROTATION_STATUS_STARTED;
- } else if (session->rotate_pending) {
- DBG("Session %s, rotate_id %" PRIu64 " still pending",
- session->name, session->rotate_count);
- (*pending_return)->status = LTTNG_ROTATION_STATUS_STARTED;
- } else {
- DBG("Session %s, rotate_id %" PRIu64 " finished",
- session->name, session->rotate_count);
- (*pending_return)->status = LTTNG_ROTATION_STATUS_COMPLETED;
- ret = lttng_strncpy((*pending_return)->output_path,
+ switch (session->rotation_state) {
+ case LTTNG_ROTATION_STATE_ONGOING:
+ DBG("Reporting that rotation id %" PRIu64 " of session %s is still pending",
+ rotation_id, session->name);
+ break;
+ case LTTNG_ROTATION_STATE_COMPLETED:
+ {
+ char *current_tracing_path_reply;
+ size_t current_tracing_path_reply_len;
+
+ switch (session_get_consumer_destination_type(session)) {
+ case CONSUMER_DST_LOCAL:
+ current_tracing_path_reply =
+ info_return->location.local.absolute_path;
+ current_tracing_path_reply_len =
+ sizeof(info_return->location.local.absolute_path);
+ info_return->location_type =
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL;
+ break;
+ case CONSUMER_DST_NET:
+ current_tracing_path_reply =
+ info_return->location.relay.relative_path;
+ current_tracing_path_reply_len =
+ sizeof(info_return->location.relay.relative_path);
+ /* Currently the only supported relay protocol. */
+ info_return->location.relay.protocol =
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP;
+
+ ret = lttng_strncpy(info_return->location.relay.host,
+ session_get_net_consumer_hostname(session),
+ sizeof(info_return->location.relay.host));
+ if (ret) {
+ ERR("Failed to host name to rotate_get_info reply");
+ info_return->status = LTTNG_ROTATION_STATUS_ERROR;
+ ret = -LTTNG_ERR_UNK;
+ goto end;
+ }
+
+ session_get_net_consumer_ports(session,
+ &info_return->location.relay.ports.control,
+ &info_return->location.relay.ports.data);
+ info_return->location_type =
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY;
+ break;
+ default:
+ abort();
+ }
+ ret = lttng_strncpy(current_tracing_path_reply,