X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Frotate.c;h=4873e5495f9bc15b6cef96ce60a22d939713ba65;hp=e2a4c509ae6464ce04cd6c182fd789a9d02692d1;hb=ce0b1d61919f37517a6212f7af2afe0fa1b1dcb0;hpb=d295668767ac8234e83984e1812d342d03293d88 diff --git a/src/bin/lttng/commands/rotate.c b/src/bin/lttng/commands/rotate.c index e2a4c509a..4873e5495 100644 --- a/src/bin/lttng/commands/rotate.c +++ b/src/bin/lttng/commands/rotate.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2017 - Julien Desfossez + * Copyright (C) 2017 Julien Desfossez * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -57,101 +47,6 @@ static struct poptOption long_options[] = { {0, 0, 0, 0, 0, 0, 0} }; -static int output_trace_archive_location( - const struct lttng_trace_archive_location *location, - const char *session_name) -{ - int ret = 0; - enum lttng_trace_archive_location_type location_type; - enum lttng_trace_archive_location_status status; - bool printed_location = false; - - location_type = lttng_trace_archive_location_get_type(location); - - _MSG("Trace chunk archive for session %s is now readable", - session_name); - switch (location_type) { - case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL: - { - const char *absolute_path; - - status = lttng_trace_archive_location_local_get_absolute_path( - location, &absolute_path); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - MSG(" at %s", absolute_path); - printed_location = true; - break; - } - case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY: - { - uint16_t control_port, data_port; - const char *host, *relative_path, *protocol_str; - enum lttng_trace_archive_location_relay_protocol_type protocol; - - /* Fetch all relay location parameters. */ - status = lttng_trace_archive_location_relay_get_protocol_type( - location, &protocol); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - - status = lttng_trace_archive_location_relay_get_host( - location, &host); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - - status = lttng_trace_archive_location_relay_get_control_port( - location, &control_port); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - - status = lttng_trace_archive_location_relay_get_data_port( - location, &data_port); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - - status = lttng_trace_archive_location_relay_get_relative_path( - location, &relative_path); - if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { - ret = -1; - goto end; - } - - switch (protocol) { - case LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP: - protocol_str = "tcp"; - break; - default: - protocol_str = "unknown"; - break; - } - - MSG(" on relay %s://%s/%s [control port %" PRIu16 ", data port %" - PRIu16 "]", protocol_str, host, - relative_path, control_port, data_port); - printed_location = true; - break; - } - default: - break; - } -end: - if (!printed_location) { - MSG(" at an unknown location"); - } - return ret; -} - static int rotate_tracing(char *session_name) { int ret; @@ -199,7 +94,7 @@ static int rotate_tracing(char *session_name) } if (rotation_state == LTTNG_ROTATION_STATE_ONGOING) { - ret = usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME); + ret = usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US); if (ret) { PERROR("\nusleep"); goto error; @@ -240,7 +135,7 @@ skip_wait: } if (!lttng_opt_mi && print_location) { - ret = output_trace_archive_location(location, + ret = print_trace_archive_location(location, session_name); } else if (lttng_opt_mi) { ret = mi_lttng_rotate(writer, session_name, rotation_state,