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.
diff --git a/src/session.c b/src/session.c
index f608c46..782d488 100644
--- a/src/session.c
+++ b/src/session.c
@@ -156,7 +156,8 @@
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 @@
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),