From: Tim Duesterhus Date: Mon, 13 Apr 2026 17:37:28 +0000 (+0200) Subject: MINOR: Allow inlining of `stream_generate_unique_id()` X-Git-Tag: v3.4-dev9~38 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=38796d4c061ed7698e6202d10e6e78c479044cb4;p=thirdparty%2Fhaproxy.git MINOR: Allow inlining of `stream_generate_unique_id()` 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. --- diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 98483eee0..f1610a297 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -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). */ diff --git a/include/haproxy/stream.h b/include/haproxy/stream.h index 09732bcf2..fe66d6cb4 100644 --- a/include/haproxy/stream.h +++ b/include/haproxy/stream.h @@ -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); diff --git a/src/stream.c b/src/stream.c index 9e026c23d..ac9fc42d1 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3083,23 +3083,6 @@ static void init_stream() } INITCALL0(STG_INIT, init_stream); -/* Generates a unique ID based on the given , stores it in the given 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. */ /************************************************************************/