This is equivalent to `stream_generate_unique_id()`, just for checks.
Reviewed-by: Volker Dusch <[email protected]>
---
include/haproxy/check.h | 1 +
src/check.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/haproxy/check.h b/include/haproxy/check.h
index 09e195a46..a93084cb4 100644
--- a/include/haproxy/check.h
+++ b/include/haproxy/check.h
@@ -80,6 +80,7 @@ struct task *srv_chk_io_cb(struct task *t, void *ctx,
unsigned int state);
int check_buf_available(void *target);
struct buffer *check_get_buf(struct check *check, struct buffer *bptr,
unsigned int small_buffer);
void check_release_buf(struct check *check, struct buffer *bptr);
+struct ist check_generate_unique_id(struct check *check, struct lf_expr
*format);
const char *init_check(struct check *check, int type);
void free_check(struct check *check);
void check_purge(struct check *check);
diff --git a/src/check.c b/src/check.c
index b75a9dd57..f81b82ea1 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1536,6 +1536,23 @@ void check_release_buf(struct check *check, struct
buffer *bptr)
}
}
+/* See stream_generate_unique_id(). */
+struct ist check_generate_unique_id(struct check *check, struct lf_expr
*format)
+{
+ if (!isttest(check->unique_id)) {
+ char *unique_id;
+ size_t len;
+
+ if ((unique_id = pool_alloc(pool_head_uniqueid)) == NULL)
+ return IST_NULL;
+
+ len = sess_build_logline(check->sess, NULL, unique_id,
UNIQUEID_LEN, format);
+ check->unique_id = ist2(unique_id, len);
+ }
+
+ return check->unique_id;
+}
+
const char *init_check(struct check *check, int type)
{
check->type = type;
--
2.53.0