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.
This commit is contained in:
Tim Duesterhus 2026-04-13 19:37:28 +02:00 committed by Willy Tarreau
parent 73040e3a8e
commit 38796d4c06
3 changed files with 9 additions and 19 deletions

View 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).
*/

View 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);

View 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. */
/************************************************************************/