]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
report: rearrange handling connection drop when skipping metrics
authorIvan Kruglov <mail@ikruglov.com>
Wed, 11 Feb 2026 12:44:00 +0000 (04:44 -0800)
committerIvan Kruglov <mail@ikruglov.com>
Mon, 16 Feb 2026 10:34:11 +0000 (02:34 -0800)
src/report/report.c

index 6909f78455cb8b4a238db9ff54f8bb1604a13a87..0eaa898514fd75a60bb1dbdf04bcdeb77d7bd23b 100644 (file)
@@ -85,15 +85,22 @@ static int metrics_on_query_reply(
                         log_info("Varlink timed out");
                 else
                         log_error("Varlink error: %s", error_id);
-        } else if (context->n_metrics >= METRICS_MAX)
+
+                goto finish;
+        }
+
+        if (context->n_metrics >= METRICS_MAX) {
                 context->n_skipped_metrics++;
-        else {
-                /* Collect metrics for later sorting */
-                if (!GREEDY_REALLOC(context->metrics, context->n_metrics + 1))
-                        return log_oom();
-                context->metrics[context->n_metrics++] = sd_json_variant_ref(parameters);
+                goto finish;
         }
 
+        /* Collect metrics for later sorting */
+        if (!GREEDY_REALLOC(context->metrics, context->n_metrics + 1))
+                return log_oom();
+
+        context->metrics[context->n_metrics++] = sd_json_variant_ref(parameters);
+
+finish:
         if (!FLAGS_SET(flags, SD_VARLINK_REPLY_CONTINUES)) {
                 assert_se(set_remove(context->links, link) == link);
                 link = sd_varlink_close_unref(link);