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.
This commit is contained in:
Christopher Faulet 2021-11-15 11:31:08 +01:00
parent d9e6b35701
commit 1ccbe12f4a
1 changed files with 4 additions and 0 deletions

View File

@ -2117,6 +2117,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
case LOG_FMT_CLIENTPORT: // %cp case LOG_FMT_CLIENTPORT: // %cp
addr = (s ? si_src(&s->si[0]) : sess_src(sess)); addr = (s ? si_src(&s->si[0]) : sess_src(sess));
if (addr) { if (addr) {
/* sess->listener is always defined when the session's owner is an inbound connections */
if (addr->ss_family == AF_UNIX) if (addr->ss_family == AF_UNIX)
ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog); ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog);
else else
@ -2147,6 +2148,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
case LOG_FMT_FRONTENDPORT: // %fp case LOG_FMT_FRONTENDPORT: // %fp
addr = (s ? si_dst(&s->si[0]) : sess_dst(sess)); addr = (s ? si_dst(&s->si[0]) : sess_dst(sess));
if (addr) { if (addr) {
/* sess->listener is always defined when the session's owner is an inbound connections */
if (addr->ss_family == AF_UNIX) if (addr->ss_family == AF_UNIX)
ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog); ret = ltoa_o(sess->listener->luid, tmplog, dst + maxsize - tmplog);
else else
@ -2319,6 +2321,8 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
if (iret == 0) if (iret == 0)
goto out; goto out;
tmplog += iret; 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)) if (sess->listener && sess->listener->bind_conf->xprt == xprt_get(XPRT_SSL))
LOGCHAR('~'); LOGCHAR('~');
if (tmp->options & LOG_OPT_QUOTE) if (tmp->options & LOG_OPT_QUOTE)