From c269f664bd07202b0879c16a2cc492ccd153d2e5 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 22 Oct 2021 17:47:14 +0200 Subject: [PATCH] MINOR: session: Rely on client source address at session level to log error When an embryonic session is killed, if no log format is defined for this error, a generic error is emitted. When this happens, we now rely on the session to get the client source address. For now, session addresses are never set. So, thanks to the fallback mechanism, no changes are expected with this patch. But its purpose is to rely on addresses at the session level when set instead of those at the connection level. --- src/session.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/session.c b/src/session.c index 06ace8a0f6..0b0a9a49f1 100644 --- a/src/session.c +++ b/src/session.c @@ -302,19 +302,20 @@ int session_accept_fd(struct connection *cli_conn) */ static void session_prepare_log_prefix(struct session *sess) { + const struct sockaddr_storage *src; struct tm tm; char pn[INET6_ADDRSTRLEN]; int ret; char *end; - struct connection *cli_conn = __objt_conn(sess->origin); - ret = conn_get_src(cli_conn) ? addr_to_str(cli_conn->src, pn, sizeof(pn)) : 0; + src = sess_src(sess); + ret = (src ? addr_to_str(src, pn, sizeof(pn)) : 0); if (ret <= 0) chunk_printf(&trash, "unknown ["); else if (ret == AF_UNIX) chunk_printf(&trash, "%s:%d [", pn, sess->listener->luid); else - chunk_printf(&trash, "%s:%d [", pn, get_host_port(cli_conn->src)); + chunk_printf(&trash, "%s:%d [", pn, get_host_port(src)); get_localtime(sess->accept_date.tv_sec, &tm); end = date2str_log(trash.area + trash.data, &tm, &(sess->accept_date),