]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: use zero as the request counter if there is no stream
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 13:52:59 +0000 (15:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 18:01:23 +0000 (20:01 +0200)
When s==NULL we don't have any assigned request counter. Ideally we
should proceed exactly like when a stream is initialized and assign
a unique value. For now we only place it into a local variable.

src/log.c

index 8491dbabba6e4e0a30fef65d5653ecbe06351f10..52223e9bf2bdc62a176e506d2534adafe3e8198f 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1576,6 +1576,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
        const struct strm_logs *logs = s ? &s->logs : NULL;
        const struct connection *be_conn = s ? cs_conn(objt_cs(s->si[1].end)) : NULL;
        unsigned int s_flags = s ? s->flags : 0;
+       unsigned int uniq_id = s ? s->uniq_id : 0;
        struct buffer chunk;
        char *uri;
        char *spc;
@@ -2448,13 +2449,13 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
 
                        case LOG_FMT_COUNTER: // %rt
                                if (tmp->options & LOG_OPT_HEXA) {
-                                       iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", s->uniq_id);
+                                       iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", uniq_id);
                                        if (iret < 0 || iret > dst + maxsize - tmplog)
                                                goto out;
                                        last_isspace = 0;
                                        tmplog += iret;
                                } else {
-                                       ret = ltoa_o(s->uniq_id, tmplog, dst + maxsize - tmplog);
+                                       ret = ltoa_o(uniq_id, tmplog, dst + maxsize - tmplog);
                                        if (ret == NULL)
                                                goto out;
                                        tmplog = ret;