From: Simon Marchi Date: Fri, 3 Sep 2021 21:31:29 +0000 (-0400) Subject: bin: compile lttng-relayd as a C++ X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=ac497a37018f3c253d2e50397294f58d33f7f24f bin: compile lttng-relayd as a C++ Same as the previous commit, but change lttng-relayd to be a C++ program. In addition to what was mentioned in previous commits: - Test test_relayd_backward_compat_group_by_session uses an object file from the relayd binary, so it's simpler to change this test to be C++ as well. - There are some declarations related to fs_handle in fd-tracker.h. Remove them, as they are already in fs-handle.h. Change-Id: I72c5fdecd2e82c30633563a47bd641af1dcfa29c Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/Makefile.am b/src/bin/lttng-relayd/Makefile.am index f6d5b2950..51b232968 100644 --- a/src/bin/lttng-relayd/Makefile.am +++ b/src/bin/lttng-relayd/Makefile.am @@ -9,23 +9,23 @@ endif bin_PROGRAMS = lttng-relayd -lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c cmd.h \ - index.c index.h live.c live.h ctf-trace.c ctf-trace.h \ - cmd-2-1.c cmd-2-1.h \ - cmd-2-2.c cmd-2-2.h \ - cmd-2-4.c cmd-2-4.h \ - cmd-2-11.c cmd-2-11.h \ - health-relayd.c health-relayd.h \ +lttng_relayd_SOURCES = main.cpp lttng-relayd.h utils.h utils.cpp cmd.h \ + index.cpp index.h live.cpp live.h ctf-trace.cpp ctf-trace.h \ + cmd-2-1.cpp cmd-2-1.h \ + cmd-2-2.cpp cmd-2-2.h \ + cmd-2-4.cpp cmd-2-4.h \ + cmd-2-11.cpp cmd-2-11.h \ + health-relayd.cpp health-relayd.h \ lttng-viewer-abi.h testpoint.h \ - viewer-stream.h viewer-stream.c \ - session.c session.h \ - stream.c stream.h \ - connection.c connection.h \ - viewer-session.c viewer-session.h \ - tracefile-array.c tracefile-array.h \ - tcp_keep_alive.c tcp_keep_alive.h \ - sessiond-trace-chunks.c sessiond-trace-chunks.h \ - backward-compatibility-group-by.c backward-compatibility-group-by.h + viewer-stream.h viewer-stream.cpp \ + session.cpp session.h \ + stream.cpp stream.h \ + connection.cpp connection.h \ + viewer-session.cpp viewer-session.h \ + tracefile-array.cpp tracefile-array.h \ + tcp_keep_alive.cpp tcp_keep_alive.h \ + sessiond-trace-chunks.cpp sessiond-trace-chunks.h \ + backward-compatibility-group-by.cpp backward-compatibility-group-by.h # link on liblttngctl for check if relayd is already alive. lttng_relayd_LDADD = $(URCU_LIBS) \ diff --git a/src/bin/lttng-relayd/backward-compatibility-group-by.c b/src/bin/lttng-relayd/backward-compatibility-group-by.c deleted file mode 100644 index 9e144f9f5..000000000 --- a/src/bin/lttng-relayd/backward-compatibility-group-by.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2019 Jonathan Rajotte - * - * SPDX-License-Identifier: GPL-2.0-only - * - */ - -#include "common/time.h" -#include -#include -#include -#include - -#include -#include -#include - -#include "backward-compatibility-group-by.h" - -#define DATETIME_REGEX \ - ".*-[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]-[0-2][0-9][0-5][0-9][0-5][0-9]$" - -/* - * Provide support for --group-output-by-session for producer >= 2.4 and < 2.11. - * Take the stream path, extract all available information, craft a new path to - * the best of our ability enforcing the group by session. - * - * Return the allocated string containing the new stream path or else NULL. - */ -char *backward_compat_group_by_session(const char *path, - const char *local_session_name, - time_t relay_session_creation_time) -{ - int ret; - size_t len; - char *leftover_ptr; - char *local_copy = NULL; - char *datetime = NULL; - char *partial_base_path = NULL; - char *filepath_per_session = NULL; - const char *second_token_ptr; - const char *leftover_second_token_ptr; - const char *hostname_ptr; - regex_t regex; - - LTTNG_ASSERT(path); - LTTNG_ASSERT(local_session_name); - LTTNG_ASSERT(local_session_name[0] != '\0'); - - DBG("Parsing path \"%s\" of session \"%s\" to create a new path that is grouped by session", - path, local_session_name); - - /* Get a local copy for strtok */ - local_copy = strdup(path); - if (!local_copy) { - PERROR("Failed to parse session path: couldn't copy input path"); - goto error; - } - - /* - * The use of strtok with '/' as delimiter is valid since we refuse '/' - * in session name and '/' is not a valid hostname character based on - * RFC-952 [1], RFC-921 [2] and refined in RFC-1123 [3]. - * [1] https://tools.ietf.org/html/rfc952 - * [2] https://tools.ietf.org/html/rfc921 - * [3] https://tools.ietf.org/html/rfc1123#page-13 - */ - - /* - * Get the hostname and possible session_name. - * Note that we can get the hostname and session name from the - * relay_session object we already have. Still, it is easier to - * tokenized the passed path to obtain the start of the path leftover. - */ - hostname_ptr = strtok_r(local_copy, "/", &leftover_ptr); - if (!hostname_ptr) { - ERR("Failed to parse session path \"%s\": couldn't identify hostname", - path); - goto error; - } - - second_token_ptr = strtok_r(NULL, "/", &leftover_ptr); - if (!second_token_ptr) { - ERR("Failed to parse session path \"%s\": couldn't identify session name", - path); - goto error; - } - - /* - * Check if the second token is a base path set at url level. This is - * legal in streaming, live and snapshot [1]. Otherwise it is the - * session name with possibly a datetime attached [2]. Note that when - * "adding" snapshot output (lttng snapshot add-output), no session name - * is present in the path by default. The handling for "base path" take - * care of this case as well. - * [1] e.g --set-url net://localhost/my_marvellous_path - * [2] Can be: - * - * When using --snapshot on session create. - * --