From: Christopher Faulet Date: Mon, 15 Nov 2021 10:31:08 +0000 (+0100) Subject: DOC: log: Add comments to specify when session's listener is defined or not X-Git-Tag: v2.5-dev15~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ccbe12f4a6af471bdbc8b85f98eb16ae3e4a626;p=thirdparty%2Fhaproxy.git DOC: log: Add comments to specify when session's listener is defined or not 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. --- diff --git a/src/log.c b/src/log.c index e7607c2c4c..ecf771221d 100644 --- 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)