r2745 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Jun 20 16:47:51 CEST 2008


Author: phk
Date: 2008-06-20 16:47:50 +0200 (Fri, 20 Jun 2008)
New Revision: 2745

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/heritage.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
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).



Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2008-06-20 13:08:52 UTC (rev 2744)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2008-06-20 14:47:50 UTC (rev 2745)
@@ -119,8 +119,16 @@
 	    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);

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h	2008-06-20 13:08:52 UTC (rev 2744)
+++ trunk/varnish-cache/bin/varnishd/heritage.h	2008-06-20 14:47:50 UTC (rev 2745)
@@ -162,6 +162,9 @@
 
 	/* Log hash string to shm */
 	unsigned		log_hash;
+
+	/* Log local socket address to shm */
+	unsigned		log_local_addr;
 };
 
 extern volatile struct params *params;

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-06-20 13:08:52 UTC (rev 2744)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-06-20 14:47:50 UTC (rev 2745)
@@ -747,6 +747,11 @@
 		"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"




More information about the varnish-commit mailing list