mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MINOR: session: use conn->src instead of conn->addr.from
In session_accept_fd() we'll soon have to dynamically allocate the address, or better, steal it from the caller and define a strict calling convention regarding who's responsible for the freeing. In the simpler session_prepare_log_prefix(), just add an attempt to retrieve the address if not yet set and do not dereference it on failure.
This commit is contained in:
parent
026efc71c8
commit
4d3c60ad8d
@ -156,7 +156,8 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
|
||||
goto out_close;
|
||||
|
||||
cli_conn->handle.fd = cfd;
|
||||
cli_conn->addr.from = *addr;
|
||||
/* FIXME WTA: an allocation will be needed here. Better steal the original address on success */
|
||||
*cli_conn->src = *addr;
|
||||
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
|
||||
cli_conn->target = &l->obj_type;
|
||||
cli_conn->proxy_netns = l->netns;
|
||||
@ -327,13 +328,13 @@ static void session_prepare_log_prefix(struct session *sess)
|
||||
char *end;
|
||||
struct connection *cli_conn = __objt_conn(sess->origin);
|
||||
|
||||
ret = addr_to_str(&cli_conn->addr.from, pn, sizeof(pn));
|
||||
ret = conn_get_src(cli_conn) ? addr_to_str(cli_conn->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->addr.from));
|
||||
chunk_printf(&trash, "%s:%d [", pn, get_host_port(cli_conn->src));
|
||||
|
||||
get_localtime(sess->accept_date.tv_sec, &tm);
|
||||
end = date2str_log(trash.area + trash.data, &tm, &(sess->accept_date),
|
||||
|
Loading…
x
Reference in New Issue
Block a user