From tfheen at projects.linpro.no Thu Dec 3 09:18:04 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Thu, 3 Dec 2009 10:18:04 +0100 (CET) Subject: r4379 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests Message-ID: <20091203091804.3F80F1F7424@projects.linpro.no> Author: tfheen Date: 2009-12-03 10:18:03 +0100 (Thu, 03 Dec 2009) New Revision: 4379 Added: branches/2.0/varnish-cache/bin/varnishtest/tests/e00017.vtc Modified: branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c Log: Merge bits of r4351 to fix off-by-one error in ESI parsing in 2.0.5 Fixes #585 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c 2009-11-27 20:22:23 UTC (rev 4378) +++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt_esi.c 2009-12-03 09:18:03 UTC (rev 4379) @@ -384,7 +384,7 @@ memcpy(c, val.b, Tlen(val)); val.b = c; val.e = val.b + s; - *val.e = '\0'; + val.e[-1] = '\0'; } if (Tlen(val) > 7 && !memcmp(val.b, "http://", 7)) { Added: branches/2.0/varnish-cache/bin/varnishtest/tests/e00017.vtc =================================================================== --- branches/2.0/varnish-cache/bin/varnishtest/tests/e00017.vtc (rev 0) +++ branches/2.0/varnish-cache/bin/varnishtest/tests/e00017.vtc 2009-12-03 09:18:03 UTC (rev 4379) @@ -0,0 +1,88 @@ +# $Id: e00003.vtc 3742 2009-02-11 07:53:47Z tfheen $ + +test "Aggressive use of ESI include" + + +server s1 { + rxreq + txresp -body { + + Before include + + + + + + + + + + + + + + + + + + + + + After include + } + rxreq + txresp -body { Included file 00 } + rxreq + txresp -body { Included file 01 } + rxreq + txresp -body { Included file 02 } + rxreq + txresp -body { Included file 03 } + rxreq + txresp -body { Included file 04 } + rxreq + txresp -body { Included file 05 } + rxreq + txresp -body { Included file 06 } + rxreq + txresp -body { Included file 07 } + rxreq + txresp -body { Included file 08 } + rxreq + txresp -body { Included file 09 } + rxreq + txresp -body { Included file 10 } + rxreq + txresp -body { Included file 11 } + rxreq + txresp -body { Included file 12 } + rxreq + txresp -body { Included file 13 } + rxreq + txresp -body { Included file 14 } + rxreq + txresp -body { Included file 15 } + rxreq + txresp -body { Included file 16 } + rxreq + txresp -body { Included file 17 } + rxreq + txresp -body { Included file 18 } + rxreq + txresp -body { Included file 19 } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} + +client c1 -run +varnish v1 -expect esi_errors == 0 From tfheen at projects.linpro.no Thu Dec 3 10:45:09 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Thu, 3 Dec 2009 11:45:09 +0100 (CET) Subject: r4380 - branches/2.0/varnish-cache/bin/varnishd Message-ID: <20091203104509.6653C1F7424@projects.linpro.no> Author: tfheen Date: 2009-12-03 11:45:09 +0100 (Thu, 03 Dec 2009) New Revision: 4380 Modified: branches/2.0/varnish-cache/bin/varnishd/varnishd.c Log: Merge r4354: Document -C option in usage. Fixes #559 Modified: branches/2.0/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/varnishd.c 2009-12-03 09:18:03 UTC (rev 4379) +++ branches/2.0/varnish-cache/bin/varnishd/varnishd.c 2009-12-03 10:45:09 UTC (rev 4380) @@ -209,6 +209,7 @@ fprintf(stderr, FMT, "-b address:port", "backend address and port"); fprintf(stderr, FMT, "", " -b "); fprintf(stderr, FMT, "", " -b ':'"); + fprintf(stderr, FMT, "-C", "print VCL code compiled to C language"); fprintf(stderr, FMT, "-d", "debug"); fprintf(stderr, FMT, "-f file", "VCL script"); fprintf(stderr, FMT, "-F", "Run in foreground"); From tfheen at projects.linpro.no Thu Dec 3 11:02:46 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Thu, 3 Dec 2009 12:02:46 +0100 (CET) Subject: r4381 - in branches/2.0/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl Message-ID: <20091203110246.CA4A81F7426@projects.linpro.no> Author: tfheen Date: 2009-12-03 12:02:46 +0100 (Thu, 03 Dec 2009) New Revision: 4381 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc branches/2.0/varnish-cache/include/vrt.h branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c Log: Merge r4356, r4357: Don't half-close probes, add .expected_response r4356: Don't halfclose the backend polling TCP connection after sending the request, some backends gets confused by this. Add a ".status" to backend polling, to configure the expected HTTP status code for a good poll. Fixes #584 r4357: .expected_response is a better idea than .status Tip o' the hat to: tfheen Modified: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c 2009-12-03 11:02:46 UTC (rev 4381) @@ -173,23 +173,6 @@ } vt->good_xmit |= 1; - /* And do a shutdown(WR) so we know that the backend got it */ - i = shutdown(s, SHUT_WR); - if (i != 0) { - vt->err_shut |= 1; - TCP_close(&s); - return; - } - vt->good_shut |= 1; - - /* Check if that took too long time */ - t_now = TIM_real(); - tmo = (int)round((t_end - t_now) * 1e3); - if (tmo < 0) { - TCP_close(&s); - return; - } - pfd->fd = s; rlen = 0; do { @@ -236,7 +219,7 @@ i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf); - if (i == 2 && resp == 200) + if (i == 2 && resp == vt->probe.exp_status) vt->happy |= 1; } @@ -335,6 +318,8 @@ vt->probe.window = 8; if (vt->probe.threshold == 0) vt->probe.threshold = 3; + if (vt->probe.exp_status == 0) + vt->probe.exp_status = 200; if (vt->probe.threshold == ~0U) vt->probe.initial = vt->probe.threshold - 1; Modified: branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h 2009-12-03 11:02:46 UTC (rev 4381) @@ -33,8 +33,6 @@ BITMAP(good_ipv6, '6', "Good IPv6", 0) BITMAP( err_xmit, 'x', "Error Xmit", 0) BITMAP(good_xmit, 'X', "Good Xmit", 0) -BITMAP( err_shut, 's', "Error Shut", 0) -BITMAP(good_shut, 'S', "Good Shut", 0) BITMAP( err_recv, 'r', "Error Recv", 0) BITMAP(good_recv, 'R', "Good Recv", 0) BITMAP(happy, 'H', "Happy", 1) Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc =================================================================== --- branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc 2009-12-03 11:02:46 UTC (rev 4381) @@ -185,3 +185,11 @@ } } + +varnish v1 -badvcl { + backend b1 { + .host = "127.0.0.1"; + .probe = { .expected_response = 13; } + } +} + Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc =================================================================== --- branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc 2009-12-03 11:02:46 UTC (rev 4381) @@ -2,6 +2,16 @@ test "VCL: test backend probe syntax" +# Check status definition +varnish v1 -vcl { + backend b1 { + .host = "127.0.0.1"; + .probe = { + .expected_response = 204; + } + } +} + # Check url definition varnish v1 -vcl { backend b1 { Modified: branches/2.0/varnish-cache/include/vrt.h =================================================================== --- branches/2.0/varnish-cache/include/vrt.h 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/include/vrt.h 2009-12-03 11:02:46 UTC (rev 4381) @@ -52,6 +52,7 @@ const char *request; double timeout; double interval; + unsigned exp_status; unsigned window; unsigned threshold; unsigned initial; Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-03 11:02:46 UTC (rev 4381) @@ -341,11 +341,12 @@ struct token *t_field; struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL; struct token *t_initial = NULL; - unsigned window, threshold, initial; + unsigned window, threshold, initial, status; fs = vcc_FldSpec(tl, "?url", "?request", + "?expected_response", "?timeout", "?interval", "?window", @@ -359,6 +360,7 @@ window = 0; threshold = 0; initial = 0; + status = 0; Fb(tl, 0, "\t.probe = {\n"); while (tl->t->tok != '}') { @@ -404,6 +406,17 @@ initial = vcc_UintVal(tl); vcc_NextToken(tl); ERRCHK(tl); + } else if (vcc_IdIs(t_field, "expected_response")) { + status = vcc_UintVal(tl); + if (status < 100 || status > 999) { + vsb_printf(tl->sb, + "Must specify .status with exactly three " + " digits (100 <= x <= 999)\n"); + vcc_ErrWhere(tl, tl->t); + return; + } + vcc_NextToken(tl); + ERRCHK(tl); } else if (vcc_IdIs(t_field, "threshold")) { t_threshold = tl->t; threshold = vcc_UintVal(tl); @@ -455,6 +468,8 @@ Fb(tl, 0, "\t\t.initial = %u,\n", initial); else Fb(tl, 0, "\t\t.initial = ~0U,\n", initial); + if (status > 0) + Fb(tl, 0, "\t\t.exp_status = %u,\n", status); Fb(tl, 0, "\t},\n"); ExpectErr(tl, '}'); vcc_NextToken(tl); Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c =================================================================== --- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-03 10:45:09 UTC (rev 4380) +++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-03 11:02:46 UTC (rev 4381) @@ -246,13 +246,14 @@ vsb_cat(sb, "on\n */\n\nextern void *vrt_magic_string_end;\n"); vsb_cat(sb, "\nstruct vrt_backend_probe {\n\tconst char\t*url;\n"); vsb_cat(sb, "\tconst char\t*request;\n\tdouble\t\ttimeout;\n"); - vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\twindow;\n"); - vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n"); - vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the"); - vsb_cat(sb, " network\n */\nstruct vrt_backend {\n"); - vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident"); - vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n"); - vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n"); + vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\texp_status;\n"); + vsb_cat(sb, "\tunsigned\twindow;\n\tunsigned\tthreshold;\n"); + vsb_cat(sb, "\tunsigned\tinitial;\n};\n\n/*\n"); + vsb_cat(sb, " * A backend is a host+port somewhere on the network\n"); + vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name"); + vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n"); + vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n"); + vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n"); vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n"); vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n"); vsb_cat(sb, "\tdouble\t\t\t\tfirst_byte_timeout;\n"); @@ -324,9 +325,9 @@ /* ../../include/vrt_obj.h */ - vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4082 2009-05-19 07:14:00Z "); - vsb_cat(sb, "sky $\n *\n * NB: This file is machine generated, DO "); - vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n"); + vsb_cat(sb, "/*\n * $Id$\n"); + vsb_cat(sb, " *\n * NB: This file is machine generated, DO NOT EDI"); + vsb_cat(sb, "T!\n *\n * Edit vcc_gen_obj.tcl instead\n"); vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct "); vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses"); vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess "); From tfheen at projects.linpro.no Thu Dec 3 11:18:29 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Thu, 3 Dec 2009 12:18:29 +0100 (CET) Subject: r4382 - in trunk/varnish-cache: . lib/libvarnishcompat Message-ID: <20091203111829.02C301F7430@projects.linpro.no> Author: tfheen Date: 2009-12-03 12:18:28 +0100 (Thu, 03 Dec 2009) New Revision: 4382 Modified: trunk/varnish-cache/configure.ac trunk/varnish-cache/lib/libvarnishcompat/execinfo.c Log: Use built-in backtrace function if one exists This gives us backtraces on panic on when you're not using GCC. Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2009-12-03 11:02:46 UTC (rev 4381) +++ trunk/varnish-cache/configure.ac 2009-12-03 11:18:28 UTC (rev 4382) @@ -213,6 +213,7 @@ AC_CHECK_FUNCS([srandomdev]) AC_CHECK_FUNCS([strlcat strlcpy]) AC_CHECK_FUNCS([strndup]) +AC_CHECK_FUNCS([backtrace]) # white lie - we don't actually test it AC_MSG_CHECKING([whether daemon() works]) case $target in Modified: trunk/varnish-cache/lib/libvarnishcompat/execinfo.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-03 11:02:46 UTC (rev 4381) +++ trunk/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-03 11:18:28 UTC (rev 4382) @@ -29,6 +29,8 @@ #include "svnid.h" SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $") +#ifndef HAVE_BACKTRACE + #include "compat/execinfo.h" #if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */ @@ -428,4 +430,5 @@ return (0); } -#endif +#endif /* (__GNUC__) && __GNUC__ >= 4 */ +#endif /* HAVE_BACKTRACE */ From phk at projects.linpro.no Thu Dec 3 11:26:53 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 3 Dec 2009 12:26:53 +0100 (CET) Subject: r4383 - trunk/varnish-cache/man Message-ID: <20091203112653.9BDE41F7430@projects.linpro.no> Author: phk Date: 2009-12-03 12:26:53 +0100 (Thu, 03 Dec 2009) New Revision: 4383 Modified: trunk/varnish-cache/man/vcl.7so Log: Remove spurious .Ed Fixes #591 Modified: trunk/varnish-cache/man/vcl.7so =================================================================== --- trunk/varnish-cache/man/vcl.7so 2009-12-03 11:18:28 UTC (rev 4382) +++ trunk/varnish-cache/man/vcl.7so 2009-12-03 11:26:53 UTC (rev 4383) @@ -99,7 +99,6 @@ To avoid overloading backend servers, .Fa .max_connections can be set to limit the maximum number of concurrent backend connections. -.Ed .Pp The timeout parameters can be overridden in the backend declaration. The timeout parameters are From phk at projects.linpro.no Thu Dec 3 11:54:51 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 3 Dec 2009 12:54:51 +0100 (CET) Subject: r4384 - trunk/varnish-cache/lib/libvarnish Message-ID: <20091203115451.898C41F7461@projects.linpro.no> Author: phk Date: 2009-12-03 12:54:51 +0100 (Thu, 03 Dec 2009) New Revision: 4384 Modified: trunk/varnish-cache/lib/libvarnish/tcp.c Log: Don't panic in TCP_linger() if the other end closed on us. Fixes #547 Modified: trunk/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/tcp.c 2009-12-03 11:26:53 UTC (rev 4383) +++ trunk/varnish-cache/lib/libvarnish/tcp.c 2009-12-03 11:54:51 UTC (rev 4384) @@ -240,8 +240,10 @@ TCP_linger(int sock, int linger) { struct linger lin; + int i; memset(&lin, 0, sizeof lin); lin.l_onoff = linger; - AZ(setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin)); + i = setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin); + assert(i == 0 || errno == EBADF); } From tfheen at projects.linpro.no Mon Dec 14 08:10:57 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Mon, 14 Dec 2009 09:10:57 +0100 (CET) Subject: r4385 - trunk/varnish-cache/man Message-ID: <20091214081057.569581F7377@projects.linpro.no> Author: tfheen Date: 2009-12-14 09:10:57 +0100 (Mon, 14 Dec 2009) New Revision: 4385 Modified: trunk/varnish-cache/man/vcl.7so Log: Fix Set-Cookie vs Cookie confusion and old keywords. Fixes #600 Modified: trunk/varnish-cache/man/vcl.7so =================================================================== --- trunk/varnish-cache/man/vcl.7so 2009-12-03 11:54:51 UTC (rev 4384) +++ trunk/varnish-cache/man/vcl.7so 2009-12-14 08:10:57 UTC (rev 4385) @@ -369,8 +369,8 @@ .\" vcl_hash .It Cm vcl_hash Use -.Cm req.hash += req.http.Set-Cookie -or similar to include the Set-Cookie HTTP header in the hash string. +.Cm req.hash += req.http.Cookie +or similar to include the Cookie HTTP header in the hash string. The .Cm vcl_hash subroutine may terminate with one of the following keywords: @@ -669,7 +669,7 @@ sub vcl_fetch { if (obj.http.Set-Cookie) { - insert; + deliver; } } .Ed From ingvar at projects.linpro.no Mon Dec 14 08:50:24 2009 From: ingvar at projects.linpro.no (ingvar at projects.linpro.no) Date: Mon, 14 Dec 2009 09:50:24 +0100 (CET) Subject: r4386 - branches/2.0/varnish-cache/redhat Message-ID: <20091214085024.ED6CD1F7377@projects.linpro.no> Author: ingvar Date: 2009-12-14 09:50:24 +0100 (Mon, 14 Dec 2009) New Revision: 4386 Modified: branches/2.0/varnish-cache/redhat/varnish.spec Log: specfile update to the 2.0.6 version Modified: branches/2.0/varnish-cache/redhat/varnish.spec =================================================================== --- branches/2.0/varnish-cache/redhat/varnish.spec 2009-12-14 08:10:57 UTC (rev 4385) +++ branches/2.0/varnish-cache/redhat/varnish.spec 2009-12-14 08:50:24 UTC (rev 4386) @@ -1,6 +1,6 @@ Summary: High-performance HTTP accelerator Name: varnish -Version: 2.0.5 +Version: 2.0.6 Release: 1%{?dist} License: BSD Group: System Environment/Daemons @@ -239,6 +239,9 @@ %postun libs -p /sbin/ldconfig %changelog +* Mon Dec 14 2009 Ingvar Hagelund - 2.0.6-1 +- New upstream release + * Mon Nov 09 2009 Ingvar Hagelund - 2.0.5-1 - New upstream release From ingvar at projects.linpro.no Mon Dec 14 10:02:11 2009 From: ingvar at projects.linpro.no (ingvar at projects.linpro.no) Date: Mon, 14 Dec 2009 11:02:11 +0100 (CET) Subject: r4387 - trunk/varnish-cache/lib/libjemalloc Message-ID: <20091214100211.5DC8F1F7377@projects.linpro.no> Author: ingvar Date: 2009-12-14 11:02:10 +0100 (Mon, 14 Dec 2009) New Revision: 4387 Modified: trunk/varnish-cache/lib/libjemalloc/jemalloc_linux.c Log: jemalloc portability fixes for sparc and s390 Modified: trunk/varnish-cache/lib/libjemalloc/jemalloc_linux.c =================================================================== --- trunk/varnish-cache/lib/libjemalloc/jemalloc_linux.c 2009-12-14 08:50:24 UTC (rev 4386) +++ trunk/varnish-cache/lib/libjemalloc/jemalloc_linux.c 2009-12-14 10:02:10 UTC (rev 4387) @@ -244,7 +244,7 @@ # define SIZEOF_PTR_2POW 3 # define NO_TLS #endif -#ifdef __sparc64__ +#ifdef __sparc__ # define PAGESIZE_2POW 13 # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 3 @@ -273,6 +273,11 @@ # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 2 #endif +#ifdef __s390x__ +# define PAGESIZE_2POW 12 +# define QUANTUM_2POW 4 +# define SIZEOF_PTR_2POW 3 +#endif #define QUANTUM ((size_t)(1U << QUANTUM_2POW)) #define QUANTUM_MASK (QUANTUM - 1) From ingvar at projects.linpro.no Mon Dec 14 10:05:28 2009 From: ingvar at projects.linpro.no (ingvar at projects.linpro.no) Date: Mon, 14 Dec 2009 11:05:28 +0100 (CET) Subject: r4388 - trunk/varnish-cache/redhat Message-ID: <20091214100528.5BE451F73DB@projects.linpro.no> Author: ingvar Date: 2009-12-14 11:05:28 +0100 (Mon, 14 Dec 2009) New Revision: 4388 Modified: trunk/varnish-cache/redhat/varnish.spec Log: RedHat specfile does no longer need the jemalloc portability patches Modified: trunk/varnish-cache/redhat/varnish.spec =================================================================== --- trunk/varnish-cache/redhat/varnish.spec 2009-12-14 10:02:10 UTC (rev 4387) +++ trunk/varnish-cache/redhat/varnish.spec 2009-12-14 10:05:28 UTC (rev 4388) @@ -1,14 +1,12 @@ Summary: High-performance HTTP accelerator Name: varnish -Version: 2.0.5 +Version: 2.0.6 Release: 1%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.varnish-cache.org/ Source0: http://downloads.sourceforge.net/varnish/varnish-%{version}.tar.gz #Patch0: varnish.varnishtest_debugflag.patch -#Patch1: varnish.s390x_pagesize.patch -#Patch2: varnish.sparc_pagesize.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # The svn sources needs autoconf, automake and libtool to generate a suitable # configure script. Release tarballs would not need this @@ -71,8 +69,6 @@ #./autogen.sh #%patch0 -p0 -#%patch1 -p0 -#%patch2 -p0 # Hack to get 32- and 64-bits tests run concurrently on the same build machine case `uname -m` in @@ -239,6 +235,9 @@ %postun libs -p /sbin/ldconfig %changelog +* Mon Dec 14 2009 Ingvar Hagelund - 2.0.6-1 +- New upstream release + * Mon Nov 09 2009 Ingvar Hagelund - 2.0.5-1 - New upstream release From phk at projects.linpro.no Mon Dec 14 11:03:23 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 14 Dec 2009 12:03:23 +0100 (CET) Subject: r4389 - trunk/varnish-cache/bin/varnishd Message-ID: <20091214110323.DA9F41F7498@projects.linpro.no> Author: phk Date: 2009-12-14 12:03:23 +0100 (Mon, 14 Dec 2009) New Revision: 4389 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c trunk/varnish-cache/bin/varnishd/cache_dir_simple.c Log: Rename backend_is_healthy() to VBE_Healthy() for naming-space consistency. Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-14 10:05:28 UTC (rev 4388) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-14 11:03:23 UTC (rev 4389) @@ -229,7 +229,7 @@ sp->vbe = sp->director->getfd(sp); } -/* +/*-------------------------------------------------------------------- * It evaluates if a backend is healthy _for_a_specific_object_. * That means that it relies on sp->objhead. This is mainly for saint-mode, * but also takes backend->healthy into account. If @@ -239,8 +239,9 @@ * The threshold has to be evaluated _after_ the timeout check, otherwise * items would never time out once the threshold is reached. */ + unsigned int -backend_is_healthy(const struct sess *sp, struct backend *backend) +VBE_Healthy(const struct sess *sp, struct backend *backend) { struct trouble *tr; struct trouble *tr2; @@ -339,7 +340,7 @@ VBE_ClosedFd(sp); } - if (!backend_is_healthy(sp, bp)) { + if (!VBE_Healthy(sp, bp)) { VSL_stats->backend_unhealthy++; return (NULL); } Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-14 10:05:28 UTC (rev 4388) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-14 11:03:23 UTC (rev 4389) @@ -143,7 +143,7 @@ /* cache_backend.c */ void VBE_ReleaseConn(struct vbe_conn *vc); struct vbe_conn *VBE_GetVbe(struct sess *sp, struct backend *bp); -unsigned int backend_is_healthy(const struct sess *sp, struct backend *backend); +unsigned int VBE_Healthy(const struct sess *sp, struct backend *backend); /* cache_backend_cfg.c */ extern struct lock VBE_mtx; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-14 10:05:28 UTC (rev 4388) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-14 11:03:23 UTC (rev 4389) @@ -81,7 +81,7 @@ /* Sum up the weights of healty backends */ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) - if (backend_is_healthy(sp,vs->hosts[i].backend)) + if (VBE_Healthy(sp,vs->hosts[i].backend)) s1 += vs->hosts[i].weight; if (s1 == 0.0) @@ -94,7 +94,7 @@ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) { - if (!backend_is_healthy(sp, vs->hosts[i].backend)) + if (!VBE_Healthy(sp, vs->hosts[i].backend)) continue; s1 += vs->hosts[i].weight; if (r >= s1) @@ -120,7 +120,7 @@ CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_RANDOM_MAGIC); for (i = 0; i < vs->nhosts; i++) { - if (backend_is_healthy(sp,vs->hosts[i].backend)) + if (VBE_Healthy(sp,vs->hosts[i].backend)) return 1; } return 0; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-14 10:05:28 UTC (rev 4388) +++ trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-14 11:03:23 UTC (rev 4389) @@ -75,7 +75,7 @@ for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[vs->next_host].backend; vs->next_host = (vs->next_host + 1) % vs->nhosts; - if (!backend_is_healthy(sp, backend)) + if (!VBE_Healthy(sp, backend)) continue; vbe = VBE_GetVbe(sp, backend); if (vbe != NULL) @@ -96,7 +96,7 @@ CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_ROUND_ROBIN_MAGIC); for (i = 0; i < vs->nhosts; i++) { - if (backend_is_healthy(sp, vs->hosts[i].backend)) + if (VBE_Healthy(sp, vs->hosts[i].backend)) return 1; } return 0; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-14 10:05:28 UTC (rev 4388) +++ trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-14 11:03:23 UTC (rev 4389) @@ -75,7 +75,7 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_SIMPLE_MAGIC); - return (backend_is_healthy(sp, vs->backend)); + return (VBE_Healthy(sp, vs->backend)); } /*lint -e{818} not const-able */ From phk at projects.linpro.no Mon Dec 14 11:41:58 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 14 Dec 2009 12:41:58 +0100 (CET) Subject: r4390 - trunk/varnish-cache/lib/libvcl Message-ID: <20091214114158.0C3001F73DB@projects.linpro.no> Author: phk Date: 2009-12-14 12:41:57 +0100 (Mon, 14 Dec 2009) New Revision: 4390 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c Log: Cosmetic: Move the vrt_dir_simple{} up together with the rest of the relevant stuff for simple directors. Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-14 11:03:23 UTC (rev 4389) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-14 11:41:57 UTC (rev 4390) @@ -751,11 +751,11 @@ PF(h->name), PF(h->name)); Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(h->name)); - Fc(tl, 0, "\nstatic const struct vrt_dir_simple sbe_%.*s = {\n", + Fh(tl, 0, "\nstatic const struct vrt_dir_simple sbe_%.*s = {\n", PF(h->name)); - Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(h->name)); - Fc(tl, 0, "\t.host = &bh_%d,\n", h->hnum); - Fc(tl, 0, "};\n"); + Fh(tl, 0, "\t.name = \"%.*s\",\n", PF(h->name)); + Fh(tl, 0, "\t.host = &bh_%d,\n", h->hnum); + Fh(tl, 0, "};\n"); } From phk at projects.linpro.no Mon Dec 14 12:10:15 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 14 Dec 2009 13:10:15 +0100 (CET) Subject: r4391 - in trunk/varnish-cache: bin/varnishd include lib/libvcl Message-ID: <20091214121015.DD5401F73DB@projects.linpro.no> Author: phk Date: 2009-12-14 13:10:15 +0100 (Mon, 14 Dec 2009) New Revision: 4391 Modified: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c trunk/varnish-cache/include/vrt.h trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c trunk/varnish-cache/lib/libvcl/vcc_obj.c Log: Eliminate the vrt_dir_simple structure, it is not really needed. Modified: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-14 11:41:57 UTC (rev 4390) +++ trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-14 12:10:15 UTC (rev 4391) @@ -95,7 +95,7 @@ void VRT_init_dir_simple(struct cli *cli, struct director **bp, - const struct vrt_dir_simple *t) + const struct vrt_backend *t) { struct vdi_simple *vs; @@ -106,12 +106,12 @@ vs->dir.magic = DIRECTOR_MAGIC; vs->dir.priv = vs; vs->dir.name = "simple"; - REPLACE(vs->dir.vcl_name, t->host->vcl_name); + REPLACE(vs->dir.vcl_name, t->vcl_name); vs->dir.getfd = vdi_simple_getfd; vs->dir.fini = vdi_simple_fini; vs->dir.healthy = vdi_simple_healthy; - vs->backend = VBE_AddBackend(cli, t->host); + vs->backend = VBE_AddBackend(cli, t); *bp = &vs->dir; } Modified: trunk/varnish-cache/include/vrt.h =================================================================== --- trunk/varnish-cache/include/vrt.h 2009-12-14 11:41:57 UTC (rev 4390) +++ trunk/varnish-cache/include/vrt.h 2009-12-14 12:10:15 UTC (rev 4391) @@ -79,15 +79,6 @@ }; /* - * A director with a predictable reply - */ - -struct vrt_dir_simple { - const char *name; - const struct vrt_backend *host; -}; - -/* * A director with an unpredictable reply */ @@ -171,7 +162,7 @@ /* Backend related */ void VRT_init_dir_simple(struct cli *, struct director **, - const struct vrt_dir_simple *); + const struct vrt_backend *); void VRT_init_dir_random(struct cli *, struct director **, const struct vrt_dir_random *); void VRT_init_dir_round_robin(struct cli *, struct director **, Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-14 11:41:57 UTC (rev 4390) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-14 12:10:15 UTC (rev 4391) @@ -747,16 +747,10 @@ VTAILQ_INSERT_TAIL(&tl->hosts, h, list); Fi(tl, 0, - "\tVRT_init_dir_simple(cli, &VGC_backend_%.*s , &sbe_%.*s);\n", - PF(h->name), PF(h->name)); + "\tVRT_init_dir_simple(cli, &VGC_backend_%.*s , &bh_%d);\n", + PF(h->name), h->hnum); Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(h->name)); - Fh(tl, 0, "\nstatic const struct vrt_dir_simple sbe_%.*s = {\n", - PF(h->name)); - Fh(tl, 0, "\t.name = \"%.*s\",\n", PF(h->name)); - Fh(tl, 0, "\t.host = &bh_%d,\n", h->hnum); - Fh(tl, 0, "};\n"); - } /*-------------------------------------------------------------------- Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-14 11:41:57 UTC (rev 4390) +++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-14 12:10:15 UTC (rev 4391) @@ -1,5 +1,5 @@ /* - * $Id: vcc_gen_fixed_token.tcl 4358 2009-11-19 19:03:25Z phk $ + * $Id: vcc_gen_fixed_token.tcl 4376 2009-11-27 11:06:32Z phk $ * * NB: This file is machine generated, DO NOT EDIT! * @@ -159,8 +159,8 @@ /* ../../include/vcl.h */ - vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4358 2009-11-19 19"); - vsb_cat(sb, ":03:25Z phk $\n *\n * NB: This file is machine genera"); + vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4376 2009-11-27 11"); + vsb_cat(sb, ":06:32Z phk $\n *\n * NB: This file is machine genera"); vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n"); vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n"); @@ -253,11 +253,8 @@ vsb_cat(sb, "\tunsigned\t\t\tmax_connections;\n"); vsb_cat(sb, "\tunsigned\t\t\tsaintmode_threshold;\n"); vsb_cat(sb, "\tstruct vrt_backend_probe\tprobe;\n"); - vsb_cat(sb, "};\n\n/*\n * A director with a predictable reply\n"); - vsb_cat(sb, " */\n\nstruct vrt_dir_simple {\n"); - vsb_cat(sb, "\tconst char\t\t\t\t*name;\n\tconst struct vrt_backend"); - vsb_cat(sb, "\t\t*host;\n};\n\n/*\n * A director with an unpredicta"); - vsb_cat(sb, "ble reply\n */\n\nstruct vrt_dir_random_entry {\n"); + vsb_cat(sb, "};\n\n/*\n * A director with an unpredictable reply\n"); + vsb_cat(sb, " */\n\nstruct vrt_dir_random_entry {\n"); vsb_cat(sb, "\tconst struct vrt_backend\t\t*host;\n"); vsb_cat(sb, "\tdouble\t\t\t\t\tweight;\n};\n"); vsb_cat(sb, "\nstruct vrt_dir_random {\n\tconst char\t\t\t\t*name;\n"); @@ -302,7 +299,7 @@ vsb_cat(sb, "ss *sp, unsigned flags, const char *, ...);\n"); vsb_cat(sb, "\n/* Backend related */\nvoid VRT_init_dir_simple(stru"); vsb_cat(sb, "ct cli *, struct director **,\n"); - vsb_cat(sb, " const struct vrt_dir_simple *);\n"); + vsb_cat(sb, " const struct vrt_backend *);\n"); vsb_cat(sb, "void VRT_init_dir_random(struct cli *, struct director"); vsb_cat(sb, " **,\n const struct vrt_dir_random *);\n"); vsb_cat(sb, "void VRT_init_dir_round_robin(struct cli *, struct dir"); @@ -318,8 +315,8 @@ /* ../../include/vrt_obj.h */ - vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4358 2009-11-19 19"); - vsb_cat(sb, ":03:25Z phk $\n *\n * NB: This file is machine genera"); + vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4376 2009-11-27 11"); + vsb_cat(sb, ":06:32Z phk $\n *\n * NB: This file is machine genera"); vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sockaddr * VRT_r_clien"); vsb_cat(sb, "t_ip(const struct sess *);\nstruct sockaddr * VRT_r_se"); Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-12-14 11:41:57 UTC (rev 4390) +++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2009-12-14 12:10:15 UTC (rev 4391) @@ -1,5 +1,5 @@ /* - * $Id: vcc_gen_fixed_token.tcl 4358 2009-11-19 19:03:25Z phk $ + * $Id: vcc_gen_fixed_token.tcl 4376 2009-11-27 11:06:32Z phk $ * * NB: This file is machine generated, DO NOT EDIT! * From phk at projects.linpro.no Mon Dec 14 13:03:09 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 14 Dec 2009 14:03:09 +0100 (CET) Subject: r4392 - trunk/varnish-cache/bin/varnishd Message-ID: <20091214130309.3279C1F730F@projects.linpro.no> Author: phk Date: 2009-12-14 14:03:08 +0100 (Mon, 14 Dec 2009) New Revision: 4392 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Execute vcl_hash{} right after vcl_recv{}, so that vcl_pipe{} and vcl_pass{} can trust the result to exist. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2009-12-14 12:10:15 UTC (rev 4391) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2009-12-14 13:03:08 UTC (rev 4392) @@ -775,12 +775,6 @@ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); - if (sp->obj == NULL) { - HSH_BeforeVclHash(sp); - VCL_hash_method(sp); - assert(sp->handling == VCL_RET_HASH); - HSH_AfterVclHash(sp); - } oc = HSH_Lookup(sp, &oh); @@ -1015,6 +1009,7 @@ static int cnt_recv(struct sess *sp) { + unsigned recv_handling; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); @@ -1030,6 +1025,8 @@ sp->disable_esi = 0; VCL_recv_method(sp); + recv_handling = sp->handling; + if (sp->restarts >= params->max_restarts) { if (sp->err_code == 0) sp->err_code = 503; @@ -1037,6 +1034,11 @@ return (0); } + HSH_BeforeVclHash(sp); + VCL_hash_method(sp); + assert(sp->handling == VCL_RET_HASH); + HSH_AfterVclHash(sp); + if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) { sp->wantbody = 0; http_ForceGet(sp->http); @@ -1044,7 +1046,7 @@ sp->wantbody = 1; sp->sendbody = 0; - switch(sp->handling) { + switch(recv_handling) { case VCL_RET_LOOKUP: /* XXX: discard req body, if any */ sp->step = STP_LOOKUP; From phk at projects.linpro.no Tue Dec 15 10:32:21 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 15 Dec 2009 11:32:21 +0100 (CET) Subject: r4393 - trunk/varnish-cache/lib/libvcl Message-ID: <20091215103221.958551F72E4@projects.linpro.no> Author: phk Date: 2009-12-15 11:32:21 +0100 (Tue, 15 Dec 2009) New Revision: 4393 Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c trunk/varnish-cache/lib/libvcl/vcc_parse.c Log: Change the way we identify backends internally in the compiled VCL code. Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_action.c 2009-12-14 13:03:08 UTC (rev 4392) +++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2009-12-15 10:32:21 UTC (rev 4393) @@ -251,7 +251,7 @@ vcc_ExpectCid(tl); ERRCHK(tl); vcc_AddRef(tl, tl->t, R_BACKEND); - Fb(tl, 0, "VGC_backend_%.*s", PF(tl->t)); + Fb(tl, 0, "VGC_backend__%.*s", PF(tl->t)); vcc_NextToken(tl); Fb(tl, 0, ");\n"); break; Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-14 13:03:08 UTC (rev 4392) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 10:32:21 UTC (rev 4393) @@ -199,8 +199,13 @@ AN(qual); assert(first != last); vsb_printf(v, "\t.ident ="); - vsb_printf(v, "\n\t \"%.*s %.*s [%d] \"", - PF(qual), PF(name), serial); + if (serial >= 0) { + vsb_printf(v, "\n\t \"%.*s %.*s [%d] \"", + PF(qual), PF(name), serial); + } else { + vsb_printf(v, "\n\t \"%.*s %.*s \"", + PF(qual), PF(name)); + } while (1) { if (first->dec != NULL) vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"", @@ -522,7 +527,7 @@ Fb(tl, 0, "\nstatic const struct vrt_backend bh_%d = {\n", *nbh); Fb(tl, 0, "\t.vcl_name = \"%.*s", PF(name)); - if (serial) + if (serial >= 0) Fb(tl, 0, "[%d]", serial); Fb(tl, 0, "\",\n"); @@ -741,15 +746,15 @@ h = TlAlloc(tl, sizeof *h); h->name = t_dir; - vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, 0); + vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1); ERRCHK(tl); VTAILQ_INSERT_TAIL(&tl->hosts, h, list); Fi(tl, 0, - "\tVRT_init_dir_simple(cli, &VGC_backend_%.*s , &bh_%d);\n", + "\tVRT_init_dir_simple(cli, &VGC_backend__%.*s , &bh_%d);\n", PF(h->name), h->hnum); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(h->name)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(h->name)); } @@ -780,7 +785,7 @@ t_dir = tl->t; vcc_NextToken(tl); - Fh(tl, 1, "\n#define VGC_backend_%.*s (VCL_conf.director[%d])\n", + Fh(tl, 1, "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n", PF(t_dir), tl->ndirector); vcc_AddDef(tl, t_dir, R_BACKEND); tl->ndirector++; Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-14 13:03:08 UTC (rev 4392) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 10:32:21 UTC (rev 4393) @@ -143,7 +143,7 @@ Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(t_dir)); Fc(tl, 0, "};\n"); Fi(tl, 0, - "\tVRT_init_dir_random(cli, &VGC_backend_%.*s , &vdr_%.*s);\n", + "\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n", PF(t_dir), PF(t_dir)); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-14 13:03:08 UTC (rev 4392) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 10:32:21 UTC (rev 4393) @@ -104,6 +104,6 @@ Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(t_dir)); Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_dir_round_robin(" - "cli, &VGC_backend_%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir)); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(t_dir)); + "cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_parse.c 2009-12-14 13:03:08 UTC (rev 4392) +++ trunk/varnish-cache/lib/libvcl/vcc_parse.c 2009-12-15 10:32:21 UTC (rev 4393) @@ -322,7 +322,7 @@ vcc_ExpectCid(tl); ERRCHK(tl); vcc_AddRef(tl, tl->t, R_BACKEND); - Fb(tl, 1, "VGC_backend_%.*s\n", PF(tl->t)); + Fb(tl, 1, "VGC_backend__%.*s\n", PF(tl->t)); vcc_NextToken(tl); } From phk at projects.linpro.no Tue Dec 15 11:23:41 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 15 Dec 2009 12:23:41 +0100 (CET) Subject: r4394 - trunk/varnish-cache/lib/libvcl Message-ID: <20091215112341.7ABCD1F72E4@projects.linpro.no> Author: phk Date: 2009-12-15 12:23:41 +0100 (Tue, 15 Dec 2009) New Revision: 4394 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c Log: Make all anonymous backends have a simple director. Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 10:32:21 UTC (rev 4393) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 11:23:41 UTC (rev 4394) @@ -490,7 +490,7 @@ static void vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name, - const struct token *qual, int serial) + const struct token *qual, int serial, const char *vgcname) { struct token *t_field; struct token *t_first; @@ -503,6 +503,9 @@ struct vsb *vsb; unsigned u; + Fh(tl, 1, "\n#define %s (VCL_conf.director[%d])\n", + vgcname, tl->ndirector); + fs = vcc_FldSpec(tl, "!host", "?port", @@ -675,6 +678,11 @@ AZ(vsb_overflowed(vsb)); Fh(tl, 0, "%s", vsb_data(vsb)); vsb_delete(vsb); + + Fi(tl, 0, "\tVRT_init_dir_simple(cli, &%s, &bh_%d);\n", + vgcname, *nbh); + Ff(tl, 0, "\tVRT_fini_dir(cli, %s);\n", vgcname); + tl->ndirector++; } /*-------------------------------------------------------------------- @@ -695,6 +703,7 @@ { struct host *h; struct token *t; + char vgcname[BUFSIZ]; if (tl->t->tok == ID) { VTAILQ_FOREACH(h, &tl->hosts, list) { @@ -715,7 +724,10 @@ *nbh = h->hnum; } else if (tl->t->tok == '{') { t = tl->t; - vcc_ParseHostDef(tl, nbh, name, qual, serial); + + sprintf(vgcname, "VGC_backend_%.*s_%d", PF(name), serial); + + vcc_ParseHostDef(tl, nbh, name, qual, serial, vgcname); if (tl->err) { vsb_printf(tl->sb, "\nIn backend host specification starting at:\n"); @@ -742,20 +754,17 @@ struct token *t_dir) { struct host *h; + char vgcname[BUFSIZ]; h = TlAlloc(tl, sizeof *h); h->name = t_dir; + vcc_AddDef(tl, t_dir, R_BACKEND); + sprintf(vgcname, "VGC_backend__%.*s", PF(h->name)); - vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1); + vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1, vgcname); ERRCHK(tl); VTAILQ_INSERT_TAIL(&tl->hosts, h, list); - - Fi(tl, 0, - "\tVRT_init_dir_simple(cli, &VGC_backend__%.*s , &bh_%d);\n", - PF(h->name), h->hnum); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(h->name)); - } /*-------------------------------------------------------------------- @@ -785,14 +794,15 @@ t_dir = tl->t; vcc_NextToken(tl); - Fh(tl, 1, "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n", - PF(t_dir), tl->ndirector); - vcc_AddDef(tl, t_dir, R_BACKEND); - tl->ndirector++; if (vcc_IdIs(t_first, "backend")) { vcc_ParseSimpleDirector(tl, t_first, t_dir); } else { + Fh(tl, 1, + "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n", + PF(t_dir), tl->ndirector); + vcc_AddDef(tl, t_dir, R_BACKEND); + tl->ndirector++; ExpectErr(tl, ID); /* ID: policy */ t_policy = tl->t; vcc_NextToken(tl); Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 10:32:21 UTC (rev 4393) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 11:23:41 UTC (rev 4394) @@ -59,6 +59,8 @@ unsigned u, retries; const char *first; + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); + fs = vcc_FldSpec(tl, "?retries", NULL); retries = 0; @@ -145,5 +147,4 @@ Fi(tl, 0, "\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n", PF(t_dir), PF(t_dir)); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 10:32:21 UTC (rev 4393) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 11:23:41 UTC (rev 4394) @@ -57,6 +57,8 @@ struct fld_spec *fs; const char *first; + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); + fs = vcc_FldSpec(tl, "!backend", NULL); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry " @@ -105,5 +107,4 @@ Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_dir_round_robin(" "cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir)); - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); } From phk at projects.linpro.no Tue Dec 15 11:55:07 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 15 Dec 2009 12:55:07 +0100 (CET) Subject: r4395 - trunk/varnish-cache/lib/libvcl Message-ID: <20091215115507.D4ADC1F72E4@projects.linpro.no> Author: phk Date: 2009-12-15 12:55:07 +0100 (Tue, 15 Dec 2009) New Revision: 4395 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c Log: Add vgcname to host struct Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 11:23:41 UTC (rev 4394) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 11:55:07 UTC (rev 4395) @@ -72,6 +72,7 @@ VTAILQ_ENTRY(host) list; int hnum; struct token *name; + char *vgcname; }; static const char * @@ -760,6 +761,8 @@ h->name = t_dir; vcc_AddDef(tl, t_dir, R_BACKEND); sprintf(vgcname, "VGC_backend__%.*s", PF(h->name)); + h->vgcname = TlAlloc(tl, strlen(vgcname) + 1); + strcpy(h->vgcname, vgcname); vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1, vgcname); ERRCHK(tl); From phk at projects.linpro.no Tue Dec 15 12:27:51 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 15 Dec 2009 13:27:51 +0100 (CET) Subject: r4396 - trunk/varnish-cache/lib/libvcl Message-ID: <20091215122751.840131F72E4@projects.linpro.no> Author: phk Date: 2009-12-15 13:27:51 +0100 (Tue, 15 Dec 2009) New Revision: 4396 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_compile.h trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c Log: Avoid dragging the name and policy of the director around in arguments. Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 11:55:07 UTC (rev 4395) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 12:27:51 UTC (rev 4396) @@ -191,21 +191,18 @@ */ static void -vcc_EmitBeIdent(struct vsb *v, const struct token *name, - const struct token *qual, int serial, const struct token *first, - const struct token *last) +vcc_EmitBeIdent(struct tokenlist *tl, struct vsb *v, + int serial, const struct token *first, const struct token *last) { - AN(name); - AN(qual); assert(first != last); vsb_printf(v, "\t.ident ="); if (serial >= 0) { vsb_printf(v, "\n\t \"%.*s %.*s [%d] \"", - PF(qual), PF(name), serial); + PF(tl->t_policy), PF(tl->t_dir), serial); } else { vsb_printf(v, "\n\t \"%.*s %.*s \"", - PF(qual), PF(name)); + PF(tl->t_policy), PF(tl->t_dir)); } while (1) { if (first->dec != NULL) @@ -490,8 +487,8 @@ */ static void -vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name, - const struct token *qual, int serial, const char *vgcname) +vcc_ParseHostDef(struct tokenlist *tl, int *nbh, int serial, + const char *vgcname) { struct token *t_field; struct token *t_first; @@ -530,7 +527,7 @@ *nbh = tl->nbackend_host++; Fb(tl, 0, "\nstatic const struct vrt_backend bh_%d = {\n", *nbh); - Fb(tl, 0, "\t.vcl_name = \"%.*s", PF(name)); + Fb(tl, 0, "\t.vcl_name = \"%.*s", PF(tl->t_dir)); if (serial >= 0) Fb(tl, 0, "[%d]", serial); Fb(tl, 0, "\",\n"); @@ -657,7 +654,7 @@ ExpectErr(tl, '}'); /* We have parsed it all, emit the ident string */ - vcc_EmitBeIdent(tl->fb, name, qual, serial, t_first, tl->t); + vcc_EmitBeIdent(tl, tl->fb, serial, t_first, tl->t); /* Emit the hosthdr field, fall back to .host if not specified */ Fb(tl, 0, "\t.hosthdr = "); @@ -699,8 +696,7 @@ */ void -vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name, - const struct token *qual, int serial) +vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, int serial) { struct host *h; struct token *t; @@ -726,9 +722,9 @@ } else if (tl->t->tok == '{') { t = tl->t; - sprintf(vgcname, "VGC_backend_%.*s_%d", PF(name), serial); + sprintf(vgcname, "VGC_backend_%.*s_%d", PF(tl->t_dir), serial); - vcc_ParseHostDef(tl, nbh, name, qual, serial, vgcname); + vcc_ParseHostDef(tl, nbh, serial, vgcname); if (tl->err) { vsb_printf(tl->sb, "\nIn backend host specification starting at:\n"); @@ -751,20 +747,19 @@ */ static void -vcc_ParseSimpleDirector(struct tokenlist *tl, const struct token *t_first, - struct token *t_dir) +vcc_ParseSimpleDirector(struct tokenlist *tl) { struct host *h; char vgcname[BUFSIZ]; h = TlAlloc(tl, sizeof *h); - h->name = t_dir; - vcc_AddDef(tl, t_dir, R_BACKEND); + h->name = tl->t_dir; + vcc_AddDef(tl, tl->t_dir, R_BACKEND); sprintf(vgcname, "VGC_backend__%.*s", PF(h->name)); h->vgcname = TlAlloc(tl, strlen(vgcname) + 1); strcpy(h->vgcname, vgcname); - vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1, vgcname); + vcc_ParseHostDef(tl, &h->hnum, -1, vgcname); ERRCHK(tl); VTAILQ_INSERT_TAIL(&tl->hosts, h, list); @@ -786,7 +781,7 @@ void vcc_ParseDirector(struct tokenlist *tl) { - struct token *t_dir, *t_first, *t_policy; + struct token *t_first; struct dirlist const *dl; t_first = tl->t; @@ -794,35 +789,36 @@ vcc_ExpectCid(tl); /* ID: name */ ERRCHK(tl); - t_dir = tl->t; + tl->t_dir = tl->t; vcc_NextToken(tl); if (vcc_IdIs(t_first, "backend")) { - vcc_ParseSimpleDirector(tl, t_first, t_dir); + tl->t_policy = t_first; + vcc_ParseSimpleDirector(tl); } else { Fh(tl, 1, "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n", - PF(t_dir), tl->ndirector); - vcc_AddDef(tl, t_dir, R_BACKEND); + PF(tl->t_dir), tl->ndirector); + vcc_AddDef(tl, tl->t_dir, R_BACKEND); tl->ndirector++; ExpectErr(tl, ID); /* ID: policy */ - t_policy = tl->t; + tl->t_policy = tl->t; vcc_NextToken(tl); for (dl = dirlist; dl->name != NULL; dl++) - if (vcc_IdIs(t_policy, dl->name)) + if (vcc_IdIs(tl->t_policy, dl->name)) break; if (dl->name == NULL) { vsb_printf(tl->sb, "Unknown director policy: "); - vcc_ErrToken(tl, t_policy); + vcc_ErrToken(tl, tl->t_policy); vsb_printf(tl->sb, " at\n"); - vcc_ErrWhere(tl, t_policy); + vcc_ErrWhere(tl, tl->t_policy); return; } ExpectErr(tl, '{'); vcc_NextToken(tl); - dl->func(tl, t_policy, t_dir); + dl->func(tl); if (!tl->err) { ExpectErr(tl, '}'); vcc_NextToken(tl); @@ -834,4 +830,6 @@ vcc_ErrWhere(tl, t_first); return; } + tl->t_policy = NULL; + tl->t_dir = NULL; } Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2009-12-15 11:55:07 UTC (rev 4395) +++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2009-12-15 12:27:51 UTC (rev 4396) @@ -89,6 +89,9 @@ VTAILQ_HEAD(, acl_e) acl; + struct token *t_dir; + struct token *t_policy; + unsigned recnt; unsigned nsockaddr; }; @@ -156,12 +159,10 @@ /* vcc_backend.c */ struct fld_spec; -typedef void parsedirector_f(struct tokenlist *tl, - const struct token *t_policy, const struct token *t_dir); +typedef void parsedirector_f(struct tokenlist *tl); void vcc_ParseDirector(struct tokenlist *tl); -void vcc_ParseBackendHost(struct tokenlist *tl, int *nbr, - const struct token *name, const struct token *qual, int serial); +void vcc_ParseBackendHost(struct tokenlist *tl, int *nbr, int serial); struct fld_spec * vcc_FldSpec(struct tokenlist *tl, const char *first, ...); void vcc_ResetFldSpec(struct fld_spec *f); void vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs); Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 11:55:07 UTC (rev 4395) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 12:27:51 UTC (rev 4396) @@ -50,8 +50,7 @@ */ void -vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, - const struct token *t_dir) +vcc_ParseRandomDirector(struct tokenlist *tl) { struct token *t_field, *t_be; int nbh, nelem; @@ -59,7 +58,7 @@ unsigned u, retries; const char *first; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir)); fs = vcc_FldSpec(tl, "?retries", NULL); @@ -83,7 +82,7 @@ Fc(tl, 0, "\nstatic const struct vrt_dir_random_entry vdre_%.*s[] = {\n", - PF(t_dir)); + PF(tl->t_dir)); for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */ first = ""; @@ -99,8 +98,7 @@ vcc_IsField(tl, &t_field, mfs); ERRCHK(tl); if (vcc_IdIs(t_field, "backend")) { - vcc_ParseBackendHost(tl, &nbh, - t_dir, t_policy, nelem); + vcc_ParseBackendHost(tl, &nbh, nelem); Fc(tl, 0, "%s .host = &bh_%d", first, nbh); ERRCHK(tl); } else if (vcc_IdIs(t_field, "weight")) { @@ -138,13 +136,13 @@ Fc(tl, 0, "};\n"); Fc(tl, 0, "\nstatic const struct vrt_dir_random vdr_%.*s = {\n", - PF(t_dir)); - Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_dir)); + PF(tl->t_dir)); + Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir)); Fc(tl, 0, "\t.retries = %u,\n", retries); Fc(tl, 0, "\t.nmember = %d,\n", nelem); - Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(t_dir)); + Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n", - PF(t_dir), PF(t_dir)); + PF(tl->t_dir), PF(tl->t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 11:55:07 UTC (rev 4395) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 12:27:51 UTC (rev 4396) @@ -49,20 +49,19 @@ */ void -vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy, - const struct token *t_dir) +vcc_ParseRoundRobinDirector(struct tokenlist *tl) { struct token *t_field, *t_be; int nbh, nelem; struct fld_spec *fs; const char *first; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir)); fs = vcc_FldSpec(tl, "!backend", NULL); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry " - "vdrre_%.*s[] = {\n", PF(t_dir)); + "vdrre_%.*s[] = {\n", PF(tl->t_dir)); for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */ first = ""; @@ -78,8 +77,7 @@ vcc_IsField(tl, &t_field, fs); ERRCHK(tl); if (vcc_IdIs(t_field, "backend")) { - vcc_ParseBackendHost(tl, &nbh, - t_dir, t_policy, nelem); + vcc_ParseBackendHost(tl, &nbh, nelem); Fc(tl, 0, "%s .host = &bh_%d", first, nbh); ERRCHK(tl); } else { @@ -100,11 +98,12 @@ Fc(tl, 0, "};\n"); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin vdrr_%.*s = {\n", - PF(t_dir)); - Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_dir)); + PF(tl->t_dir)); + Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir)); Fc(tl, 0, "\t.nmember = %d,\n", nelem); - Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(t_dir)); + Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_dir_round_robin(" - "cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir)); + "cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", + PF(tl->t_dir), PF(tl->t_dir)); } From tfheen at projects.linpro.no Wed Dec 16 08:26:48 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 09:26:48 +0100 (CET) Subject: r4397 - trunk/varnish-cache/bin/varnishd Message-ID: <20091216082648.58F851F74D5@projects.linpro.no> Author: tfheen Date: 2009-12-16 09:26:48 +0100 (Wed, 16 Dec 2009) New Revision: 4397 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: s/url.purge/purge.url/ in help The documentation referred to deprecated url.purge, make it point to purge.url instead. Maybe it should be updated to the new purge syntax. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2009-12-15 12:27:51 UTC (rev 4396) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2009-12-16 08:26:48 UTC (rev 4397) @@ -483,7 +483,7 @@ "Objects already cached will not be affected by changes " "made until they are fetched from the backend again.\n" "To force an immediate effect at the expense of a total " - "flush of the cache use \"url.purge .\"", + "flush of the cache use \"purge.url .\"", 0, "120", "seconds" }, { "sess_workspace", tweak_uint, &master.sess_workspace, 1024, UINT_MAX, From tfheen at projects.linpro.no Wed Dec 16 08:50:50 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 09:50:50 +0100 (CET) Subject: r4398 - branches/2.0/varnish-cache/bin/varnishd Message-ID: <20091216085050.2011E1F74F6@projects.linpro.no> Author: tfheen Date: 2009-12-16 09:50:49 +0100 (Wed, 16 Dec 2009) New Revision: 4398 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c Log: Merge small part of r4215: Charge sessions when herding In 2.0.5 we default to lingering for a bit which can cause sessions to not be charged for a long time. This fixes it. Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-12-16 08:26:48 UTC (rev 4397) +++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-12-16 08:50:49 UTC (rev 4398) @@ -105,6 +105,7 @@ if (i == 0) { WSL(sp->wrk, SLT_Debug, sp->fd, "herding"); VSL_stats->sess_herd++; + SES_Charge(sp); sp->wrk = NULL; vca_return_session(sp); return (1); From tfheen at projects.linpro.no Wed Dec 16 08:59:41 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 09:59:41 +0100 (CET) Subject: r4399 - in branches/2.0/varnish-cache: bin/varnishd include/compat lib/libvarnishcompat Message-ID: <20091216085941.6FD661F7500@projects.linpro.no> Author: tfheen Date: 2009-12-16 09:59:41 +0100 (Wed, 16 Dec 2009) New Revision: 4399 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_panic.c branches/2.0/varnish-cache/include/compat/execinfo.h branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c Log: Merge r4349: Hide GCC specific backtrace() compat function under a #ifdef. We do not want to be dependent on GCC. Fixes #577 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_panic.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_panic.c 2009-12-16 08:50:49 UTC (rev 4398) +++ branches/2.0/varnish-cache/bin/varnishd/cache_panic.c 2009-12-16 08:59:41 UTC (rev 4399) @@ -264,6 +264,8 @@ size_t i; size = backtrace (array, 10); + if (size == 0) + return; vsb_printf(vsp, "Backtrace:\n"); for (i = 0; i < size; i++) { vsb_printf (vsp, " "); Modified: branches/2.0/varnish-cache/include/compat/execinfo.h =================================================================== --- branches/2.0/varnish-cache/include/compat/execinfo.h 2009-12-16 08:50:49 UTC (rev 4398) +++ branches/2.0/varnish-cache/include/compat/execinfo.h 2009-12-16 08:59:41 UTC (rev 4399) @@ -35,7 +35,6 @@ int backtrace(void **, int); char ** backtrace_symbols(void *const *, int); -void backtrace_symbols_fd(void *const *, int, int); #ifdef __cplusplus } Modified: branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c =================================================================== --- branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-16 08:50:49 UTC (rev 4398) +++ branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-16 08:59:41 UTC (rev 4399) @@ -28,6 +28,10 @@ #include "config.h" +#include "compat/execinfo.h" + +#if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */ + #include #include #include @@ -38,10 +42,9 @@ #include #include -#include "compat/execinfo.h" -void *getreturnaddr(int); -void *getframeaddr(int); +static void *getreturnaddr(int); +static void *getframeaddr(int); #define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1))) @@ -132,51 +135,7 @@ return rval; } -#if 0 -void -backtrace_symbols_fd(void *const *buffer, int size, int fd) -{ - int i, len, offset; - char *buf; - Dl_info info; - - for (i = 0; i < size; i++) { - if (dladdr(buffer[i], &info) != 0) { - if (info.dli_sname == NULL) - info.dli_sname = "???"; - if (info.dli_saddr == NULL) - info.dli_saddr = buffer[i]; - offset = (const char *)buffer[i] - (const char *)info.dli_saddr; - /* "0x01234567 at filename" */ - len = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 2 + /* " <" */ - strlen(info.dli_sname) + /* "function" */ - 1 + /* "+" */ - D10(offset) + /* "offset */ - 5 + /* "> at " */ - strlen(info.dli_fname) + /* "filename" */ - 2; /* "\n\0" */ - buf = alloca(len); - if (buf == NULL) - return; - snprintf(buf, len, "%p <%s+%d> at %s\n", - buffer[i], info.dli_sname, offset, info.dli_fname); - } else { - len = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 2; /* "\n\0" */ - buf = alloca(len); - if (buf == NULL) - return; - snprintf(buf, len, "%p\n", buffer[i]); - } - write(fd, buf, len - 1); - } -} -#endif - -void * +static void * getreturnaddr(int level) { @@ -313,7 +272,7 @@ } } -void * +static void * getframeaddr(int level) { @@ -449,3 +408,23 @@ default: return NULL; } } + +#else + +int +backtrace(void **buffer, int size) +{ + (void)buffer; + (void)size; + return (0); +} + +char ** +backtrace_symbols(void *const *buffer, int size) +{ + (void)buffer; + (void)size; + return (0); +} + +#endif From tfheen at projects.linpro.no Wed Dec 16 09:26:03 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 10:26:03 +0100 (CET) Subject: r4400 - in branches/2.0/varnish-cache: . lib/libvarnishcompat Message-ID: <20091216092603.671E91F74F6@projects.linpro.no> Author: tfheen Date: 2009-12-16 10:26:03 +0100 (Wed, 16 Dec 2009) New Revision: 4400 Modified: branches/2.0/varnish-cache/configure.ac branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c Log: Merge r4382: Use built-in backtrace function if one exists This gives us backtraces on panic on when you're not using GCC too. Modified: branches/2.0/varnish-cache/configure.ac =================================================================== --- branches/2.0/varnish-cache/configure.ac 2009-12-16 08:59:41 UTC (rev 4399) +++ branches/2.0/varnish-cache/configure.ac 2009-12-16 09:26:03 UTC (rev 4400) @@ -175,6 +175,7 @@ AC_CHECK_FUNCS([strlcat strlcpy]) AC_CHECK_FUNCS([strndup]) AC_CHECK_FUNCS([daemon]) +AC_CHECK_FUNCS([backtrace]) AC_SYS_LARGEFILE save_LIBS="${LIBS}" Modified: branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c =================================================================== --- branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-16 08:59:41 UTC (rev 4399) +++ branches/2.0/varnish-cache/lib/libvarnishcompat/execinfo.c 2009-12-16 09:26:03 UTC (rev 4400) @@ -28,6 +28,8 @@ #include "config.h" +#ifndef HAVE_BACKTRACE + #include "compat/execinfo.h" #if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */ @@ -427,4 +429,5 @@ return (0); } -#endif +#endif /* (__GNUC__) && __GNUC__ >= 4 */ +#endif /* HAVE_BACKTRACE */ From phk at projects.linpro.no Wed Dec 16 09:53:26 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 10:53:26 +0100 (CET) Subject: r4401 - trunk/varnish-cache/lib/libvcl Message-ID: <20091216095326.0C6841F74F6@projects.linpro.no> Author: phk Date: 2009-12-16 10:53:25 +0100 (Wed, 16 Dec 2009) New Revision: 4401 Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_compile.c trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c trunk/varnish-cache/lib/libvcl/vcc_parse.c Log: Refer to directors by integer index instead of pointer. Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_action.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -251,7 +251,7 @@ vcc_ExpectCid(tl); ERRCHK(tl); vcc_AddRef(tl, tl->t, R_BACKEND); - Fb(tl, 0, "VGC_backend__%.*s", PF(tl->t)); + Fb(tl, 0, "VGCDIR(_%.*s)", PF(tl->t)); vcc_NextToken(tl); Fb(tl, 0, ");\n"); break; Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -501,8 +501,7 @@ struct vsb *vsb; unsigned u; - Fh(tl, 1, "\n#define %s (VCL_conf.director[%d])\n", - vgcname, tl->ndirector); + Fh(tl, 1, "\n#define VGC_backend_%s %d\n", vgcname, tl->ndirector); fs = vcc_FldSpec(tl, "!host", @@ -677,9 +676,9 @@ Fh(tl, 0, "%s", vsb_data(vsb)); vsb_delete(vsb); - Fi(tl, 0, "\tVRT_init_dir_simple(cli, &%s, &bh_%d);\n", + Fi(tl, 0, "\tVRT_init_dir_simple(cli, &VGCDIR(%s), &bh_%d);\n", vgcname, *nbh); - Ff(tl, 0, "\tVRT_fini_dir(cli, %s);\n", vgcname); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(%s));\n", vgcname); tl->ndirector++; } @@ -722,7 +721,7 @@ } else if (tl->t->tok == '{') { t = tl->t; - sprintf(vgcname, "VGC_backend_%.*s_%d", PF(tl->t_dir), serial); + sprintf(vgcname, "%.*s_%d", PF(tl->t_dir), serial); vcc_ParseHostDef(tl, nbh, serial, vgcname); if (tl->err) { @@ -755,7 +754,7 @@ h = TlAlloc(tl, sizeof *h); h->name = tl->t_dir; vcc_AddDef(tl, tl->t_dir, R_BACKEND); - sprintf(vgcname, "VGC_backend__%.*s", PF(h->name)); + sprintf(vgcname, "_%.*s", PF(h->name)); h->vgcname = TlAlloc(tl, strlen(vgcname) + 1); strcpy(h->vgcname, vgcname); @@ -797,8 +796,7 @@ tl->t_policy = t_first; vcc_ParseSimpleDirector(tl); } else { - Fh(tl, 1, - "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n", + Fh(tl, 1, "\n#define VGC_backend__%.*s %d\n", PF(tl->t_dir), tl->ndirector); vcc_AddDef(tl, tl->t_dir, R_BACKEND); tl->ndirector++; Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -552,6 +552,9 @@ Fh(tl, 0, "\n/* ---===### VCC generated below here ###===---*/\n"); Fh(tl, 0, "\nextern const struct VCL_conf VCL_conf;\n"); + /* Macro for accessing directors */ + Fh(tl, 0, "#define VGCDIR(n) VCL_conf.director[VGC_backend_##n]\n"); + /* Register and lex the main source */ VTAILQ_INSERT_TAIL(&tl->sources, sp, list); sp->idx = tl->nsources++; Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -58,7 +58,7 @@ unsigned u, retries; const char *first; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir)); fs = vcc_FldSpec(tl, "?retries", NULL); @@ -142,7 +142,6 @@ Fc(tl, 0, "\t.nmember = %d,\n", nelem); Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); - Fi(tl, 0, - "\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n", + Fi(tl, 0, "\tVRT_init_dir_random(cli, &VGCDIR(_%.*s) , &vdr_%.*s);\n", PF(tl->t_dir), PF(tl->t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -56,7 +56,7 @@ struct fld_spec *fs; const char *first; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir)); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir)); fs = vcc_FldSpec(tl, "!backend", NULL); @@ -104,6 +104,6 @@ Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_dir_round_robin(" - "cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", + "cli, &VGCDIR(_%.*s), &vdrr_%.*s);\n", PF(tl->t_dir), PF(tl->t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_parse.c 2009-12-16 09:26:03 UTC (rev 4400) +++ trunk/varnish-cache/lib/libvcl/vcc_parse.c 2009-12-16 09:53:25 UTC (rev 4401) @@ -322,7 +322,7 @@ vcc_ExpectCid(tl); ERRCHK(tl); vcc_AddRef(tl, tl->t, R_BACKEND); - Fb(tl, 1, "VGC_backend__%.*s\n", PF(tl->t)); + Fb(tl, 1, "VGCDIR(_%.*s)\n", PF(tl->t)); vcc_NextToken(tl); } From tfheen at projects.linpro.no Wed Dec 16 09:55:38 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 10:55:38 +0100 (CET) Subject: r4402 - branches/2.0/varnish-cache/bin/varnishd Message-ID: <20091216095538.5FF351F74F6@projects.linpro.no> Author: tfheen Date: 2009-12-16 10:55:37 +0100 (Wed, 16 Dec 2009) New Revision: 4402 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_pool.c branches/2.0/varnish-cache/bin/varnishd/heritage.h branches/2.0/varnish-cache/bin/varnishd/mgt_pool.c Log: Merge r4352: Add a parameter to set the workerthread stacksize. On 32 bit systems, it may be necessary to tweak this down to get high numbers of worker threads squeezed into the address-space. I have no idea how much stack-space a worker thread normally uses, so no guidance is given, and we default to the system default. Fixes #572 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_pool.c 2009-12-16 09:53:25 UTC (rev 4401) +++ branches/2.0/varnish-cache/bin/varnishd/cache_pool.c 2009-12-16 09:55:37 UTC (rev 4402) @@ -551,7 +551,7 @@ */ static void -wrk_breed_flock(struct wq *qp) +wrk_breed_flock(struct wq *qp, const pthread_attr_t *tp_attr) { pthread_t tp; @@ -564,7 +564,7 @@ qp->nqueue > qp->lqueue)) { /* not getting better since last */ if (qp->nthr >= nthr_max) { VSL_stats->n_wrk_max++; - } else if (pthread_create(&tp, NULL, wrk_thread, qp)) { + } else if (pthread_create(&tp, tp_attr, wrk_thread, qp)) { VSL(SLT_Debug, 0, "Create worker thread failed %d %s", errno, strerror(errno)); VSL_stats->n_wrk_failed++; @@ -595,17 +595,27 @@ wrk_herder_thread(void *priv) { unsigned u, w; + pthread_attr_t tp_attr; + /* Set the stacksize for worker threads */ + AZ(pthread_attr_init(&tp_attr)); + THR_SetName("wrk_herder"); (void)priv; while (1) { for (u = 0 ; u < nwq; u++) { + if (params->wthread_stacksize != UINT_MAX) + AZ(pthread_attr_setstacksize(&tp_attr, + params->wthread_stacksize)); + + wrk_breed_flock(wq[u], &tp_attr); + /* * Make sure all pools have their minimum complement */ for (w = 0 ; w < nwq; w++) while (wq[w]->nthr < params->wthread_min) - wrk_breed_flock(wq[w]); + wrk_breed_flock(wq[w], &tp_attr); /* * We cannot avoid getting a mutex, so we have a * bogo mutex just for POSIX_STUPIDITY @@ -613,7 +623,6 @@ Lck_Lock(&herder_mtx); Lck_CondWait(&herder_cond, &herder_mtx); Lck_Unlock(&herder_mtx); - wrk_breed_flock(wq[u]); } } } Modified: branches/2.0/varnish-cache/bin/varnishd/heritage.h =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/heritage.h 2009-12-16 09:53:25 UTC (rev 4401) +++ branches/2.0/varnish-cache/bin/varnishd/heritage.h 2009-12-16 09:55:37 UTC (rev 4402) @@ -94,6 +94,7 @@ unsigned wthread_add_delay; unsigned wthread_fail_delay; unsigned wthread_purge_delay; + unsigned wthread_stacksize; unsigned overflow_max; Modified: branches/2.0/varnish-cache/bin/varnishd/mgt_pool.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/mgt_pool.c 2009-12-16 09:53:25 UTC (rev 4401) +++ branches/2.0/varnish-cache/bin/varnishd/mgt_pool.c 2009-12-16 09:55:37 UTC (rev 4402) @@ -179,6 +179,13 @@ "number of worker threads. ", EXPERIMENTAL, "3", "requests per request" }, + { "thread_pool_stack", + tweak_uint, &master.wthread_stacksize, 64*1024, UINT_MAX, + "Worker thread stack size. In particular on 32bit systems " + "you may need to tweak this down to fit many threads into " + "the limited address space.\n", + EXPERIMENTAL, + "-1", "bytes" }, { NULL, NULL, NULL } }; From tfheen at projects.linpro.no Wed Dec 16 10:08:21 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 11:08:21 +0100 (CET) Subject: r4403 - branches/2.0/varnish-cache/bin/varnishtest/tests Message-ID: <20091216100821.5C9961F74F6@projects.linpro.no> Author: tfheen Date: 2009-12-16 11:08:20 +0100 (Wed, 16 Dec 2009) New Revision: 4403 Added: branches/2.0/varnish-cache/bin/varnishtest/tests/c00031.vtc Log: Merge r4353: Add test case for setting stacksize of worker thread Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/c00031.vtc (from rev 4353, trunk/varnish-cache/bin/varnishtest/tests/c00031.vtc) =================================================================== --- branches/2.0/varnish-cache/bin/varnishtest/tests/c00031.vtc (rev 0) +++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00031.vtc 2009-12-16 10:08:20 UTC (rev 4403) @@ -0,0 +1,19 @@ +# Test that we get anything through at all +# +# $Id: c00002.vtc 3053 2008-08-01 09:22:21Z phk $ + +test "Worker thread stack size setting" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p thread_pool_stack=131072" -vcl+backend {} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} -run + From tfheen at projects.linpro.no Wed Dec 16 10:16:59 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 11:16:59 +0100 (CET) Subject: r4404 - branches/2.0/varnish-cache/bin/varnishtest Message-ID: <20091216101659.E42421F769E@projects.linpro.no> Author: tfheen Date: 2009-12-16 11:16:59 +0100 (Wed, 16 Dec 2009) New Revision: 4404 Modified: branches/2.0/varnish-cache/bin/varnishtest/vtc.c Log: Merge r4359: Fix random signature recognition on 64bit OS Modified: branches/2.0/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishtest/vtc.c 2009-12-16 10:08:20 UTC (rev 4403) +++ branches/2.0/varnish-cache/bin/varnishtest/vtc.c 2009-12-16 10:16:59 UTC (rev 4404) @@ -294,7 +294,7 @@ static void cmd_random(CMD_ARGS) { - unsigned long l; + uint32_t l; int i; (void)cmd; From phk at projects.linpro.no Wed Dec 16 10:45:39 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 11:45:39 +0100 (CET) Subject: r4405 - in trunk/varnish-cache: bin/varnishd include lib/libvcl Message-ID: <20091216104539.D3A531F7530@projects.linpro.no> Author: phk Date: 2009-12-16 11:45:39 +0100 (Wed, 16 Dec 2009) New Revision: 4405 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_vrt.c trunk/varnish-cache/include/vrt.h trunk/varnish-cache/lib/libvcl/vcc_backend.c trunk/varnish-cache/lib/libvcl/vcc_compile.h trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c Log: Get rid of all reference to backend index numbers in the compiled VCL code. Unify the call to initialize a director, fan it out in the VRT code. Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 10:45:39 UTC (rev 4405) @@ -154,3 +154,15 @@ /* cache_backend_poll.c */ void VBP_Start(struct backend *b, struct vrt_backend_probe const *p); void VBP_Stop(struct backend *b); + + +/* Init functions for directors */ +struct vrt_backend; +void VRT_init_dir_simple(struct cli *, struct director **, + const struct vrt_backend *); +struct vrt_dir_random; +void VRT_init_dir_random(struct cli *, struct director **, + const struct vrt_dir_random *); +struct vrt_dir_round_robin; +void VRT_init_dir_round_robin(struct cli *, struct director **, + const struct vrt_dir_round_robin *); Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 10:45:39 UTC (rev 4405) @@ -850,7 +850,24 @@ } /*--------------------------------------------------------------------*/ +void +VRT_init_dir(struct cli *cli, struct director **dir, const char *name, + int idx, const void *priv) +{ + if (!strcmp(name, "simple")) + VRT_init_dir_simple(cli, dir + idx, priv); + else if (!strcmp(name, "random")) + VRT_init_dir_random(cli, dir + idx, priv); + else if (!strcmp(name, "round-robin")) + VRT_init_dir_round_robin(cli, dir + idx, priv); + else + INCOMPL(); +} + + +/*--------------------------------------------------------------------*/ + void VRT_Rollback(struct sess *sp) { Modified: trunk/varnish-cache/include/vrt.h =================================================================== --- trunk/varnish-cache/include/vrt.h 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/include/vrt.h 2009-12-16 10:45:39 UTC (rev 4405) @@ -161,12 +161,8 @@ void VRT_synth_page(struct sess *sp, unsigned flags, const char *, ...); /* Backend related */ -void VRT_init_dir_simple(struct cli *, struct director **, - const struct vrt_backend *); -void VRT_init_dir_random(struct cli *, struct director **, - const struct vrt_dir_random *); -void VRT_init_dir_round_robin(struct cli *, struct director **, - const struct vrt_dir_round_robin *); +void VRT_init_dir(struct cli *, struct director **, const char *name, + int idx, const void *priv); void VRT_fini_dir(struct cli *, struct director *); char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa); Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 10:45:39 UTC (rev 4405) @@ -70,7 +70,6 @@ struct host { VTAILQ_ENTRY(host) list; - int hnum; struct token *name; char *vgcname; }; @@ -487,8 +486,7 @@ */ static void -vcc_ParseHostDef(struct tokenlist *tl, int *nbh, int serial, - const char *vgcname) +vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname) { struct token *t_field; struct token *t_first; @@ -523,8 +521,8 @@ AN(vsb); tl->fb = vsb; - *nbh = tl->nbackend_host++; - Fb(tl, 0, "\nstatic const struct vrt_backend bh_%d = {\n", *nbh); + Fb(tl, 0, "\nstatic const struct vrt_backend vgc_dir_priv_%s = {\n", + vgcname); Fb(tl, 0, "\t.vcl_name = \"%.*s", PF(tl->t_dir)); if (serial >= 0) @@ -676,8 +674,8 @@ Fh(tl, 0, "%s", vsb_data(vsb)); vsb_delete(vsb); - Fi(tl, 0, "\tVRT_init_dir_simple(cli, &VGCDIR(%s), &bh_%d);\n", - vgcname, *nbh); + Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director, \"simple\",\n" + "\t VGC_backend_%s, &vgc_dir_priv_%s);\n", vgcname, vgcname); Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(%s));\n", vgcname); tl->ndirector++; } @@ -695,12 +693,14 @@ */ void -vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, int serial) +vcc_ParseBackendHost(struct tokenlist *tl, int serial, char **nm) { struct host *h; struct token *t; char vgcname[BUFSIZ]; + AN(nm); + *nm = NULL; if (tl->t->tok == ID) { VTAILQ_FOREACH(h, &tl->hosts, list) { if (vcc_Teq(h->name, tl->t)) @@ -717,18 +717,22 @@ vcc_NextToken(tl); ExpectErr(tl, ';'); vcc_NextToken(tl); - *nbh = h->hnum; + *nm = h->vgcname; } else if (tl->t->tok == '{') { t = tl->t; sprintf(vgcname, "%.*s_%d", PF(tl->t_dir), serial); - vcc_ParseHostDef(tl, nbh, serial, vgcname); + Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", + PF(tl->t_dir)); + vcc_ParseHostDef(tl, serial, vgcname); if (tl->err) { vsb_printf(tl->sb, "\nIn backend host specification starting at:\n"); vcc_ErrWhere(tl, t); } + *nm = strdup(vgcname); /* XXX */ + return; } else { vsb_printf(tl->sb, @@ -758,7 +762,7 @@ h->vgcname = TlAlloc(tl, strlen(vgcname) + 1); strcpy(h->vgcname, vgcname); - vcc_ParseHostDef(tl, &h->hnum, -1, vgcname); + vcc_ParseHostDef(tl, -1, vgcname); ERRCHK(tl); VTAILQ_INSERT_TAIL(&tl->hosts, h, list); @@ -821,6 +825,13 @@ ExpectErr(tl, '}'); vcc_NextToken(tl); } + Fi(tl, 0, + "\tVRT_init_dir(cli, VCL_conf.director, \"%.*s\",\n", + PF(tl->t_policy)); + Fi(tl, 0, "\t VGC_backend__%.*s, &vgc_dir_priv_%.*s);\n", + PF(tl->t_dir), PF(tl->t_dir)); + + } if (tl->err) { vsb_printf(tl->sb, Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2009-12-16 10:45:39 UTC (rev 4405) @@ -81,7 +81,6 @@ VTAILQ_HEAD(, ref) refs; struct vsb *sb; int err; - int nbackend_host; int ndirector; VTAILQ_HEAD(, proc) procs; struct proc *curproc; @@ -162,7 +161,7 @@ typedef void parsedirector_f(struct tokenlist *tl); void vcc_ParseDirector(struct tokenlist *tl); -void vcc_ParseBackendHost(struct tokenlist *tl, int *nbr, int serial); +void vcc_ParseBackendHost(struct tokenlist *tl, int serial, char **nm); struct fld_spec * vcc_FldSpec(struct tokenlist *tl, const char *first, ...); void vcc_ResetFldSpec(struct fld_spec *f); void vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs); Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 10:45:39 UTC (rev 4405) @@ -53,13 +53,12 @@ vcc_ParseRandomDirector(struct tokenlist *tl) { struct token *t_field, *t_be; - int nbh, nelem; + int nelem; struct fld_spec *fs, *mfs; unsigned u, retries; const char *first; + char *p; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir)); - fs = vcc_FldSpec(tl, "?retries", NULL); retries = 0; @@ -88,7 +87,6 @@ first = ""; t_be = tl->t; vcc_ResetFldSpec(mfs); - nbh = -1; ExpectErr(tl, '{'); vcc_NextToken(tl); @@ -98,9 +96,11 @@ vcc_IsField(tl, &t_field, mfs); ERRCHK(tl); if (vcc_IdIs(t_field, "backend")) { - vcc_ParseBackendHost(tl, &nbh, nelem); - Fc(tl, 0, "%s .host = &bh_%d", first, nbh); + vcc_ParseBackendHost(tl, nelem, &p); ERRCHK(tl); + AN(p); + Fc(tl, 0, "%s .host = &vgc_dir_priv_%s", + first, p); } else if (vcc_IdIs(t_field, "weight")) { ExpectErr(tl, CNUM); u = vcc_UintVal(tl); @@ -135,13 +135,11 @@ } Fc(tl, 0, "};\n"); Fc(tl, 0, - "\nstatic const struct vrt_dir_random vdr_%.*s = {\n", + "\nstatic const struct vrt_dir_random vgc_dir_priv_%.*s = {\n", PF(tl->t_dir)); Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir)); Fc(tl, 0, "\t.retries = %u,\n", retries); Fc(tl, 0, "\t.nmember = %d,\n", nelem); Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); - Fi(tl, 0, "\tVRT_init_dir_random(cli, &VGCDIR(_%.*s) , &vdr_%.*s);\n", - PF(tl->t_dir), PF(tl->t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 10:45:39 UTC (rev 4405) @@ -52,12 +52,11 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl) { struct token *t_field, *t_be; - int nbh, nelem; + int nelem; struct fld_spec *fs; const char *first; + char *p; - Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir)); - fs = vcc_FldSpec(tl, "!backend", NULL); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry " @@ -67,7 +66,6 @@ first = ""; t_be = tl->t; vcc_ResetFldSpec(fs); - nbh = -1; ExpectErr(tl, '{'); vcc_NextToken(tl); @@ -77,9 +75,11 @@ vcc_IsField(tl, &t_field, fs); ERRCHK(tl); if (vcc_IdIs(t_field, "backend")) { - vcc_ParseBackendHost(tl, &nbh, nelem); - Fc(tl, 0, "%s .host = &bh_%d", first, nbh); + vcc_ParseBackendHost(tl, nelem, &p); ERRCHK(tl); + AN(p); + Fc(tl, 0, "%s .host = &vgc_dir_priv_%s", + first, p); } else { ErrInternal(tl); } @@ -97,13 +97,10 @@ } Fc(tl, 0, "};\n"); Fc(tl, 0, - "\nstatic const struct vrt_dir_round_robin vdrr_%.*s = {\n", + "\nstatic const struct vrt_dir_round_robin vgc_dir_priv_%.*s = {\n", PF(tl->t_dir)); Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir)); Fc(tl, 0, "\t.nmember = %d,\n", nelem); Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); - Fi(tl, 0, "\tVRT_init_dir_round_robin(" - "cli, &VGCDIR(_%.*s), &vdrr_%.*s);\n", - PF(tl->t_dir), PF(tl->t_dir)); } Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-16 10:16:59 UTC (rev 4404) +++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-16 10:45:39 UTC (rev 4405) @@ -227,8 +227,8 @@ vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI"); vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT"); vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"); - vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4356 2009-11-19 11:"); - vsb_cat(sb, "40:23Z phk $\n *\n * Runtime support for compiled VCL "); + vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4391 2009-12-14 12:"); + vsb_cat(sb, "10:15Z phk $\n *\n * Runtime support for compiled VCL "); vsb_cat(sb, "programs.\n *\n * XXX: When this file is changed, lib/"); vsb_cat(sb, "libvcl/vcc_gen_fixed_token.tcl\n"); vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n"); @@ -297,13 +297,9 @@ vsb_cat(sb, ");\nvoid VRT_Rollback(struct sess *sp);\n"); vsb_cat(sb, "\n/* Synthetic pages */\nvoid VRT_synth_page(struct se"); vsb_cat(sb, "ss *sp, unsigned flags, const char *, ...);\n"); - vsb_cat(sb, "\n/* Backend related */\nvoid VRT_init_dir_simple(stru"); - vsb_cat(sb, "ct cli *, struct director **,\n"); - vsb_cat(sb, " const struct vrt_backend *);\n"); - vsb_cat(sb, "void VRT_init_dir_random(struct cli *, struct director"); - vsb_cat(sb, " **,\n const struct vrt_dir_random *);\n"); - vsb_cat(sb, "void VRT_init_dir_round_robin(struct cli *, struct dir"); - vsb_cat(sb, "ector **,\n const struct vrt_dir_round_robin *);\n"); + vsb_cat(sb, "\n/* Backend related */\nvoid VRT_init_dir(struct cli "); + vsb_cat(sb, "*, struct director **, const char *name,\n"); + vsb_cat(sb, " int idx, const void *priv);\n"); vsb_cat(sb, "void VRT_fini_dir(struct cli *, struct director *);\n"); vsb_cat(sb, "\nchar *VRT_IP_string(const struct sess *sp, const str"); vsb_cat(sb, "uct sockaddr *sa);\nchar *VRT_int_string(const struct "); From tfheen at projects.linpro.no Wed Dec 16 10:45:45 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 11:45:45 +0100 (CET) Subject: r4406 - branches/2.0/varnish-cache/bin/varnishd Message-ID: <20091216104545.9E7291F7B18@projects.linpro.no> Author: tfheen Date: 2009-12-16 11:45:45 +0100 (Wed, 16 Dec 2009) New Revision: 4406 Modified: branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c Log: Merge r4369: Add a debug.listen_address cli command to report the actual listen address(es) Modified: branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c 2009-12-16 10:45:39 UTC (rev 4405) +++ branches/2.0/varnish-cache/bin/varnishd/cache_acceptor.c 2009-12-16 10:45:45 UTC (rev 4406) @@ -351,16 +351,46 @@ VSL(SLT_Debug, 0, "Acceptor is %s", vca_act->name); } +/*--------------------------------------------------------------------*/ + +static void +ccf_listen_address(struct cli *cli, const char * const *av, void *priv) +{ + struct listen_sock *ls; + char h[32], p[32]; + + (void)cli; + (void)av; + (void)priv; + VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) + continue; + TCP_myname(ls->sock, h, sizeof h, p, sizeof p); + cli_out(cli, "%s %s\n", h, p); + } +} + +/*--------------------------------------------------------------------*/ + static struct cli_proto vca_cmds[] = { { CLI_SERVER_START, ccf_start }, { NULL } }; +static struct cli_proto vca_debug_cmds[] = { + { "debug.listen_address", + "debug.listen_address", + "Report the actual listen address\n", 0, 0, + ccf_listen_address, NULL }, + { NULL } +}; + void VCA_Init(void) { CLI_AddFuncs(MASTER_CLI, vca_cmds); + CLI_AddFuncs(DEBUG_CLI, vca_debug_cmds); } void From tfheen at projects.linpro.no Wed Dec 16 11:05:06 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 12:05:06 +0100 (CET) Subject: r4407 - branches/2.0/varnish-cache/man Message-ID: <20091216110506.30F0E1F769E@projects.linpro.no> Author: tfheen Date: 2009-12-16 12:05:05 +0100 (Wed, 16 Dec 2009) New Revision: 4407 Modified: branches/2.0/varnish-cache/man/vcl.7so Log: Merge r4383: Remove spurious .Ed Fixes #591 Modified: branches/2.0/varnish-cache/man/vcl.7so =================================================================== --- branches/2.0/varnish-cache/man/vcl.7so 2009-12-16 10:45:45 UTC (rev 4406) +++ branches/2.0/varnish-cache/man/vcl.7so 2009-12-16 11:05:05 UTC (rev 4407) @@ -96,7 +96,6 @@ To avoid overloading backend servers, .Fa .max_connections can be set to limit the maximum number of concurrent backend connections. -.Ed .Pp The timeout parameters can be overridden in the backend declaration. The timeout parameters are From tfheen at projects.linpro.no Wed Dec 16 11:14:46 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 12:14:46 +0100 (CET) Subject: r4408 - branches/2.0/varnish-cache/lib/libvarnish Message-ID: <20091216111446.CF09D1F7530@projects.linpro.no> Author: tfheen Date: 2009-12-16 12:14:46 +0100 (Wed, 16 Dec 2009) New Revision: 4408 Modified: branches/2.0/varnish-cache/lib/libvarnish/tcp.c Log: Merge r4384: Don't panic in TCP_linger() if the other end closed on us. Fixes #547 Modified: branches/2.0/varnish-cache/lib/libvarnish/tcp.c =================================================================== --- branches/2.0/varnish-cache/lib/libvarnish/tcp.c 2009-12-16 11:05:05 UTC (rev 4407) +++ branches/2.0/varnish-cache/lib/libvarnish/tcp.c 2009-12-16 11:14:46 UTC (rev 4408) @@ -239,8 +239,10 @@ TCP_linger(int sock, int linger) { struct linger lin; + int i; memset(&lin, 0, sizeof lin); lin.l_onoff = linger; - AZ(setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin)); + i = setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin); + assert(i == 0 || errno == EBADF); } From tfheen at projects.linpro.no Wed Dec 16 11:21:16 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 12:21:16 +0100 (CET) Subject: r4409 - branches/2.0/varnish-cache/man Message-ID: <20091216112116.DA02B1F7530@projects.linpro.no> Author: tfheen Date: 2009-12-16 12:21:16 +0100 (Wed, 16 Dec 2009) New Revision: 4409 Modified: branches/2.0/varnish-cache/man/vcl.7so Log: Merge r4385: Fix Set-Cookie vs Cookie confusion and old keywords. Fixes #600 Modified: branches/2.0/varnish-cache/man/vcl.7so =================================================================== --- branches/2.0/varnish-cache/man/vcl.7so 2009-12-16 11:14:46 UTC (rev 4408) +++ branches/2.0/varnish-cache/man/vcl.7so 2009-12-16 11:21:16 UTC (rev 4409) @@ -358,8 +358,8 @@ .\" vcl_hash .It Cm vcl_hash Use -.Cm req.hash += req.http.Set-Cookie -or similar to include the Set-Cookie HTTP header in the hash string. +.Cm req.hash += req.http.Cookie +or similar to include the Cookie HTTP header in the hash string. The .Cm vcl_hash subroutine may terminate with one of the following keywords: @@ -687,7 +687,7 @@ sub vcl_fetch { if (obj.http.Set-Cookie) { - insert; + deliver; } } .Ed From tfheen at projects.linpro.no Wed Dec 16 11:30:42 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 12:30:42 +0100 (CET) Subject: r4410 - branches/2.0/varnish-cache/lib/libjemalloc Message-ID: <20091216113042.DAC5A1F7530@projects.linpro.no> Author: tfheen Date: 2009-12-16 12:30:42 +0100 (Wed, 16 Dec 2009) New Revision: 4410 Modified: branches/2.0/varnish-cache/lib/libjemalloc/jemalloc_linux.c Log: Merge r4387: jemalloc portability fixes for sparc and s390 Modified: branches/2.0/varnish-cache/lib/libjemalloc/jemalloc_linux.c =================================================================== --- branches/2.0/varnish-cache/lib/libjemalloc/jemalloc_linux.c 2009-12-16 11:21:16 UTC (rev 4409) +++ branches/2.0/varnish-cache/lib/libjemalloc/jemalloc_linux.c 2009-12-16 11:30:42 UTC (rev 4410) @@ -243,7 +243,7 @@ # define SIZEOF_PTR_2POW 3 # define NO_TLS #endif -#ifdef __sparc64__ +#ifdef __sparc__ # define PAGESIZE_2POW 13 # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 3 @@ -272,6 +272,11 @@ # define QUANTUM_2POW 4 # define SIZEOF_PTR_2POW 2 #endif +#ifdef __s390x__ +# define PAGESIZE_2POW 12 +# define QUANTUM_2POW 4 +# define SIZEOF_PTR_2POW 3 +#endif #define QUANTUM ((size_t)(1U << QUANTUM_2POW)) #define QUANTUM_MASK (QUANTUM - 1) From phk at projects.linpro.no Wed Dec 16 11:41:36 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 12:41:36 +0100 (CET) Subject: r4411 - in trunk/varnish-cache: bin/varnishd include lib/libvcl Message-ID: <20091216114136.9D8411F7530@projects.linpro.no> Author: phk Date: 2009-12-16 12:41:36 +0100 (Wed, 16 Dec 2009) New Revision: 4411 Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c trunk/varnish-cache/bin/varnishd/cache_dir_simple.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_vrt.c trunk/varnish-cache/include/vrt.h trunk/varnish-cache/lib/libvcl/vcc_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c Log: Significantly objectify directors, and have non-simple directors call methods in they subservient directors rather than fondle backends directly. Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -68,6 +68,25 @@ "Host: %s", sp->vbe->backend->hosthdr); } +void +VBE_ReleaseConn(struct vbe_conn *vc) +{ + + CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); + assert(vc->backend == NULL); + assert(vc->fd < 0); + + if (params->cache_vbe_conns) { + Lck_Lock(&VBE_mtx); + VTAILQ_INSERT_HEAD(&vbe_conns, vc, list); + VSL_stats->backend_unused++; + Lck_Unlock(&VBE_mtx); + } else { + VSL_stats->n_vbe_conn--; + free(vc); + } +} + /*-------------------------------------------------------------------- * Attempt to connect to a given addrinfo entry. * @@ -113,6 +132,39 @@ return (s); } +/*--------------------------------------------------------------------*/ + +static int +bes_conn_try(const struct sess *sp, struct backend *bp) +{ + int s; + + Lck_Lock(&bp->mtx); + bp->refcount++; + bp->n_conn++; /* It mostly works */ + Lck_Unlock(&bp->mtx); + + s = -1; + assert(bp->ipv6 != NULL || bp->ipv4 != NULL); + + /* release lock during stuff that can take a long time */ + + if (params->prefer_ipv6 && bp->ipv6 != NULL) + s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); + if (s == -1 && bp->ipv4 != NULL) + s = VBE_TryConnect(sp, PF_INET, bp->ipv4, bp->ipv4len, bp); + if (s == -1 && !params->prefer_ipv6 && bp->ipv6 != NULL) + s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); + + if (s < 0) { + Lck_Lock(&bp->mtx); + bp->n_conn--; + bp->refcount--; /* Only keep ref on success */ + Lck_Unlock(&bp->mtx); + } + return (s); +} + /*-------------------------------------------------------------------- * Check that there is still something at the far end of a given socket. * We poll the fd with instant timeout, if there are any events we can't @@ -161,75 +213,8 @@ return (vc); } -void -VBE_ReleaseConn(struct vbe_conn *vc) -{ - CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); - assert(vc->backend == NULL); - assert(vc->fd < 0); - - if (params->cache_vbe_conns) { - Lck_Lock(&VBE_mtx); - VTAILQ_INSERT_HEAD(&vbe_conns, vc, list); - VSL_stats->backend_unused++; - Lck_Unlock(&VBE_mtx); - } else { - VSL_stats->n_vbe_conn--; - free(vc); - } -} - -/*--------------------------------------------------------------------*/ - -static int -bes_conn_try(const struct sess *sp, struct backend *bp) -{ - int s; - - Lck_Lock(&bp->mtx); - bp->refcount++; - bp->n_conn++; /* It mostly works */ - Lck_Unlock(&bp->mtx); - - s = -1; - assert(bp->ipv6 != NULL || bp->ipv4 != NULL); - - /* release lock during stuff that can take a long time */ - - if (params->prefer_ipv6 && bp->ipv6 != NULL) - s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); - if (s == -1 && bp->ipv4 != NULL) - s = VBE_TryConnect(sp, PF_INET, bp->ipv4, bp->ipv4len, bp); - if (s == -1 && !params->prefer_ipv6 && bp->ipv6 != NULL) - s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); - - if (s < 0) { - Lck_Lock(&bp->mtx); - bp->n_conn--; - bp->refcount--; /* Only keep ref on success */ - Lck_Unlock(&bp->mtx); - } - return (s); -} - /*-------------------------------------------------------------------- - * Get a connection to whatever backend the director think this session - * should contact. - */ - -void -VBE_GetFd(struct sess *sp) -{ - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - - AN (sp->director->getfd); - sp->vbe = sp->director->getfd(sp); -} - -/*-------------------------------------------------------------------- * It evaluates if a backend is healthy _for_a_specific_object_. * That means that it relies on sp->objhead. This is mainly for saint-mode, * but also takes backend->healthy into account. If @@ -366,6 +351,21 @@ return (vc); } +/*-------------------------------------------------------------------- + * Get a connection to whatever backend the director think this session + * should contact. + */ + +void +VBE_GetFd(struct sess *sp) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); + + AN (sp->director->getfd); + sp->vbe = sp->director->getfd(sp->director, sp); +} /* Close a connection ------------------------------------------------*/ void Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 11:41:36 UTC (rev 4411) @@ -77,9 +77,9 @@ * backends to use. */ -typedef struct vbe_conn *vdi_getfd_f(struct sess *sp); -typedef void vdi_fini_f(struct director *d); -typedef unsigned vdi_healthy(const struct sess *sp); +typedef struct vbe_conn *vdi_getfd_f(struct director *, struct sess *sp); +typedef void vdi_fini_f(struct director *); +typedef unsigned vdi_healthy(struct director *, const struct sess *sp); struct director { unsigned magic; @@ -92,6 +92,24 @@ void *priv; }; +static inline struct vbe_conn * +dir_getfd(struct director *d, struct sess *sp) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + return (d->getfd(d, sp)); +} + +static inline int +dir_healthy(struct director *d, const struct sess *sp) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + return (d->healthy(d, sp)); +} + /*-------------------------------------------------------------------- * List of objectheads that have recently been rejected by VCL. */ @@ -157,12 +175,6 @@ /* Init functions for directors */ -struct vrt_backend; -void VRT_init_dir_simple(struct cli *, struct director **, - const struct vrt_backend *); -struct vrt_dir_random; -void VRT_init_dir_random(struct cli *, struct director **, - const struct vrt_dir_random *); -struct vrt_dir_round_robin; -void VRT_init_dir_round_robin(struct cli *, struct director **, - const struct vrt_dir_round_robin *); +void VRT_init_dir_simple(struct cli *, struct director **, int , const void*); +void VRT_init_dir_random(struct cli *, struct director **, int , const void*); +void VRT_init_dir_round_robin(struct cli *, struct director **, int , const void*); Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -50,7 +50,7 @@ /*--------------------------------------------------------------------*/ struct vdi_random_host { - struct backend *backend; + struct director *backend; double weight; }; @@ -65,24 +65,27 @@ }; static struct vbe_conn * -vdi_random_getfd(struct sess *sp) +vdi_random_getfd(struct director *d, struct sess *sp) { int i, k; struct vdi_random *vs; double r, s1; struct vbe_conn *vbe; + struct director *d2; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_RANDOM_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); for (k = 0; k < vs->retries; ) { /* Sum up the weights of healty backends */ s1 = 0.0; - for (i = 0; i < vs->nhosts; i++) - if (VBE_Healthy(sp,vs->hosts[i].backend)) + for (i = 0; i < vs->nhosts; i++) { + d2 = vs->hosts[i].backend; + if (d2->healthy(d2, sp)) s1 += vs->hosts[i].weight; + } if (s1 == 0.0) return (NULL); @@ -94,12 +97,13 @@ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) { - if (!VBE_Healthy(sp, vs->hosts[i].backend)) + d2 = vs->hosts[i].backend; + if (!d2->healthy(d2, sp)) continue; s1 += vs->hosts[i].weight; if (r >= s1) continue; - vbe = VBE_GetVbe(sp, vs->hosts[i].backend); + vbe = d2->getfd(d2, sp); if (vbe != NULL) return (vbe); break; @@ -110,17 +114,19 @@ } static unsigned -vdi_random_healthy(const struct sess *sp) +vdi_random_healthy(struct director *d, const struct sess *sp) { struct vdi_random *vs; int i; + struct director *d2; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_RANDOM_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); for (i = 0; i < vs->nhosts; i++) { - if (VBE_Healthy(sp,vs->hosts[i].backend)) + d2 = vs->hosts[i].backend; + if (d2->healthy(d2, sp)) return 1; } return 0; @@ -130,7 +136,7 @@ static void vdi_random_fini(struct director *d) { - int i; + // int i; struct vdi_random *vs; struct vdi_random_host *vh; @@ -138,8 +144,10 @@ CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); vh = vs->hosts; +#if 0 /* XXX */ for (i = 0; i < vs->nhosts; i++, vh++) VBE_DropRef(vh->backend); +#endif free(vs->hosts); free(vs->dir.vcl_name); vs->dir.magic = 0; @@ -147,15 +155,18 @@ } void -VRT_init_dir_random(struct cli *cli, struct director **bp, - const struct vrt_dir_random *t) +VRT_init_dir_random(struct cli *cli, struct director **bp, int idx, + const void *priv) { + const struct vrt_dir_random *t; struct vdi_random *vs; const struct vrt_dir_random_entry *te; struct vdi_random_host *vh; int i; + ASSERT_CLI(); (void)cli; + t = priv; ALLOC_OBJ(vs, VDI_RANDOM_MAGIC); XXXAN(vs); @@ -178,8 +189,9 @@ for (i = 0; i < t->nmember; i++, vh++, te++) { assert(te->weight > 0.0); vh->weight = te->weight; - vh->backend = VBE_AddBackend(cli, te->host); + vh->backend = bp[te->host]; + AN(vh->backend); } vs->nhosts = t->nmember; - *bp = &vs->dir; + bp[idx] = &vs->dir; } Modified: trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -48,7 +48,7 @@ /*--------------------------------------------------------------------*/ struct vdi_round_robin_host { - struct backend *backend; + struct director *backend; }; struct vdi_round_robin { @@ -61,23 +61,23 @@ }; static struct vbe_conn * -vdi_round_robin_getfd(struct sess *sp) +vdi_round_robin_getfd(struct director *d, struct sess *sp) { int i; struct vdi_round_robin *vs; - struct backend *backend; + struct director *backend; struct vbe_conn *vbe; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_ROUND_ROBIN_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC); for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[vs->next_host].backend; vs->next_host = (vs->next_host + 1) % vs->nhosts; - if (!VBE_Healthy(sp, backend)) + if (!backend->healthy(backend, sp)) continue; - vbe = VBE_GetVbe(sp, backend); + vbe = backend->getfd(backend, sp); if (vbe != NULL) return (vbe); } @@ -86,17 +86,19 @@ } static unsigned -vdi_round_robin_healthy(const struct sess *sp) +vdi_round_robin_healthy(struct director *d, const struct sess *sp) { struct vdi_round_robin *vs; + struct director *backend; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_ROUND_ROBIN_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC); for (i = 0; i < vs->nhosts; i++) { - if (VBE_Healthy(sp, vs->hosts[i].backend)) + backend = vs->hosts[i].backend; + if (backend->healthy(backend, sp)) return 1; } return 0; @@ -106,7 +108,7 @@ static void vdi_round_robin_fini(struct director *d) { - int i; + // int i; struct vdi_round_robin *vs; struct vdi_round_robin_host *vh; @@ -114,8 +116,10 @@ CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC); vh = vs->hosts; +#if 0 /* XXX */ for (i = 0; i < vs->nhosts; i++, vh++) VBE_DropRef(vh->backend); +#endif free(vs->hosts); free(vs->dir.vcl_name); vs->dir.magic = 0; @@ -124,15 +128,18 @@ } void -VRT_init_dir_round_robin(struct cli *cli, struct director **bp, - const struct vrt_dir_round_robin *t) +VRT_init_dir_round_robin(struct cli *cli, struct director **bp, int idx, + const void *priv) { + const struct vrt_dir_round_robin *t; struct vdi_round_robin *vs; const struct vrt_dir_round_robin_entry *te; struct vdi_round_robin_host *vh; int i; + ASSERT_CLI(); (void)cli; + t = priv; ALLOC_OBJ(vs, VDI_ROUND_ROBIN_MAGIC); XXXAN(vs); @@ -149,10 +156,12 @@ vh = vs->hosts; te = t->members; - for (i = 0; i < t->nmember; i++, vh++, te++) - vh->backend = VBE_AddBackend(cli, te->host); + for (i = 0; i < t->nmember; i++, vh++, te++) { + vh->backend = bp[te->host]; + AN (vh->backend); + } vs->nhosts = t->nmember; vs->next_host = 0; - *bp = &vs->dir; + bp[idx] = &vs->dir; } Modified: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -41,6 +41,7 @@ #include #include #include +#include #include "shmlog.h" #include "cache.h" @@ -57,24 +58,24 @@ }; static struct vbe_conn * -vdi_simple_getfd(struct sess *sp) +vdi_simple_getfd(struct director *d, struct sess *sp) { struct vdi_simple *vs; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_SIMPLE_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); return (VBE_GetVbe(sp, vs->backend)); } static unsigned -vdi_simple_healthy(const struct sess *sp) +vdi_simple_healthy(struct director *d, const struct sess *sp) { struct vdi_simple *vs; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, sp->director->priv, VDI_SIMPLE_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); return (VBE_Healthy(sp, vs->backend)); } @@ -94,12 +95,15 @@ } void -VRT_init_dir_simple(struct cli *cli, struct director **bp, - const struct vrt_backend *t) +VRT_init_dir_simple(struct cli *cli, struct director **bp, int idx, + const void *priv) { + const struct vrt_backend *t; struct vdi_simple *vs; + ASSERT_CLI(); (void)cli; + t = priv; ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC); XXXAN(vs); @@ -113,5 +117,5 @@ vs->backend = VBE_AddBackend(cli, t); - *bp = &vs->dir; + bp[idx] = &vs->dir; } Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -408,7 +408,7 @@ */ sp->objhead = oh; if (oc == NULL && grace_oc != NULL && - (busy_oc != NULL || !sp->director->healthy(sp))) { + (busy_oc != NULL || !sp->director->healthy(sp->director, sp))) { o = grace_oc->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->ttl + HSH_Grace(sp->grace) >= sp->t_req) Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -782,7 +782,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - return (sp->director->healthy(sp)); + return (sp->director->healthy(sp->director, sp)); } /*--------------------------------------------------------------------*/ @@ -855,12 +855,13 @@ int idx, const void *priv) { + ASSERT_CLI(); if (!strcmp(name, "simple")) - VRT_init_dir_simple(cli, dir + idx, priv); + VRT_init_dir_simple(cli, dir, idx, priv); else if (!strcmp(name, "random")) - VRT_init_dir_random(cli, dir + idx, priv); + VRT_init_dir_random(cli, dir, idx, priv); else if (!strcmp(name, "round-robin")) - VRT_init_dir_round_robin(cli, dir + idx, priv); + VRT_init_dir_round_robin(cli, dir, idx, priv); else INCOMPL(); } Modified: trunk/varnish-cache/include/vrt.h =================================================================== --- trunk/varnish-cache/include/vrt.h 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/include/vrt.h 2009-12-16 11:41:36 UTC (rev 4411) @@ -83,7 +83,7 @@ */ struct vrt_dir_random_entry { - const struct vrt_backend *host; + int host; double weight; }; @@ -99,7 +99,7 @@ */ struct vrt_dir_round_robin_entry { - const struct vrt_backend *host; + int host; }; struct vrt_dir_round_robin { Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -99,7 +99,7 @@ vcc_ParseBackendHost(tl, nelem, &p); ERRCHK(tl); AN(p); - Fc(tl, 0, "%s .host = &vgc_dir_priv_%s", + Fc(tl, 0, "%s .host = VGC_backend_%s", first, p); } else if (vcc_IdIs(t_field, "weight")) { ExpectErr(tl, CNUM); Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -78,7 +78,7 @@ vcc_ParseBackendHost(tl, nelem, &p); ERRCHK(tl); AN(p); - Fc(tl, 0, "%s .host = &vgc_dir_priv_%s", + Fc(tl, 0, "%s .host = VGC_backend_%s", first, p); } else { ErrInternal(tl); Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-16 11:30:42 UTC (rev 4410) +++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2009-12-16 11:41:36 UTC (rev 4411) @@ -227,8 +227,8 @@ vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI"); vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT"); vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"); - vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4391 2009-12-14 12:"); - vsb_cat(sb, "10:15Z phk $\n *\n * Runtime support for compiled VCL "); + vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4405 2009-12-16 10:"); + vsb_cat(sb, "45:39Z phk $\n *\n * Runtime support for compiled VCL "); vsb_cat(sb, "programs.\n *\n * XXX: When this file is changed, lib/"); vsb_cat(sb, "libvcl/vcc_gen_fixed_token.tcl\n"); vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n"); @@ -255,19 +255,19 @@ vsb_cat(sb, "\tstruct vrt_backend_probe\tprobe;\n"); vsb_cat(sb, "};\n\n/*\n * A director with an unpredictable reply\n"); vsb_cat(sb, " */\n\nstruct vrt_dir_random_entry {\n"); - vsb_cat(sb, "\tconst struct vrt_backend\t\t*host;\n"); - vsb_cat(sb, "\tdouble\t\t\t\t\tweight;\n};\n"); - vsb_cat(sb, "\nstruct vrt_dir_random {\n\tconst char\t\t\t\t*name;\n"); - vsb_cat(sb, "\tunsigned\t\t\t\tretries;\n\tunsigned\t\t\t\tnmember;"); - vsb_cat(sb, "\n\tconst struct vrt_dir_random_entry\t*members;\n"); - vsb_cat(sb, "};\n\n/*\n * A director with round robin selection\n"); + vsb_cat(sb, "\tint\t\t\t\t\thost;\n\tdouble\t\t\t\t\tweight;\n"); + vsb_cat(sb, "};\n\nstruct vrt_dir_random {\n"); + vsb_cat(sb, "\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tretries;"); + vsb_cat(sb, "\n\tunsigned\t\t\t\tnmember;\n\tconst struct vrt_dir_r"); + vsb_cat(sb, "andom_entry\t*members;\n};\n\n/*\n"); + vsb_cat(sb, " * A director with round robin selection\n"); vsb_cat(sb, " */\n\nstruct vrt_dir_round_robin_entry {\n"); - vsb_cat(sb, "\tconst struct vrt_backend\t\t*host;\n"); - vsb_cat(sb, "};\n\nstruct vrt_dir_round_robin {\n"); - vsb_cat(sb, "\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tnmember;"); - vsb_cat(sb, "\n\tconst struct vrt_dir_round_robin_entry\t*members;\n"); - vsb_cat(sb, "};\n\n\n/*\n * other stuff.\n * XXX: document when bor"); - vsb_cat(sb, "ed\n */\n\nstruct vrt_ref {\n\tunsigned\tsource;\n"); + vsb_cat(sb, "\tint\t\t\t\t\thost;\n};\n\nstruct vrt_dir_round_robin"); + vsb_cat(sb, " {\n\tconst char\t\t\t\t*name;\n"); + vsb_cat(sb, "\tunsigned\t\t\t\tnmember;\n\tconst struct vrt_dir_rou"); + vsb_cat(sb, "nd_robin_entry\t*members;\n};\n"); + vsb_cat(sb, "\n\n/*\n * other stuff.\n * XXX: document when bored\n"); + vsb_cat(sb, " */\n\nstruct vrt_ref {\n\tunsigned\tsource;\n"); vsb_cat(sb, "\tunsigned\toffset;\n\tunsigned\tline;\n"); vsb_cat(sb, "\tunsigned\tpos;\n\tunsigned\tcount;\n"); vsb_cat(sb, "\tconst char\t*token;\n};\n\n/* ACL related */\n"); From tfheen at projects.linpro.no Wed Dec 16 11:51:19 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 12:51:19 +0100 (CET) Subject: r4412 - branches/2.0/varnish-cache/doc Message-ID: <20091216115119.0FB3F1F769E@projects.linpro.no> Author: tfheen Date: 2009-12-16 12:51:18 +0100 (Wed, 16 Dec 2009) New Revision: 4412 Added: branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml branches/2.0/varnish-cache/doc/changes-2.0.6.xml Modified: branches/2.0/varnish-cache/doc/Makefile.am Log: Add changes for 2.0.6 Modified: branches/2.0/varnish-cache/doc/Makefile.am =================================================================== --- branches/2.0/varnish-cache/doc/Makefile.am 2009-12-16 11:41:36 UTC (rev 4411) +++ branches/2.0/varnish-cache/doc/Makefile.am 2009-12-16 11:51:18 UTC (rev 4412) @@ -1,6 +1,7 @@ # $Id$ CHANGELOGS = \ + changes-2.0.6.html \ changes-2.0.5.html \ changes-2.0.4.html \ changes-2.0.3.html \ @@ -13,6 +14,7 @@ changes-1.0.4.html XML = \ + changes-2.0.5-2.0.6.xml \ changes-2.0.4-2.0.5.xml \ changes-2.0.3-2.0.4.xml \ changes-2.0.2-2.0.3.xml \ Added: branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml =================================================================== --- branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml (rev 0) +++ branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml 2009-12-16 11:51:18 UTC (rev 4412) @@ -0,0 +1,53 @@ + + +]> + + + + varnishd + + + 2.0.5 had an off-by-one error in the ESI handling causing + includes to fail a large part of the time. This has now been + fixed. + + + + Try harder to not confuse backends when sending them + backend probes. We half-closed the connection, something some + backends thought meant we had dropped the connection. Stop + doing so, and add the capability for specifying the expected + response code. + + + + In 2.0.5, session lingering was turned on. This caused + statistics to not be counted often enough in some cases. This + has now been fixed. + + + + Avoid triggering an assert if the other end closes the + connection while we are lingering and waiting for another + request from them. + + + + When generating backtraces, prefer the built-in backtrace + function if such exists. This fixes a problem compiling 2.0.5 + on Solaris. + + + + Make it possible to specify the per-thread stack size. + This might be useful on 32 bit systems with their limited + address space. + + + + Document the -C option + to varnishd. + + + Added: branches/2.0/varnish-cache/doc/changes-2.0.6.xml =================================================================== --- branches/2.0/varnish-cache/doc/changes-2.0.6.xml (rev 0) +++ branches/2.0/varnish-cache/doc/changes-2.0.6.xml 2009-12-16 11:51:18 UTC (rev 4412) @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 2.0.6 + + + From phk at projects.linpro.no Wed Dec 16 11:58:47 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 12:58:47 +0100 (CET) Subject: r4413 - trunk/varnish-cache/bin/varnishd Message-ID: <20091216115847.B24A31F7B11@projects.linpro.no> Author: phk Date: 2009-12-16 12:58:47 +0100 (Wed, 16 Dec 2009) New Revision: 4413 Removed: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c Modified: trunk/varnish-cache/bin/varnishd/Makefile.am trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Shuffle things around: Move the "simple" director into cache_backend.c, since it is what is really dealing with backends now that directors are objectified. Make a lot of stuff static as a result. Collect both the init and fini VRT functins for directors in cache_backend_cfg.c Modified: trunk/varnish-cache/bin/varnishd/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishd/Makefile.am 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/Makefile.am 2009-12-16 11:58:47 UTC (rev 4413) @@ -20,7 +20,6 @@ cache_cli.c \ cache_dir_random.c \ cache_dir_round_robin.c \ - cache_dir_simple.c \ cache_esi.c \ cache_expire.c \ cache_fetch.c \ Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 11:58:47 UTC (rev 4413) @@ -47,6 +47,7 @@ #include "shmlog.h" #include "cache.h" #include "cache_backend.h" +#include "vrt.h" /* * List of cached vbe_conns, used if enabled in params/heritage @@ -68,6 +69,7 @@ "Host: %s", sp->vbe->backend->hosthdr); } +/* Private interface from backend_cfg.c */ void VBE_ReleaseConn(struct vbe_conn *vc) { @@ -97,7 +99,7 @@ */ static int -VBE_TryConnect(const struct sess *sp, int pf, const struct sockaddr *sa, +vbe_TryConnect(const struct sess *sp, int pf, const struct sockaddr *sa, socklen_t salen, const struct backend *bp) { int s, i, tmo; @@ -150,11 +152,11 @@ /* release lock during stuff that can take a long time */ if (params->prefer_ipv6 && bp->ipv6 != NULL) - s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); + s = vbe_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); if (s == -1 && bp->ipv4 != NULL) - s = VBE_TryConnect(sp, PF_INET, bp->ipv4, bp->ipv4len, bp); + s = vbe_TryConnect(sp, PF_INET, bp->ipv4, bp->ipv4len, bp); if (s == -1 && !params->prefer_ipv6 && bp->ipv6 != NULL) - s = VBE_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); + s = vbe_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, bp); if (s < 0) { Lck_Lock(&bp->mtx); @@ -172,7 +174,7 @@ */ static int -VBE_CheckFd(int fd) +vbe_CheckFd(int fd) { struct pollfd pfd; @@ -189,7 +191,7 @@ */ static struct vbe_conn * -VBE_NewConn(void) +vbe_NewConn(void) { struct vbe_conn *vc; @@ -225,8 +227,8 @@ * items would never time out once the threshold is reached. */ -unsigned int -VBE_Healthy(const struct sess *sp, struct backend *backend) +static unsigned int +vbe_Healthy(const struct sess *sp, struct backend *backend) { struct trouble *tr; struct trouble *tr2; @@ -292,8 +294,8 @@ * Get a connection to a particular backend. */ -struct vbe_conn * -VBE_GetVbe(struct sess *sp, struct backend *bp) +static struct vbe_conn * +vbe_GetVbe(struct sess *sp, struct backend *bp) { struct vbe_conn *vc; @@ -313,7 +315,7 @@ Lck_Unlock(&bp->mtx); if (vc == NULL) break; - if (VBE_CheckFd(vc->fd)) { + if (vbe_CheckFd(vc->fd)) { /* XXX locking of stats */ VSL_stats->backend_reuse += 1; WSP(sp, SLT_Backend, "%d %s %s", @@ -325,7 +327,7 @@ VBE_ClosedFd(sp); } - if (!VBE_Healthy(sp, bp)) { + if (!vbe_Healthy(sp, bp)) { VSL_stats->backend_unhealthy++; return (NULL); } @@ -335,7 +337,7 @@ return (NULL); } - vc = VBE_NewConn(); + vc = vbe_NewConn(); assert(vc->fd == -1); AZ(vc->backend); vc->fd = bes_conn_try(sp, bp); @@ -407,3 +409,80 @@ sp->vbe = NULL; VBE_DropRefLocked(bp); } + + +/*-------------------------------------------------------------------- + * The "simple" director really isn't, since thats where all the actual + * connections happen. Nontheless, pretend it is simple by sequestering + * the directoricity of it under this line. + */ + +struct vdi_simple { + unsigned magic; +#define VDI_SIMPLE_MAGIC 0x476d25b7 + struct director dir; + struct backend *backend; +}; + +static struct vbe_conn * +vdi_simple_getfd(struct director *d, struct sess *sp) +{ + struct vdi_simple *vs; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + return (vbe_GetVbe(sp, vs->backend)); +} + +static unsigned +vdi_simple_healthy(struct director *d, const struct sess *sp) +{ + struct vdi_simple *vs; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + return (vbe_Healthy(sp, vs->backend)); +} + +/*lint -e{818} not const-able */ +static void +vdi_simple_fini(struct director *d) +{ + struct vdi_simple *vs; + + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + + VBE_DropRef(vs->backend); + free(vs->dir.vcl_name); + vs->dir.magic = 0; + FREE_OBJ(vs); +} + +void +VRT_init_dir_simple(struct cli *cli, struct director **bp, int idx, + const void *priv) +{ + const struct vrt_backend *t; + struct vdi_simple *vs; + + ASSERT_CLI(); + (void)cli; + t = priv; + + ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC); + XXXAN(vs); + vs->dir.magic = DIRECTOR_MAGIC; + vs->dir.priv = vs; + vs->dir.name = "simple"; + REPLACE(vs->dir.vcl_name, t->vcl_name); + vs->dir.getfd = vdi_simple_getfd; + vs->dir.fini = vdi_simple_fini; + vs->dir.healthy = vdi_simple_healthy; + + vs->backend = VBE_AddBackend(cli, t); + + bp[idx] = &vs->dir; +} Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 11:58:47 UTC (rev 4413) @@ -160,8 +160,6 @@ /* cache_backend.c */ void VBE_ReleaseConn(struct vbe_conn *vc); -struct vbe_conn *VBE_GetVbe(struct sess *sp, struct backend *bp); -unsigned int VBE_Healthy(const struct sess *sp, struct backend *backend); /* cache_backend_cfg.c */ extern struct lock VBE_mtx; Modified: trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c 2009-12-16 11:58:47 UTC (rev 4413) @@ -262,6 +262,22 @@ /*--------------------------------------------------------------------*/ void +VRT_init_dir(struct cli *cli, struct director **dir, const char *name, + int idx, const void *priv) +{ + + ASSERT_CLI(); + if (!strcmp(name, "simple")) + VRT_init_dir_simple(cli, dir, idx, priv); + else if (!strcmp(name, "random")) + VRT_init_dir_random(cli, dir, idx, priv); + else if (!strcmp(name, "round-robin")) + VRT_init_dir_round_robin(cli, dir, idx, priv); + else + INCOMPL(); +} + +void VRT_fini_dir(struct cli *cli, struct director *b) { Deleted: trunk/varnish-cache/bin/varnishd/cache_dir_simple.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/cache_dir_simple.c 2009-12-16 11:58:47 UTC (rev 4413) @@ -1,121 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Poul-Henning Kamp - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#include "config.h" - -#include "svnid.h" -SVNID("$Id$") - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "shmlog.h" -#include "cache.h" -#include "cache_backend.h" -#include "vrt.h" - -/*--------------------------------------------------------------------*/ - -struct vdi_simple { - unsigned magic; -#define VDI_SIMPLE_MAGIC 0x476d25b7 - struct director dir; - struct backend *backend; -}; - -static struct vbe_conn * -vdi_simple_getfd(struct director *d, struct sess *sp) -{ - struct vdi_simple *vs; - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - return (VBE_GetVbe(sp, vs->backend)); -} - -static unsigned -vdi_simple_healthy(struct director *d, const struct sess *sp) -{ - struct vdi_simple *vs; - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - return (VBE_Healthy(sp, vs->backend)); -} - -/*lint -e{818} not const-able */ -static void -vdi_simple_fini(struct director *d) -{ - struct vdi_simple *vs; - - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - - VBE_DropRef(vs->backend); - free(vs->dir.vcl_name); - vs->dir.magic = 0; - FREE_OBJ(vs); -} - -void -VRT_init_dir_simple(struct cli *cli, struct director **bp, int idx, - const void *priv) -{ - const struct vrt_backend *t; - struct vdi_simple *vs; - - ASSERT_CLI(); - (void)cli; - t = priv; - - ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC); - XXXAN(vs); - vs->dir.magic = DIRECTOR_MAGIC; - vs->dir.priv = vs; - vs->dir.name = "simple"; - REPLACE(vs->dir.vcl_name, t->vcl_name); - vs->dir.getfd = vdi_simple_getfd; - vs->dir.fini = vdi_simple_fini; - vs->dir.healthy = vdi_simple_healthy; - - vs->backend = VBE_AddBackend(cli, t); - - bp[idx] = &vs->dir; -} Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 11:51:18 UTC (rev 4412) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 11:58:47 UTC (rev 4413) @@ -850,25 +850,7 @@ } /*--------------------------------------------------------------------*/ -void -VRT_init_dir(struct cli *cli, struct director **dir, const char *name, - int idx, const void *priv) -{ - ASSERT_CLI(); - if (!strcmp(name, "simple")) - VRT_init_dir_simple(cli, dir, idx, priv); - else if (!strcmp(name, "random")) - VRT_init_dir_random(cli, dir, idx, priv); - else if (!strcmp(name, "round-robin")) - VRT_init_dir_round_robin(cli, dir, idx, priv); - else - INCOMPL(); -} - - -/*--------------------------------------------------------------------*/ - void VRT_Rollback(struct sess *sp) { From phk at projects.linpro.no Wed Dec 16 12:28:47 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 13:28:47 +0100 (CET) Subject: r4414 - trunk/varnish-cache/bin/varnishd Message-ID: <20091216122847.B97A81F7530@projects.linpro.no> Author: phk Date: 2009-12-16 13:28:47 +0100 (Wed, 16 Dec 2009) New Revision: 4414 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_backend.c trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_pipe.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Polish pass: Add wrapped methods for ->getfd and ->healthy. Remove the backend deref code that is no longer needed by random/round-robin directors, since they only reference other directors in the same VCL. Stop messing with sp->vbe behind the back, make the assignment explicit where it matters. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache.h 2009-12-16 12:28:47 UTC (rev 4414) @@ -451,7 +451,8 @@ /* cache_backend.c */ -void VBE_GetFd(struct sess *sp); +struct vbe_conn *VBE_GetFd(struct director *, struct sess *sp); +int VBE_Healthy(struct director *, const struct sess *sp); void VBE_ClosedFd(struct sess *sp); void VBE_RecycleFd(struct sess *sp); void VBE_AddHostHeader(const struct sess *sp); Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -353,21 +353,6 @@ return (vc); } -/*-------------------------------------------------------------------- - * Get a connection to whatever backend the director think this session - * should contact. - */ - -void -VBE_GetFd(struct sess *sp) -{ - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - - AN (sp->director->getfd); - sp->vbe = sp->director->getfd(sp->director, sp); -} /* Close a connection ------------------------------------------------*/ void @@ -410,7 +395,32 @@ VBE_DropRefLocked(bp); } +/* Get a connection --------------------------------------------------*/ +struct vbe_conn * +VBE_GetFd(struct director *d, struct sess *sp) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (d == NULL) + d = sp->director; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + return (d->getfd(d, sp)); +} + +/* Cheack health -----------------------------------------------------*/ + +int +VBE_Healthy(struct director *d, const struct sess *sp) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (d == NULL) + d = sp->director; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + return (d->healthy(d, sp)); +} + /*-------------------------------------------------------------------- * The "simple" director really isn't, since thats where all the actual * connections happen. Nontheless, pretend it is simple by sequestering Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 12:28:47 UTC (rev 4414) @@ -92,24 +92,6 @@ void *priv; }; -static inline struct vbe_conn * -dir_getfd(struct director *d, struct sess *sp) -{ - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->getfd(d, sp)); -} - -static inline int -dir_healthy(struct director *d, const struct sess *sp) -{ - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->healthy(d, sp)); -} - /*-------------------------------------------------------------------- * List of objectheads that have recently been rejected by VCL. */ Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -83,7 +83,8 @@ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) { d2 = vs->hosts[i].backend; - if (d2->healthy(d2, sp)) + /* XXX: cache result of healty to avoid double work */ + if (VBE_Healthy(d2, sp)) s1 += vs->hosts[i].weight; } @@ -98,12 +99,12 @@ s1 = 0.0; for (i = 0; i < vs->nhosts; i++) { d2 = vs->hosts[i].backend; - if (!d2->healthy(d2, sp)) + if (!VBE_Healthy(d2, sp)) continue; s1 += vs->hosts[i].weight; if (r >= s1) continue; - vbe = d2->getfd(d2, sp); + vbe = VBE_GetFd(d2, sp); if (vbe != NULL) return (vbe); break; @@ -126,7 +127,7 @@ for (i = 0; i < vs->nhosts; i++) { d2 = vs->hosts[i].backend; - if (d2->healthy(d2, sp)) + if (VBE_Healthy(d2, sp)) return 1; } return 0; @@ -136,18 +137,11 @@ static void vdi_random_fini(struct director *d) { - // int i; struct vdi_random *vs; - struct vdi_random_host *vh; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); - vh = vs->hosts; -#if 0 /* XXX */ - for (i = 0; i < vs->nhosts; i++, vh++) - VBE_DropRef(vh->backend); -#endif free(vs->hosts); free(vs->dir.vcl_name); vs->dir.magic = 0; Modified: trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_dir_round_robin.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -75,9 +75,9 @@ for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[vs->next_host].backend; vs->next_host = (vs->next_host + 1) % vs->nhosts; - if (!backend->healthy(backend, sp)) + if (!VBE_Healthy(backend, sp)) continue; - vbe = backend->getfd(backend, sp); + vbe = VBE_GetFd(backend, sp); if (vbe != NULL) return (vbe); } @@ -98,7 +98,7 @@ for (i = 0; i < vs->nhosts; i++) { backend = vs->hosts[i].backend; - if (backend->healthy(backend, sp)) + if (VBE_Healthy(backend, sp)) return 1; } return 0; @@ -108,18 +108,11 @@ static void vdi_round_robin_fini(struct director *d) { - // int i; struct vdi_round_robin *vs; - struct vdi_round_robin_host *vh; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC); - vh = vs->hosts; -#if 0 /* XXX */ - for (i = 0; i < vs->nhosts; i++, vh++) - VBE_DropRef(vh->backend); -#endif free(vs->hosts); free(vs->dir.vcl_name); vs->dir.magic = 0; Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -351,7 +351,7 @@ w = sp->wrk; hp = sp->wrk->bereq; - VBE_GetFd(sp); + sp->vbe = VBE_GetFd(NULL, sp); if (sp->vbe == NULL) { WSP(sp, SLT_FetchError, "no backend connection"); return (__LINE__); Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -408,7 +408,7 @@ */ sp->objhead = oh; if (oc == NULL && grace_oc != NULL && - (busy_oc != NULL || !sp->director->healthy(sp->director, sp))) { + (busy_oc != NULL || !VBE_Healthy(NULL, sp))) { o = grace_oc->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->ttl + HSH_Grace(sp->grace) >= sp->t_req) Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -75,7 +75,7 @@ CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); w = sp->wrk; - VBE_GetFd(sp); + sp->vbe = VBE_GetFd(NULL, sp); if (sp->vbe == NULL) return; vc = sp->vbe; Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 11:58:47 UTC (rev 4413) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2009-12-16 12:28:47 UTC (rev 4414) @@ -782,7 +782,7 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); - return (sp->director->healthy(sp->director, sp)); + return (VBE_Healthy(NULL, sp)); } /*--------------------------------------------------------------------*/ From tfheen at projects.linpro.no Wed Dec 16 12:31:58 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 13:31:58 +0100 (CET) Subject: r4415 - branches/2.0/varnish-cache Message-ID: <20091216123158.17D951F7530@projects.linpro.no> Author: tfheen Date: 2009-12-16 13:31:57 +0100 (Wed, 16 Dec 2009) New Revision: 4415 Modified: branches/2.0/varnish-cache/configure.ac Log: Bump version number in configure.ac to 2.0.6 Modified: branches/2.0/varnish-cache/configure.ac =================================================================== --- branches/2.0/varnish-cache/configure.ac 2009-12-16 12:28:47 UTC (rev 4414) +++ branches/2.0/varnish-cache/configure.ac 2009-12-16 12:31:57 UTC (rev 4415) @@ -1,9 +1,9 @@ # $Id$ AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS]) +AC_COPYRIGHT([Copyright (c) 2006-2009 Linpro AS / Verdens Gang AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [2.0.5], [varnish-dev at projects.linpro.no]) +AC_INIT([Varnish], [2.0.6], [varnish-dev at projects.linpro.no]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) From phk at projects.linpro.no Wed Dec 16 13:02:42 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 14:02:42 +0100 (CET) Subject: r4416 - trunk/varnish-cache/bin/varnishd Message-ID: <20091216130242.BC8381F7530@projects.linpro.no> Author: phk Date: 2009-12-16 14:02:42 +0100 (Wed, 16 Dec 2009) New Revision: 4416 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/hash_slinger.h Log: Put the hash-digest into struct sess, let HSH_Lookup grab it from there. Saves some pointless calling forth and back and makes the hash available for other uses. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2009-12-16 12:31:57 UTC (rev 4415) +++ trunk/varnish-cache/bin/varnishd/cache.h 2009-12-16 13:02:42 UTC (rev 4416) @@ -100,6 +100,9 @@ struct lock { void *priv; }; // Opaque +#define DIGEST_LEN 32 + + /*--------------------------------------------------------------------*/ typedef struct { @@ -383,6 +386,8 @@ char *ws_ses; /* WS above session data */ char *ws_req; /* WS above request data */ + unsigned char digest[DIGEST_LEN]; + struct http_conn htc[1]; /* Timestamps, all on TIM_real() timescale */ Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2009-12-16 12:31:57 UTC (rev 4415) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2009-12-16 13:02:42 UTC (rev 4416) @@ -78,6 +78,7 @@ #include "cache.h" #include "hash_slinger.h" #include "stevedore.h" +#include "vsha256.h" static unsigned xids; @@ -1034,10 +1035,10 @@ return (0); } - HSH_BeforeVclHash(sp); + SHA256_Init(sp->wrk->sha256ctx); VCL_hash_method(sp); assert(sp->handling == VCL_RET_HASH); - HSH_AfterVclHash(sp); + SHA256_Final(sp->digest, sp->wrk->sha256ctx); if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) { sp->wantbody = 0; Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 12:31:57 UTC (rev 4415) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-12-16 13:02:42 UTC (rev 4416) @@ -172,21 +172,6 @@ } void -HSH_BeforeVclHash(const struct sess *sp) -{ - - SHA256_Init(sp->wrk->sha256ctx); -} - -void -HSH_AfterVclHash(const struct sess *sp) -{ - - HSH_Prealloc(sp); - SHA256_Final(sp->wrk->nobjhead->digest, sp->wrk->sha256ctx); -} - -void HSH_AddString(const struct sess *sp, const char *str) { int l; @@ -339,6 +324,7 @@ w = sp->wrk; HSH_Prealloc(sp); + memcpy(sp->wrk->nobjhead->digest, sp->digest, sizeof sp->digest); if (params->diag_bitmap & 0x80000000) hsh_testmagic(sp->wrk->nobjhead->digest); Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h =================================================================== --- trunk/varnish-cache/bin/varnishd/hash_slinger.h 2009-12-16 12:31:57 UTC (rev 4415) +++ trunk/varnish-cache/bin/varnishd/hash_slinger.h 2009-12-16 13:02:42 UTC (rev 4416) @@ -61,16 +61,12 @@ double HSH_Grace(double g); void HSH_Init(void); void HSH_AddString(const struct sess *sp, const char *str); -void HSH_BeforeVclHash(const struct sess *sp); -void HSH_AfterVclHash(const struct sess *sp); void HSH_DerefObjCore(struct sess *sp); void HSH_FindBan(struct sess *sp, struct objcore **oc); struct objcore *HSH_Insert(const struct sess *sp); #ifdef VARNISH_CACHE_CHILD -#define DIGEST_LEN 32 - struct objhead { unsigned magic; #define OBJHEAD_MAGIC 0x1b96615d From tfheen at projects.linpro.no Wed Dec 16 13:54:57 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 14:54:57 +0100 (CET) Subject: r4417 - tags Message-ID: <20091216135457.EBDF11F76F2@projects.linpro.no> Author: tfheen Date: 2009-12-16 14:54:57 +0100 (Wed, 16 Dec 2009) New Revision: 4417 Added: tags/varnish-2.0.6/ Log: Tag 2.0.6 Copied: tags/varnish-2.0.6 (from rev 4416, branches/2.0) From tfheen at projects.linpro.no Wed Dec 16 14:31:27 2009 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 16 Dec 2009 15:31:27 +0100 (CET) Subject: r4418 - branches/2.0/varnish-cache/doc Message-ID: <20091216143127.52D401F769E@projects.linpro.no> Author: tfheen Date: 2009-12-16 15:31:27 +0100 (Wed, 16 Dec 2009) New Revision: 4418 Modified: branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml Log: Add missing / Modified: branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml =================================================================== --- branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml 2009-12-16 13:54:57 UTC (rev 4417) +++ branches/2.0/varnish-cache/doc/changes-2.0.5-2.0.6.xml 2009-12-16 14:31:27 UTC (rev 4418) @@ -49,5 +49,5 @@ Document the -C option to varnishd. - + From phk at projects.linpro.no Wed Dec 16 15:46:44 2009 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 16 Dec 2009 16:46:44 +0100 (CET) Subject: r4419 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests lib/libvcl Message-ID: <20091216154644.F18DB1F76F2@projects.linpro.no> Author: phk Date: 2009-12-16 16:46:44 +0100 (Wed, 16 Dec 2009) New Revision: 4419 Added: trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c trunk/varnish-cache/bin/varnishd/cache_dir_random.c trunk/varnish-cache/lib/libvcl/vcc_backend.c Log: Exploit the new and cleaner director interface and add a "hash" director by sharing most of the code with the "random" director. The Hash director will use the hash output from vcl_hash{} to pick a backend from the configured set. If this backend is unhealthy, it pick another backend, using only the healthy subset of backends, but as soon as the "canonical" backend becomes healthy it will revert to using that. This means that one backend going unhealthy on "rehashes" the requests for that backend, hashing for healthy backends are not affected. Modified: trunk/varnish-cache/bin/varnishd/cache_backend.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 14:31:27 UTC (rev 4418) +++ trunk/varnish-cache/bin/varnishd/cache_backend.h 2009-12-16 15:46:44 UTC (rev 4419) @@ -155,6 +155,8 @@ /* Init functions for directors */ -void VRT_init_dir_simple(struct cli *, struct director **, int , const void*); -void VRT_init_dir_random(struct cli *, struct director **, int , const void*); -void VRT_init_dir_round_robin(struct cli *, struct director **, int , const void*); +typedef void dir_init_f(struct cli *, struct director **, int , const void*); +dir_init_f VRT_init_dir_simple; +dir_init_f VRT_init_dir_hash; +dir_init_f VRT_init_dir_random; +dir_init_f VRT_init_dir_round_robin; Modified: trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c 2009-12-16 14:31:27 UTC (rev 4418) +++ trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c 2009-12-16 15:46:44 UTC (rev 4419) @@ -269,6 +269,8 @@ ASSERT_CLI(); if (!strcmp(name, "simple")) VRT_init_dir_simple(cli, dir, idx, priv); + else if (!strcmp(name, "hash")) + VRT_init_dir_hash(cli, dir, idx, priv); else if (!strcmp(name, "random")) VRT_init_dir_random(cli, dir, idx, priv); else if (!strcmp(name, "round-robin")) Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 14:31:27 UTC (rev 4418) +++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c 2009-12-16 15:46:44 UTC (rev 4419) @@ -26,6 +26,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * This code is shared between the random and hash directors, because they + * share the same properties and most of the same selection logic. + * + * The random director picks a backend on random, according to weight, + * from the healty subset of backends. + * + * The hash director first tries to locate the "canonical" backend from + * the full set, according to weight, and if it is healthy selects it. + * If the canonical backend is not healthy, we pick a backend according + * to weight from the healthy subset. That way only traffic to unhealthy + * backends gets redistributed. */ #include "config.h" @@ -59,7 +70,9 @@ #define VDI_RANDOM_MAGIC 0x3771ae23 struct director dir; + unsigned use_hash; unsigned retries; + double tot_weight; struct vdi_random_host *hosts; unsigned nhosts; }; @@ -70,6 +83,7 @@ int i, k; struct vdi_random *vs; double r, s1; + unsigned u; struct vbe_conn *vbe; struct director *d2; @@ -77,6 +91,30 @@ CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); + /* + * If we are hashing, first try to hit our "canonical backend" + * If that fails, we fall through, and select a weighted backend + * amongst the good set. + */ + if (vs->use_hash) { + memcpy(&u, sp->digest, sizeof u); + r = u / 4294967296.0; + r *= vs->tot_weight; + s1 = 0.0; + for (i = 0; i < vs->nhosts; i++) { + s1 += vs->hosts[i].weight; + if (r >= s1) + continue; + d2 = vs->hosts[i].backend; + if (!VBE_Healthy(d2, sp)) + break; + vbe = VBE_GetFd(d2, sp); + if (vbe != NULL) + return (vbe); + break; + } + } + for (k = 0; k < vs->retries; ) { /* Sum up the weights of healty backends */ @@ -91,8 +129,13 @@ if (s1 == 0.0) return (NULL); - /* Pick a random threshold in that interval */ - r = random() / 2147483648.0; /* 2^31 */ + if (vs->use_hash) { + memcpy(&u, sp->digest, sizeof u); + r = u / 4294967296.0; + } else { + /* Pick a random threshold in that interval */ + r = random() / 2147483648.0; /* 2^31 */ + } assert(r >= 0.0 && r < 1.0); r *= s1; @@ -119,15 +162,13 @@ { struct vdi_random *vs; int i; - struct director *d2; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC); for (i = 0; i < vs->nhosts; i++) { - d2 = vs->hosts[i].backend; - if (VBE_Healthy(d2, sp)) + if (VBE_Healthy(vs->hosts[i].backend, sp)) return 1; } return 0; @@ -148,9 +189,9 @@ FREE_OBJ(vs); } -void -VRT_init_dir_random(struct cli *cli, struct director **bp, int idx, - const void *priv) +static void +vrt_init(struct cli *cli, struct director **bp, int idx, + const void *priv, int use_hash) { const struct vrt_dir_random *t; struct vdi_random *vs; @@ -175,17 +216,34 @@ vs->dir.fini = vdi_random_fini; vs->dir.healthy = vdi_random_healthy; + vs->use_hash = use_hash; vs->retries = t->retries; if (vs->retries == 0) vs->retries = t->nmember; vh = vs->hosts; te = t->members; + vs->tot_weight = 0.; for (i = 0; i < t->nmember; i++, vh++, te++) { assert(te->weight > 0.0); vh->weight = te->weight; + vs->tot_weight += vh->weight; vh->backend = bp[te->host]; AN(vh->backend); } vs->nhosts = t->nmember; bp[idx] = &vs->dir; } + +void +VRT_init_dir_random(struct cli *cli, struct director **bp, int idx, + const void *priv) +{ + vrt_init(cli, bp, idx, priv, 0); +} + +void +VRT_init_dir_hash(struct cli *cli, struct director **bp, int idx, + const void *priv) +{ + vrt_init(cli, bp, idx, priv, 1); +} Added: trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/v00026.vtc 2009-12-16 15:46:44 UTC (rev 4419) @@ -0,0 +1,52 @@ +# $Id$ + +test "Hash director" + +server s1 { + rxreq + txresp -hdr "Foo: 1" -body "1" + rxreq + txresp -hdr "Foo: 3" -body "3" +} -start + +server s2 { + rxreq + txresp -hdr "Foo: 2" -body "2" + rxreq + txresp -hdr "Foo: 4" -body "4" +} -start + + +varnish v1 -vcl+backend { + director h1 hash { + { .backend = s1; .weight = 1; } + { .backend = s2; .weight = 1; } + } + + sub vcl_recv { + set req.backend = h1; + pass; + } + +} -start + + +client c1 { + txreq -url /12 + rxresp + expect resp.http.foo == "1" + + txreq -url /1 + rxresp + expect resp.http.foo == "2" + + txreq -url /13 + rxresp + expect resp.http.foo == "3" + + txreq -url /15 + rxresp + expect resp.http.foo == "4" + + +} -run Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 14:31:27 UTC (rev 4418) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-16 15:46:44 UTC (rev 4419) @@ -776,6 +776,7 @@ const char *name; parsedirector_f *func; } dirlist[] = { + { "hash", vcc_ParseRandomDirector }, { "random", vcc_ParseRandomDirector }, { "round-robin", vcc_ParseRoundRobinDirector }, { NULL, NULL }