]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DOC: log: Add comments to specify when session's listener is defined or not
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Nov 2021 10:31:08 +0000 (11:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Nov 2021 10:31:09 +0000 (11:31 +0100)
When a log message is emitted, The session's listener is always defined when
the session's owner is an inbound connection while it is undefined for a
health-check. It is not obvious. So, comments have been added to make it
clear.

This patch is related to the issue #1434.

src/log.c

index e7607c2c4c0f52b78529a5f12a1de14964f1923e..ecf771221d117d75ed6f5f5039407141997ab707 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2117,6 +2117,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                        case LOG_FMT_CLIENTPORT:  // %cp
                                addr = (s ? si_src(&s->si[0]) : sess_src(sess));
                                if (addr) {
+                                       /* sess->listener is always defined when the session's owner is an inbound connections */
                                        if (addr->ss_family == AF_UNIX)
                                                ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog);
                                        else
@@ -2147,6 +2148,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                        case  LOG_FMT_FRONTENDPORT: // %fp
                                addr = (s ? si_dst(&s->si[0]) : sess_dst(sess));
                                if (addr) {
+                                       /* sess->listener is always defined when the session's owner is an inbound connections */
                                        if (addr->ss_family == AF_UNIX)
                                                ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog);
                                        else
@@ -2319,6 +2321,8 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                                if (iret == 0)
                                        goto out;
                                tmplog += iret;
+
+                               /* sess->listener may be undefined if the session's owner is a health-check */
                                if (sess->listener && sess->listener->bind_conf->xprt == xprt_get(XPRT_SSL))
                                        LOGCHAR('~');
                                if (tmp->options & LOG_OPT_QUOTE)