]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: Allow inlining of `stream_generate_unique_id()`
authorTim Duesterhus <tim@bastelstu.be>
Mon, 13 Apr 2026 17:37:28 +0000 (19:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Apr 2026 18:01:42 +0000 (20:01 +0200)
With the introduction of the `generate_unique_id()` helper, the actual
complicated logic is sitting in a different file. Allow inlining of
`stream_generate_unique_id()`, so that callers can benefit from an abstraction
without hiding away the access of `strm->unique_id` behind a function call.

include/haproxy/log.h
include/haproxy/stream.h
src/stream.c

index 98483eee0e7cf2be4834c8898d02f0af0ccd7d31..f1610a29708c6659810bc42fdd3f13a7f490fd52 100644 (file)
@@ -198,6 +198,15 @@ char * get_format_pid_sep2(int format, size_t *len);
 
 void generate_unique_id(struct ist *dst, struct session *sess, struct stream *strm, struct lf_expr *format);
 
+static inline struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format)
+{
+       if (!isttest(strm->unique_id)) {
+               generate_unique_id(&strm->unique_id, strm_sess(strm), strm, format);
+       }
+
+       return strm->unique_id;
+}
+
 /*
  * Builds a log line for the stream (must be valid).
  */
index 09732bcf29286587a98124ae61df581e9990dd7f..fe66d6cb433f5cd40975ae89e37f1fdddb3d483e 100644 (file)
@@ -69,8 +69,6 @@ void stream_shutdown_self(struct stream *stream, int why);
 void stream_dump_and_crash(enum obj_type *obj, int rate);
 void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const char *pfx, uint32_t anon_key);
 
-struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format);
-
 void stream_process_counters(struct stream *s);
 void sess_change_server(struct stream *strm, struct server *newsrv);
 struct task *process_stream(struct task *t, void *context, unsigned int state);
index 9e026c23de59abb55f8102fa7f8f9cc299d040fa..ac9fc42d184b6ee17cc961fec5460a3fe5960ab2 100644 (file)
@@ -3083,23 +3083,6 @@ static void init_stream()
 }
 INITCALL0(STG_INIT, init_stream);
 
-/* Generates a unique ID based on the given <format>, stores it in the given <strm> and
- * returns the unique ID.
- *
- * If this function fails to allocate memory IST_NULL is returned.
- *
- * If an ID is already stored within the stream nothing happens existing unique ID is
- * returned.
- */
-struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format)
-{
-       if (!isttest(strm->unique_id)) {
-               generate_unique_id(&strm->unique_id, strm_sess(strm), strm, format);
-       }
-
-       return strm->unique_id;
-}
-
 /************************************************************************/
 /*           All supported ACL keywords must be declared here.          */
 /************************************************************************/