Revert "sessiond: trigger: run trigger actions through an action executor"
[lttng-tools.git] / src / bin / lttng-relayd / backward-compatibility-group-by.c
index 45bbe17284b551a5f7ddb5b667a445bfc486b725..eaae4e9417edb7b1c5af88e3040004d5041ca50c 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+#include "common/time.h"
 #include <assert.h>
 #include <regex.h>
 #include <stdio.h>
@@ -17,7 +18,6 @@
 
 #include "backward-compatibility-group-by.h"
 
-#define DATETIME_STRING_SIZE 16
 #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]$"
 
@@ -28,8 +28,9 @@
  *
  * 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)
+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;
@@ -162,7 +163,7 @@ char *backward_compat_group_by_session(
                ret = regexec(&regex, local_session_name, 0, NULL, 0);
                if (ret == 0) {
                        const ssize_t local_session_name_offset =
-                                       strlen(local_session_name) - DATETIME_STRING_SIZE + 1;
+                                       strlen(local_session_name) - DATETIME_STR_LEN + 1;
 
                        assert(local_session_name_offset >= 0);
                        datetime = strdup(local_session_name +
@@ -171,8 +172,21 @@ char *backward_compat_group_by_session(
                                PERROR("Failed to parse session path: couldn't copy datetime on regex match");
                                goto error_regex;
                        }
+               } else {
+                       datetime = zmalloc(DATETIME_STR_LEN);
+                       if (!datetime) {
+                               PERROR("Failed to allocate DATETIME string");
+                               goto error;
+                       }
+
+                       ret = time_to_datetime_str(relay_session_creation_time,
+                                       datetime, DATETIME_STR_LEN);
+                       if (ret) {
+                               /* time_to_datetime_str already logs errors. */
+                               goto error;
+                       }
                }
-       } else if (len == DATETIME_STRING_SIZE &&
+       } else if (len == DATETIME_STR_LEN &&
                        !regexec(&regex, leftover_second_token_ptr, 0, NULL,
                                        0)) {
                /*
This page took 0.029178 seconds and 5 git commands to generate.