]> err.no Git - varnish/commitdiff
Add a boolean paramter "log_local_address" which enables logging of
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jun 2008 14:47:50 +0000 (14:47 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Jun 2008 14:47:50 +0000 (14:47 +0000)
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: svn+ssh://projects.linpro.no/svn/varnish/trunk@2745 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_param.c

index 27770ea863ff83aa1bdeb6d1ec5678f8e0eefb2f..60dfb9d2d93c16b07764f111bec20c91cc046c6d 100644 (file)
@@ -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);
index 3e8926186d9eff4cfaa3de29195386f1074a86c0..10970a929d1053d40aeda14be98b87874d20d7eb 100644 (file)
@@ -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;
index cb27e4f49c388ad6627a6b74eb2066c282f6cc2d..c3fde9834248afab96ce29cbacb05f6a3794c28e 100644 (file)
@@ -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"