]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stream: Explain the two-step initialization in `stream_generate_unique_id()`
authorTim Duesterhus <tim@bastelstu.be>
Fri, 3 Apr 2026 21:28:58 +0000 (23:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Apr 2026 12:02:29 +0000 (14:02 +0200)
This two-step initialization of `strm->unique_id` looks like a refactoring
target. Add a comment to prevent regressions of the fix in
fb7b5c8a53cb4f19a223abd20660d47162aa8708.

src/stream.c

index 40f9f75ae1359868dd7873b119a286a89440a23c..0afa3059f5f3e348a30901e6218d85cc05beb9d6 100644 (file)
@@ -3102,6 +3102,9 @@ struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format
                if ((unique_id = pool_alloc(pool_head_uniqueid)) == NULL)
                        return IST_NULL;
 
+               /* Initialize ->unique_id to an empty string to prevent infinite
+                * recursion when the <format> references %[unique-id] or %ID.
+                */
                strm->unique_id = ist2(unique_id, 0);
                strm->unique_id.len = build_logline(strm, unique_id, UNIQUEID_LEN, format);