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.
This commit is contained in:
parent
f9c4d8d5be
commit
c269f664bd
|
@ -302,19 +302,20 @@ int session_accept_fd(struct connection *cli_conn)
|
||||||
*/
|
*/
|
||||||
static void session_prepare_log_prefix(struct session *sess)
|
static void session_prepare_log_prefix(struct session *sess)
|
||||||
{
|
{
|
||||||
|
const struct sockaddr_storage *src;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
char pn[INET6_ADDRSTRLEN];
|
char pn[INET6_ADDRSTRLEN];
|
||||||
int ret;
|
int ret;
|
||||||
char *end;
|
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)
|
if (ret <= 0)
|
||||||
chunk_printf(&trash, "unknown [");
|
chunk_printf(&trash, "unknown [");
|
||||||
else if (ret == AF_UNIX)
|
else if (ret == AF_UNIX)
|
||||||
chunk_printf(&trash, "%s:%d [", pn, sess->listener->luid);
|
chunk_printf(&trash, "%s:%d [", pn, sess->listener->luid);
|
||||||
else
|
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);
|
get_localtime(sess->accept_date.tv_sec, &tm);
|
||||||
end = date2str_log(trash.area + trash.data, &tm, &(sess->accept_date),
|
end = date2str_log(trash.area + trash.data, &tm, &(sess->accept_date),
|
||||||
|
|
Loading…
Reference in New Issue