[master] 72d3574 Log SessionOpen with VSL() so we can be sure it is always the first VSL record for a session.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Jul 3 09:54:48 CEST 2012
commit 72d35747a9ed1f2d5a5d146df4b5eceedb201981
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jul 3 07:53:42 2012 +0000
Log SessionOpen with VSL() so we can be sure it is always the first
VSL record for a session.
Make $log_local_address default to on.
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 64ee6f5..7f88212 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -149,18 +149,20 @@ ses_pool_task(struct worker *wrk, void *arg)
}
/*--------------------------------------------------------------------
+ * VSL log the endpoints of the TCP connection.
+ *
+ * We use VSL() to get the sessions vxid and to make sure tha this
+ * VSL comes before anything else for this session.
*/
+
static void
-ses_vsl_socket(struct req *req, const char *lsockname)
+ses_vsl_socket(struct sess *sp, const char *lsockname)
{
char laddr[ADDR_BUFSIZE];
char lport[PORT_BUFSIZE];
- struct sess *sp;
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- AN(lsockname);
- sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ AN(lsockname);
VTCP_name(&sp->sockaddr, sp->sockaddrlen,
sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
@@ -169,14 +171,12 @@ ses_vsl_socket(struct req *req, const char *lsockname)
&sp->mysockaddrlen));
VTCP_name(&sp->mysockaddr, sp->mysockaddrlen,
laddr, sizeof laddr, lport, sizeof lport);
- /* XXX: have no req yet */
- VSLb(req->vsl, SLT_SessionOpen, "%s %s %s %s %s",
- sp->addr, sp->port, lsockname, laddr, lport);
} else {
- /* XXX: have no req yet */
- VSLb(req->vsl, SLT_SessionOpen, "%s %s %s - -",
- sp->addr, sp->port, lsockname);
+ strcpy(laddr, "-");
+ strcpy(lport, "-");
}
+ VSL(SLT_SessionOpen, sp->vxid, "%s %s %s %s %s",
+ sp->addr, sp->port, lsockname, laddr, lport);
}
/*--------------------------------------------------------------------
@@ -210,13 +210,13 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
sp->vxid = VXID_Get(&wrk->vxid_pool);
lsockname = VCA_SetupSess(wrk, sp);
+ ses_vsl_socket(sp, lsockname);
req = ses_GetReq(sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->vxid = VXID_Get(&wrk->vxid_pool);
- ses_vsl_socket(req, lsockname);
wrk->acct_tmp.sess++;
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index d17f9e2..b030caa 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -1047,9 +1047,11 @@ static const struct parspec input_parspec[] = {
"on", "bool" },
{ "log_local_address", tweak_bool, &mgt_param.log_local_addr, 0, 0,
"Log the local address on the TCP connection in the "
- "SessionOpen shared memory record.\n",
+ "SessionOpen VSL record.\n"
+ "Disabling this saves a getsockname(2) system call "
+ "per TCP connection.\n",
0,
- "off", "bool" },
+ "on", "bool" },
{ "waiter", tweak_waiter, NULL, 0, 0,
"Select the waiter kernel interface.\n",
WIZARD | MUST_RESTART,
diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc
index 598eae9..e0c5afa 100644
--- a/bin/varnishtest/tests/c00003.vtc
+++ b/bin/varnishtest/tests/c00003.vtc
@@ -8,6 +8,7 @@ server s1 {
# This requires non-local binds to be disabled. If you see this fail
# and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0.
varnish v1 -cliok "param.set listen_address ${bad_ip}:0"
+varnish v1 -cliok "param.set log_local_address off"
varnish v1 -vcl+backend {} -clierr 300 start
varnish v1 -cliok "param.set listen_address 127.0.0.1:0,${bad_ip}:9082"
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 5a6c862..c79f378 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -37,7 +37,7 @@
*
* Arguments:
* Tag-Name
- * Short Description (1 line, max ?? chars)
+ * Short Description (1 line, max ? chars)
* Long Description (in RST "definition list" format)
*/
@@ -69,9 +69,9 @@ SLTM(SessionOpen, "Client connection opened",
"socket-endpoints of the connection.\n\n"
"caddr\n Client IPv4/6 address\n\n"
"cport\n Client TCP port\n\n"
- "lsock\n Listen socket name\n\n"
- "laddr\n Local IPv4/6 address ('-' if $log_local_addr not set)\n\n"
- "lport\n Local TCP port ('-' if $log_local_addr not set)\n\n"
+ "lsock\n Listen socket\n\n"
+ "laddr\n Local IPv4/6 address ('-' if !$log_local_addr)\n\n"
+ "lport\n Local TCP port ('-' if !$log_local_addr)\n\n"
)
SLTM(SessionClose, "Client connection closed",
@@ -81,11 +81,11 @@ SLTM(SessionClose, "Client connection closed",
"'Connection: close' - The client specifed that keepalive should "
"be disabled by sending a 'Connection: close' header. "
"'no request' - No initial request was received within sess_timeout. "
- "'EOF' - ??? "
- "'remote closed' - ??? "
+ "'EOF' - ? "
+ "'remote closed' - ? "
"'error' - Processing reached vcl_error even if the status code "
"indicates success. "
- "' blast' - ???"
+ "' blast' - ?"
)
SLTM(BackendOpen, "Backend connection opened", "")
SLTM(BackendXID, "The unique ID of the backend transaction", "")
More information about the varnish-commit
mailing list