Commit 1902da85 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a boolean paramter "log_local_address" which enables logging of

the local socket address in the SessionOpen records in SHM.

This costs us an extra getsockname(2) call per connection, so default
to off.

SHM clients can tell the state of this option by the number of fields
in SessionOpen: 3 (off) or 4 (on).



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2745 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 92019e05
......@@ -119,8 +119,16 @@ VCA_Prep(struct sess *sp)
addr, sizeof addr, port, sizeof port);
sp->addr = WS_Dup(sp->ws, addr);
sp->port = WS_Dup(sp->ws, port);
VSL(SLT_SessionOpen, sp->fd, "%s %s %s",
sp->addr, sp->port, sp->mylsock->name);
if (params->log_local_addr) {
AZ(getsockname(sp->fd, sp->mysockaddr, &sp->mysockaddrlen));
TCP_name(sp->mysockaddr, sp->mysockaddrlen,
addr, sizeof addr, port, sizeof port);
VSL(SLT_SessionOpen, sp->fd, "%s %s %s %s",
sp->addr, sp->port, addr, port);
} else {
VSL(SLT_SessionOpen, sp->fd, "%s %s %s",
sp->addr, sp->port, sp->mylsock->name);
}
sp->acct.first = sp->t_open;
if (need_test)
sock_test(sp->fd);
......
......@@ -162,6 +162,9 @@ struct params {
/* Log hash string to shm */
unsigned log_hash;
/* Log local socket address to shm */
unsigned log_local_addr;
};
extern volatile struct params *params;
......
......@@ -747,6 +747,11 @@ static const struct parspec parspec[] = {
"Log the hash string to shared memory log.\n",
0,
"off", "bool" },
{ "log_local_address", tweak_bool, &master.log_local_addr, 0, 0,
"Log the local address on the TCP connection in the "
"SessionOpen shared memory record.\n",
0,
"off", "bool" },
{ "diag_bitmap", tweak_diag_bitmap, 0, 0, 0,
"Bitmap controlling diagnostics code:\n"
" 0x00000001 - CNT_Session states.\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment