From fgsch at lodoss.net Fri Jan 2 01:00:56 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 02 Jan 2015 02:00:56 +0100 Subject: [master] 3769f02 Instruct Travis to test using clang and gcc Message-ID: commit 3769f022e9c7782dde83358259ed5bda3f322ef8 Author: Federico G. Schwindt Date: Fri Jan 2 01:00:09 2015 +0000 Instruct Travis to test using clang and gcc diff --git a/.travis.yml b/.travis.yml index f55a37b..3ed018a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ --- -script: 'make -j3 check' +language: c +compiler: + - clang + - gcc before_install: - sudo apt-get install python-docutils - ./autogen.sh - ./configure +script: 'make -j3 check' From phk at FreeBSD.org Mon Jan 5 08:30:22 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 05 Jan 2015 09:30:22 +0100 Subject: [master] 344f794 Properly throw return values away. Message-ID: commit 344f794b71c6904e9a6b7885ecce2603207742cf Author: Poul-Henning Kamp Date: Mon Jan 5 08:30:10 2015 +0000 Properly throw return values away. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 93d6ea7..d53ce82 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -710,7 +710,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) do { ois = ObjIter(bo->ims_oc, oi, &sp, &sl); if (ois == OIS_ERROR) - VFP_Error(bo->vfc, "Template object failed"); + (void)VFP_Error(bo->vfc, "Template object failed"); while (sl > 0) { l = ObjGetLen(bo->wrk, bo->ims_oc) - al; assert(l > 0); @@ -727,7 +727,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } while (!bo->vfc->failed && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(bo->ims_oc, &oi); if (bo->ims_oc->flags & OC_F_FAILED) - VFP_Error(bo->vfc, "Template object failed"); + (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { VDI_Finish(bo->director_resp, bo->wrk, bo); return (F_STP_FAIL); From phk at FreeBSD.org Tue Jan 6 10:00:11 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 11:00:11 +0100 Subject: [master] 02adb47 Slim this table down to 80 char width like all other source files. Message-ID: commit 02adb478d8dc49833eec39e53504dfc75c6020c6 Author: Poul-Henning Kamp Date: Tue Jan 6 09:59:48 2015 +0000 Slim this table down to 80 char width like all other source files. diff --git a/include/tbl/http_headers.h b/include/tbl/http_headers.h index 0a5395f..53cd8fe 100644 --- a/include/tbl/http_headers.h +++ b/include/tbl/http_headers.h @@ -29,72 +29,89 @@ * Argument list: * --------------------------------------- * a Http header name - * b session field name + * b enum name * c Supress header in filter ops * * see [RFC2616 13.5.1 End-to-end and Hop-by-hop Headers] * */ + /*lint -save -e525 -e539 */ #ifndef HTTPH_R_PASS -#define HTTPH_R_PASS (1 << 0) /* Request (c->b) in pass mode */ +#define HTTPH_R_PASS (1 << 0 ) /* Request (c->b) in pass mode */ #define HTTPH_R_FETCH (1 << 1) /* Request (c->b) for fetch */ #define HTTPH_A_INS (1 << 2) /* Response (b->o) for insert */ #endif -HTTPH("Keep-Alive", H_Keep_Alive, HTTPH_R_PASS | HTTPH_R_FETCH ) /* RFC2068 */ -HTTPH("Accept", H_Accept, 0 ) /* RFC2616 14.1 */ -HTTPH("Accept-Charset", H_Accept_Charset, 0 ) /* RFC2616 14.2 */ -HTTPH("Accept-Encoding", H_Accept_Encoding, 0 ) /* RFC2616 14.3 */ -HTTPH("Accept-Language", H_Accept_Language, 0 ) /* RFC2616 14.4 */ -HTTPH("Accept-Ranges", H_Accept_Ranges, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.5 */ -HTTPH("Age", H_Age, HTTPH_A_INS) /* RFC2616 14.6 */ -HTTPH("Allow", H_Allow, 0 ) /* RFC2616 14.7 */ -HTTPH("Authorization", H_Authorization, 0 ) /* RFC2616 14.8 */ -HTTPH("Cache-Control", H_Cache_Control, HTTPH_R_FETCH ) /* RFC2616 14.9 */ -HTTPH("Connection", H_Connection, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.10 */ -HTTPH("Content-Encoding", H_Content_Encoding, 0 ) /* RFC2616 14.11 */ -HTTPH("Content-Language", H_Content_Language, 0 ) /* RFC2616 14.12 */ -HTTPH("Content-Length", H_Content_Length, HTTPH_R_FETCH ) /* RFC2616 14.13 */ -HTTPH("Content-Location", H_Content_Location, 0 ) /* RFC2616 14.14 */ -HTTPH("Content-MD5", H_Content_MD5, 0 ) /* RFC2616 14.15 */ -HTTPH("Content-Range", H_Content_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.16 */ -HTTPH("Content-Type", H_Content_Type, 0 ) /* RFC2616 14.17 */ -HTTPH("Cookie", H_Cookie, 0 ) /* RFC6265 4.2 */ -HTTPH("Date", H_Date, 0 ) /* RFC2616 14.18 */ -HTTPH("ETag", H_ETag, 0 ) /* RFC2616 14.19 */ -HTTPH("Expect", H_Expect, 0 ) /* RFC2616 14.20 */ -HTTPH("Expires", H_Expires, 0 ) /* RFC2616 14.21 */ -HTTPH("From", H_From, 0 ) /* RFC2616 14.22 */ -HTTPH("Host", H_Host, 0 ) /* RFC2616 14.23 */ -HTTPH("HTTP2-Settings", H_HTTP2_Settings, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* draft-ietf-httpbis-http2-12.txt */ -HTTPH("If-Match", H_If_Match, HTTPH_R_FETCH ) /* RFC2616 14.24 */ -HTTPH("If-Modified-Since", H_If_Modified_Since, HTTPH_R_FETCH ) /* RFC2616 14.25 */ -HTTPH("If-None-Match", H_If_None_Match, HTTPH_R_FETCH ) /* RFC2616 14.26 */ -HTTPH("If-Range", H_If_Range, HTTPH_R_FETCH ) /* RFC2616 14.27 */ -HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, HTTPH_R_FETCH ) /* RFC2616 14.28 */ -HTTPH("Last-Modified", H_Last_Modified, 0 ) /* RFC2616 14.29 */ -HTTPH("Location", H_Location, 0 ) /* RFC2616 14.30 */ -HTTPH("Max-Forwards", H_Max_Forwards, 0 ) /* RFC2616 14.31 */ -HTTPH("Pragma", H_Pragma, 0 ) /* RFC2616 14.32 */ -HTTPH("Proxy-Authenticate", H_Proxy_Authenticate, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.33 */ -HTTPH("Proxy-Authorization", H_Proxy_Authorization, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.34 */ -HTTPH("Range", H_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.35 */ -HTTPH("Referer", H_Referer, 0 ) /* RFC2616 14.36 */ -HTTPH("Retry-After", H_Retry_After, 0 ) /* RFC2616 14.37 */ -HTTPH("Server", H_Server, 0 ) /* RFC2616 14.38 */ -HTTPH("Set-Cookie", H_Set_Cookie, 0 ) /* RFC6265 4.1 */ -HTTPH("TE", H_TE, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.39 */ -HTTPH("Trailer", H_Trailer, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.40 */ -HTTPH("Transfer-Encoding", H_Transfer_Encoding, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.41 */ -HTTPH("Upgrade", H_Upgrade, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.42 */ -HTTPH("User-Agent", H_User_Agent, 0 ) /* RFC2616 14.43 */ -HTTPH("Vary", H_Vary, 0 ) /* RFC2616 14.44 */ -HTTPH("Via", H_Via, 0 ) /* RFC2616 14.45 */ -HTTPH("Warning", H_Warning, 0 ) /* RFC2616 14.46 */ -HTTPH("WWW-Authenticate", H_WWW_Authenticate, 0 ) /* RFC2616 14.47 */ -HTTPH("X-Forwarded-For", H_X_Forwarded_For, 0 ) /* Not RFC */ +/* Shorthand for this file only, to keep table narrow */ + +#if defined(P) || defined(F) || defined(I) || defined(H) +#error "Macro overloading" // Trust but verify +#endif + +#define P HTTPH_R_PASS +#define F HTTPH_R_FETCH +#define I HTTPH_A_INS +#define H(s,e,f) HTTPH(s, e, f) + +H("Keep-Alive", H_Keep_Alive, P|F ) // 2068 +H("Accept", H_Accept, 0 ) // 2616 14.1 +H("Accept-Charset", H_Accept_Charset, 0 ) // 2616 14.2 +H("Accept-Encoding", H_Accept_Encoding, 0 ) // 2616 14.3 +H("Accept-Language", H_Accept_Language, 0 ) // 2616 14.4 +H("Accept-Ranges", H_Accept_Ranges, F|I) // 2616 14.5 +H("Age", H_Age, I) // 2616 14.6 +H("Allow", H_Allow, 0 ) // 2616 14.7 +H("Authorization", H_Authorization, 0 ) // 2616 14.8 +H("Cache-Control", H_Cache_Control, F ) // 2616 14.9 +H("Connection", H_Connection, P|F|I) // 2616 14.10 +H("Content-Encoding", H_Content_Encoding, 0 ) // 2616 14.11 +H("Content-Language", H_Content_Language, 0 ) // 2616 14.12 +H("Content-Length", H_Content_Length, F ) // 2616 14.13 +H("Content-Location", H_Content_Location, 0 ) // 2616 14.14 +H("Content-MD5", H_Content_MD5, 0 ) // 2616 14.15 +H("Content-Range", H_Content_Range, F|I) // 2616 14.16 +H("Content-Type", H_Content_Type, 0 ) // 2616 14.17 +H("Cookie", H_Cookie, 0 ) // 6265 4.2 +H("Date", H_Date, 0 ) // 2616 14.18 +H("ETag", H_ETag, 0 ) // 2616 14.19 +H("Expect", H_Expect, 0 ) // 2616 14.20 +H("Expires", H_Expires, 0 ) // 2616 14.21 +H("From", H_From, 0 ) // 2616 14.22 +H("Host", H_Host, 0 ) // 2616 14.23 +H("HTTP2-Settings", H_HTTP2_Settings, P|F|I) // httpbis-http2-16.txt +H("If-Match", H_If_Match, F ) // 2616 14.24 +H("If-Modified-Since", H_If_Modified_Since, F ) // 2616 14.25 +H("If-None-Match", H_If_None_Match, F ) // 2616 14.26 +H("If-Range", H_If_Range, F ) // 2616 14.27 +H("If-Unmodified-Since",H_If_Unmodifed_Since, F ) // 2616 14.28 +H("Last-Modified", H_Last_Modified, 0 ) // 2616 14.29 +H("Location", H_Location, 0 ) // 2616 14.30 +H("Max-Forwards", H_Max_Forwards, 0 ) // 2616 14.31 +H("Pragma", H_Pragma, 0 ) // 2616 14.32 +H("Proxy-Authenticate", H_Proxy_Authenticate, F|I) // 2616 14.33 +H("Proxy-Authorization",H_Proxy_Authorization, F|I) // 2616 14.34 +H("Range", H_Range, F|I) // 2616 14.35 +H("Referer", H_Referer, 0 ) // 2616 14.36 +H("Retry-After", H_Retry_After, 0 ) // 2616 14.37 +H("Server", H_Server, 0 ) // 2616 14.38 +H("Set-Cookie", H_Set_Cookie, 0 ) // 6265 4.1 +H("TE", H_TE, P|F|I) // 2616 14.39 +H("Trailer", H_Trailer, P|F|I) // 2616 14.40 +H("Transfer-Encoding", H_Transfer_Encoding, P|F|I) // 2616 14.41 +H("Upgrade", H_Upgrade, P|F|I) // 2616 14.42 +H("User-Agent", H_User_Agent, 0 ) // 2616 14.43 +H("Vary", H_Vary, 0 ) // 2616 14.44 +H("Via", H_Via, 0 ) // 2616 14.45 +H("Warning", H_Warning, 0 ) // 2616 14.46 +H("WWW-Authenticate", H_WWW_Authenticate, 0 ) // 2616 14.47 +H("X-Forwarded-For", H_X_Forwarded_For, 0 ) // No RFC + +#undef P +#undef F +#undef I +#undef H /*lint -restore */ From phk at FreeBSD.org Tue Jan 6 10:57:16 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 11:57:16 +0100 Subject: [master] 3ba899d Be more consistent about per-hop/end-to-end headers. Message-ID: commit 3ba899d4cf13d45ff1f21fd45f8edfc320dd7a24 Author: Poul-Henning Kamp Date: Tue Jan 6 10:55:21 2015 +0000 Be more consistent about per-hop/end-to-end headers. diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index e655fa0..eff9408 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -265,23 +265,6 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr) } /*-------------------------------------------------------------------- - */ - -static void -http_MarkHeader(const struct http *hp, const char *hdr, unsigned hdrlen, - uint8_t flag) -{ - unsigned u; - - CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - - u = http_findhdr(hp, hdrlen, hdr); - if (u == 0) - return; - hp->hdf[u] |= flag; -} - -/*-------------------------------------------------------------------- * Count how many instances we have of this header */ @@ -655,7 +638,7 @@ http_DoConnection(struct http *hp) { const char *h, *b, *e; enum sess_close retval; - unsigned u; + unsigned u, v; if (hp->protover < 11) retval = SC_REQ_HTTP10; @@ -672,7 +655,20 @@ http_DoConnection(struct http *hp) retval = SC_REQ_CLOSE; if (u == 10 && !strncasecmp(b, "keep-alive", u)) retval = SC_NULL; - http_MarkHeader(hp, b, u, HDF_FILTER); + + /* Refuse removal of well-known-headers if they would pass. */ +/*lint -save -e506 */ +#define HTTPH(a, x, c) \ + if (!((c) & HTTPH_R_PASS) && \ + strlen(a) == u && !strncasecmp(a, b, u)) \ + return (SC_RX_BAD); +#include "tbl/http_headers.h" +#undef HTTPH +/*lint -restore */ + + v = http_findhdr(hp, u, b); + if (v > 0) + hp->hdf[v] |= HDF_FILTER; } return (retval); } diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 29bd789..910dfac 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -304,6 +304,13 @@ http1_dissect(struct worker *wrk, struct req *req) req->ws_req = WS_Snapshot(req->ws); req->doclose = http_DoConnection(req->http); + if (req->doclose == SC_RX_BAD) { + r = write(req->sp->fd, r_400, strlen(r_400)); + if (r > 0) + req->acct.resp_hdrbytes += r; + SES_Close(req->sp, req->doclose); + return (REQ_FSM_DONE); + } assert(req->req_body_status != REQ_BODY_INIT); diff --git a/bin/varnishtest/tests/c00016.vtc b/bin/varnishtest/tests/c00016.vtc index 83c9527..3e0b2be 100644 --- a/bin/varnishtest/tests/c00016.vtc +++ b/bin/varnishtest/tests/c00016.vtc @@ -23,3 +23,9 @@ client c1 { rxresp expect req.http.Bar == } -run + +client c1 { + txreq -hdr "foo: 1" -hdr "Age: 200" -hdr "Connection: Age" + rxresp + expect resp.status == 400 +} -run diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index 5b77eba..351cc58 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -29,18 +29,19 @@ /*lint -save -e525 -e539 */ -SESS_CLOSE(REM_CLOSE, "Client Closed") -SESS_CLOSE(REQ_CLOSE, "Client requested close") -SESS_CLOSE(REQ_HTTP10, "Proto < HTTP/1.1") -SESS_CLOSE(RX_BODY, "Failure receiving req.body") -SESS_CLOSE(RX_JUNK, "Received junk data") -SESS_CLOSE(RX_OVERFLOW, "Received buffer overflow") -SESS_CLOSE(RX_TIMEOUT, "Receive timeout") -SESS_CLOSE(TX_PIPE, "Piped transaction") -SESS_CLOSE(TX_ERROR, "Error transaction") -SESS_CLOSE(TX_EOF, "EOF transmission") -SESS_CLOSE(RESP_CLOSE, "Backend/VCL requested close") -SESS_CLOSE(OVERLOAD, "Out of some resource") +SESS_CLOSE(REM_CLOSE, "Client Closed") +SESS_CLOSE(REQ_CLOSE, "Client requested close") +SESS_CLOSE(REQ_HTTP10, "Proto < HTTP/1.1") +SESS_CLOSE(RX_BAD, "Received bad request") +SESS_CLOSE(RX_BODY, "Failure receiving req.body") +SESS_CLOSE(RX_JUNK, "Received junk data") +SESS_CLOSE(RX_OVERFLOW, "Received buffer overflow") +SESS_CLOSE(RX_TIMEOUT, "Receive timeout") +SESS_CLOSE(TX_PIPE, "Piped transaction") +SESS_CLOSE(TX_ERROR, "Error transaction") +SESS_CLOSE(TX_EOF, "EOF transmission") +SESS_CLOSE(RESP_CLOSE, "Backend/VCL requested close") +SESS_CLOSE(OVERLOAD, "Out of some resource") SESS_CLOSE(SESS_PIPE_OVERFLOW, "Session pipe overflow") /*lint -restore */ From phk at FreeBSD.org Tue Jan 6 12:52:56 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 13:52:56 +0100 Subject: [master] 8ba2941 Add a test-case for r01644, even though I cannot reproduce the problem, it may be a platform thing, in which case Jenkins should go Technicrome after this commit...3...2...1... Message-ID: commit 8ba2941b70d919e7c6c14be9527839e92802096c Author: Poul-Henning Kamp Date: Tue Jan 6 12:51:47 2015 +0000 Add a test-case for r01644, even though I cannot reproduce the problem, it may be a platform thing, in which case Jenkins should go Technicrome after this commit...3...2...1... diff --git a/bin/varnishtest/tests/r01644.vtc b/bin/varnishtest/tests/r01644.vtc new file mode 100644 index 0000000..f845213 --- /dev/null +++ b/bin/varnishtest/tests/r01644.vtc @@ -0,0 +1,33 @@ +varnishtest "test access to cache_param from vmod" + +server s1 { + rxreq + txresp + +} -start + +varnish v1 -vcl+backend { + + import ${vmod_debug}; + + sub vcl_deliver { + set resp.http.foo = debug.vre_limit(); + } + +} -start + +varnish v1 -cliok "param.set pcre_match_limit 100" + +client c1 { + txreq + rxresp + expect resp.http.foo == 100 +} -run + +varnish v1 -cliok "param.set pcre_match_limit 200" + +client c1 { + txreq + rxresp + expect resp.http.foo == 200 +} -run diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index a027779..cafd88d 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -91,3 +91,5 @@ Encrypt the HTTP header with quad-ROT13 encryption, (this is approx 33% better than triple-DES). $Function STRING argtest(STRING one, REAL two=2, STRING three="3") + +$Function INT vre_limit() diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 500d154..1a5331b 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -168,3 +168,10 @@ vmod_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three) bprintf(buf, "%s %g %s", one, two, three); return WS_Copy(ctx->ws, buf, -1); } + +VCL_INT +vmod_vre_limit(VRT_CTX) +{ + (void)ctx; + return (cache_param->vre_limits.match); +} From phk at FreeBSD.org Tue Jan 6 13:54:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 14:54:51 +0100 Subject: [master] abd320a Language nit from herrpaco@github Message-ID: commit abd320ae46e5eb2176f695eddf68c1afeb040b4a Author: Poul-Henning Kamp Date: Tue Jan 6 13:54:20 2015 +0000 Language nit from herrpaco at github diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index b87a1a6..1adb5fe 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -32,7 +32,7 @@ Conventions used in this manual include: http://www.varnish-cache.org/ A hyperlink. -Longer listings like example command output and VCL will look like this:: +Longer listings like example command output and VCL look like this:: $ /opt/varnish/sbin/varnishd -V varnishd (varnish-4.0.0-tp1 revision ddd00e1) From phk at FreeBSD.org Tue Jan 6 13:56:43 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 14:56:43 +0100 Subject: [master] 6113d5d Minor typos from dbs@github Message-ID: commit 6113d5da02a4725ac03cd6922580a4358494e791 Author: Poul-Henning Kamp Date: Tue Jan 6 13:56:26 2015 +0000 Minor typos from dbs at github diff --git a/doc/sphinx/tutorial/introduction.rst b/doc/sphinx/tutorial/introduction.rst index 330764f..cff7268 100644 --- a/doc/sphinx/tutorial/introduction.rst +++ b/doc/sphinx/tutorial/introduction.rst @@ -30,7 +30,7 @@ Performance Varnish has a modern architecture and is written with performance in mind. It is usually bound by the speed of the network, effectively turning performance into a non-issue. You get to focus on how your web -application work and you can allow yourself, to some degree, to care +applications work and you can allow yourself, to some degree, to care less about performance and scalability. .. XXX:Not totally sure what the last sentence above means. benc @@ -58,7 +58,7 @@ About the Varnish development process ------------------------------------- Varnish is a community driven project. The development is overseen by -the Varnish Governing Board which currently consist of Poul-Henning Kamp +the Varnish Governing Board which currently consists of Poul-Henning Kamp (Architect), Rogier Mulhuijzen (Fastly) and Lasse Karstensen (Varnish Software). @@ -69,13 +69,13 @@ Getting in touch ---------------- You can get in touch with us through many channels. For real time chat -you can reach us on IRC trough the server irc.linpro.net on the #varnish +you can reach us on IRC through the server irc.linpro.net on the #varnish and #varnish-hacking channels. -There are two mailing lists available. One for user questions and one +There are two mailing lists available: one for user questions and one for development discussions. See https://www.varnish-cache.org/lists for information and signup. There is also a web forum on the same site. -Now that you have a vague idea on what Varnish Cache is, let see if we +Now that you have a vague idea on what Varnish Cache is, let's see if we can get it up and running. .. XXX:The above three paragraphs are repetitive this is already handled in previous chapters. The only new information is Governing Board which could be moved to the introduction and the paragraphs scrapped. benc From phk at FreeBSD.org Tue Jan 6 14:12:36 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 06 Jan 2015 15:12:36 +0100 Subject: [master] 18f1f7a Use VFIL_readfile() rather than home-rolled function. Message-ID: commit 18f1f7ac1aeaefc68484537c9e7482f90d03f991 Author: Poul-Henning Kamp Date: Tue Jan 6 14:11:53 2015 +0000 Use VFIL_readfile() rather than home-rolled function. Inspired by fix from JonathanHuot at github diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 6fdfb6f..8b649d8 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -43,6 +43,7 @@ #include "vtc.h" #include "vev.h" +#include "vfil.h" #include "vqueue.h" #include "vrnd.h" #include "vtim.h" @@ -108,37 +109,6 @@ parse_D_opt(char *arg) } /********************************************************************** - * Read a file into memory - */ - -static char * -read_file(const char *fn) -{ - char *buf; - ssize_t sz = MAX_FILESIZE; - ssize_t s; - int fd; - - fd = open(fn, O_RDONLY); - if (fd < 0) - return (NULL); - buf = malloc(sz); - assert(buf != NULL); - s = read(fd, buf, sz - 1); - if (s <= 0) { - free(buf); - (void)close(fd); - return (NULL); - } - AZ(close (fd)); - assert(s < sz); /* XXX: increase MAX_FILESIZE */ - buf[s] = '\0'; - buf = realloc(buf, s + 1); - assert(buf != NULL); - return (buf); -} - -/********************************************************************** * Print usage */ @@ -345,7 +315,7 @@ i_mode(void) vsb = VSB_new_auto(); - q = p = read_file("Makefile"); + q = p = VFIL_readfile(NULL, "Makefile", NULL); if (p == NULL) { fprintf(stderr, "No Makefile to search for -i flag.\n"); VSB_printf(vsb, "%s/../..", cwd); @@ -492,7 +462,7 @@ main(int argc, char * const *argv) argv += optind; for (;argc > 0; argc--, argv++) { - p = read_file(*argv); + p = VFIL_readfile(NULL, *argv, NULL); if (p == NULL) { fprintf(stderr, "Cannot stat file \"%s\": %s\n", *argv, strerror(errno)); diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index d985e3e..0b035da 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -105,8 +105,11 @@ VFIL_readfd(int fd, ssize_t *sz) return (NULL); f = malloc(st.st_size + 1); assert(f != NULL); - i = read(fd, f, st.st_size); - assert(i == st.st_size); + i = read(fd, f, st.st_size + 1); + if (i != st.st_size) { + free(f); + return (NULL); + } f[i] = '\0'; if (sz != NULL) *sz = st.st_size; From fgsch at lodoss.net Tue Jan 6 14:38:18 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 06 Jan 2015 15:38:18 +0100 Subject: [master] a5a45d6 Typo Message-ID: commit a5a45d68ed2a58fcd2373f29089e4eadf0ce0460 Author: Federico G. Schwindt Date: Tue Jan 6 14:21:41 2015 +0000 Typo diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 0d646a2..19e8ad6 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -39,7 +39,7 @@ * 'g' - Gauge, goes up and down * 'i' - Integer (deprecated, use 'g') * v - Verbosity: Counter verbosity level (see vsc_levels.h) - * e - Explantion: Short explanation of field (for screen use) + * e - Explanation: Short explanation of field (for screen use) * d - Description: Long explanation of field (for doc use) * * Please describe Gauge variables as "Number of..." to indicate that From fgsch at lodoss.net Tue Jan 6 14:38:18 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 06 Jan 2015 15:38:18 +0100 Subject: [master] 5cceef8 Stop using deprecated stats formats Message-ID: commit 5cceef8159f65a9edc73621f578f1df2a0cc14a8 Author: Federico G. Schwindt Date: Tue Jan 6 14:34:53 2015 +0000 Stop using deprecated stats formats diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index c4bb931..42c57e2 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -61,7 +61,7 @@ * Globals, not related to traffic */ -VSC_F(uptime, uint64_t, 0, 'a', info, +VSC_F(uptime, uint64_t, 0, 'c', info, "Child process uptime", "How long the child process has been running." ) @@ -95,32 +95,32 @@ VSC_F(sess_pipe_overflow, uint64_t, 1, 'c', info, /*---------------------------------------------------------------------*/ -VSC_F(client_req_400, uint64_t, 1, 'a', info, +VSC_F(client_req_400, uint64_t, 1, 'c', info, "Client requests received, subject to 400 errors", "400 means we couldn't make sense of the request, it was" " malformed in some drastic way." ) -VSC_F(client_req_417, uint64_t, 1, 'a', info, +VSC_F(client_req_417, uint64_t, 1, 'c', info, "Client requests received, subject to 417 errors", "417 means that something went wrong with an Expect: header." ) -VSC_F(client_req, uint64_t, 1, 'a', info, +VSC_F(client_req, uint64_t, 1, 'c', info, "Good client requests received", "The count of parseable client requests seen." ) /*---------------------------------------------------------------------*/ -VSC_F(cache_hit, uint64_t, 1, 'a', info, +VSC_F(cache_hit, uint64_t, 1, 'c', info, "Cache hits", "Count of cache hits. " " A cache hit indicates that an object has been delivered to a" " client without fetching it from a backend server." ) -VSC_F(cache_hitpass, uint64_t, 1, 'a', info, +VSC_F(cache_hitpass, uint64_t, 1, 'c', info, "Cache hits for pass", "Count of hits for pass" " A cache hit for pass indicates that Varnish is going to" @@ -129,7 +129,7 @@ VSC_F(cache_hitpass, uint64_t, 1, 'a', info, " decision is being used." ) -VSC_F(cache_miss, uint64_t, 1, 'a', info, +VSC_F(cache_miss, uint64_t, 1, 'c', info, "Cache misses", "Count of misses" " A cache miss indicates the object was fetched from the" @@ -138,34 +138,34 @@ VSC_F(cache_miss, uint64_t, 1, 'a', info, /*---------------------------------------------------------------------*/ -VSC_F(backend_conn, uint64_t, 0, 'a', info, +VSC_F(backend_conn, uint64_t, 0, 'c', info, "Backend conn. success", "How many backend connections have successfully been" " established." ) -VSC_F(backend_unhealthy, uint64_t, 0, 'a', info, +VSC_F(backend_unhealthy, uint64_t, 0, 'c', info, "Backend conn. not attempted", "" ) -VSC_F(backend_busy, uint64_t, 0, 'a', info, +VSC_F(backend_busy, uint64_t, 0, 'c', info, "Backend conn. too many", "" ) -VSC_F(backend_fail, uint64_t, 0, 'a', info, +VSC_F(backend_fail, uint64_t, 0, 'c', info, "Backend conn. failures", "" ) -VSC_F(backend_reuse, uint64_t, 0, 'a', info, +VSC_F(backend_reuse, uint64_t, 0, 'c', info, "Backend conn. reuses", "Count of backend connection reuses" " This counter is increased whenever we reuse a recycled connection." ) -VSC_F(backend_toolate, uint64_t, 0, 'a', info, +VSC_F(backend_toolate, uint64_t, 0, 'c', info, "Backend conn. was closed", "" ) -VSC_F(backend_recycle, uint64_t, 0, 'a', info, +VSC_F(backend_recycle, uint64_t, 0, 'c', info, "Backend conn. recycles", "Count of backend connection recycles" " This counter is increased whenever we have a keep-alive" @@ -173,7 +173,7 @@ VSC_F(backend_recycle, uint64_t, 0, 'a', info, " It has not yet been used, but it might be, unless the backend" " closes it." ) -VSC_F(backend_retry, uint64_t, 0, 'a', info, +VSC_F(backend_retry, uint64_t, 0, 'c', info, "Backend conn. retry", "" ) @@ -309,165 +309,165 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', info, /*---------------------------------------------------------------------*/ -VSC_F(n_object, uint64_t, 1, 'i', info, +VSC_F(n_object, uint64_t, 1, 'g', info, "object structs made", "Number of object structs made" ) -VSC_F(n_vampireobject, uint64_t, 1, 'i', diag, +VSC_F(n_vampireobject, uint64_t, 1, 'g', diag, "unresurrected objects", "Number of unresurrected objects" ) -VSC_F(n_objectcore, uint64_t, 1, 'i', info, +VSC_F(n_objectcore, uint64_t, 1, 'g', info, "objectcore structs made", "Number of objectcore structs made" ) -VSC_F(n_objecthead, uint64_t, 1, 'i', info, +VSC_F(n_objecthead, uint64_t, 1, 'g', info, "objecthead structs made", "Number of objecthead structs made" ) -VSC_F(n_waitinglist, uint64_t, 1, 'i', debug, +VSC_F(n_waitinglist, uint64_t, 1, 'g', debug, "waitinglist structs made", "Number of waitinglist structs made" ) -VSC_F(n_backend, uint64_t, 0, 'i', info, +VSC_F(n_backend, uint64_t, 0, 'g', info, "Number of backends", "Number of backends known to us." ) -VSC_F(n_expired, uint64_t, 0, 'i', info, +VSC_F(n_expired, uint64_t, 0, 'g', info, "Number of expired objects", "Number of objects that expired from cache" " because of old age." ) -VSC_F(n_lru_nuked, uint64_t, 0, 'i', info, +VSC_F(n_lru_nuked, uint64_t, 0, 'g', info, "Number of LRU nuked objects", "How many objects have been forcefully evicted" " from storage to make room for a new object." ) -VSC_F(n_lru_moved, uint64_t, 0, 'i', diag, +VSC_F(n_lru_moved, uint64_t, 0, 'g', diag, "Number of LRU moved objects", "Number of move operations done on the LRU list." ) -VSC_F(losthdr, uint64_t, 0, 'a', info, +VSC_F(losthdr, uint64_t, 0, 'c', info, "HTTP header overflows", "" ) -VSC_F(s_sess, uint64_t, 1, 'a', info, +VSC_F(s_sess, uint64_t, 1, 'c', info, "Total sessions seen", "" ) -VSC_F(s_req, uint64_t, 1, 'a', info, +VSC_F(s_req, uint64_t, 1, 'c', info, "Total requests seen", "" ) -VSC_F(s_pipe, uint64_t, 1, 'a', info, +VSC_F(s_pipe, uint64_t, 1, 'c', info, "Total pipe sessions seen", "" ) -VSC_F(s_pass, uint64_t, 1, 'a', info, +VSC_F(s_pass, uint64_t, 1, 'c', info, "Total pass-ed requests seen", "" ) -VSC_F(s_fetch, uint64_t, 1, 'a', info, +VSC_F(s_fetch, uint64_t, 1, 'c', info, "Total backend fetches initiated", "" ) -VSC_F(s_synth, uint64_t, 1, 'a', info, +VSC_F(s_synth, uint64_t, 1, 'c', info, "Total synthethic responses made", "" ) -VSC_F(s_req_hdrbytes, uint64_t, 1, 'a', info, +VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', info, "Request header bytes", "Total request header bytes received" ) -VSC_F(s_req_bodybytes, uint64_t, 1, 'a', info, +VSC_F(s_req_bodybytes, uint64_t, 1, 'c', info, "Request body bytes", "Total request body bytes received" ) -VSC_F(s_resp_hdrbytes, uint64_t, 1, 'a', info, +VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', info, "Response header bytes", "Total response header bytes transmitted" ) -VSC_F(s_resp_bodybytes, uint64_t, 1, 'a', info, +VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', info, "Response body bytes", "Total response body bytes transmitted" ) -VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'a', info, +VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', info, "Pipe request header bytes", "Total request bytes received for piped sessions" ) -VSC_F(s_pipe_in, uint64_t, 0, 'a', info, +VSC_F(s_pipe_in, uint64_t, 0, 'c', info, "Piped bytes from client", "Total number of bytes forwarded from clients in" " pipe sessions" ) -VSC_F(s_pipe_out, uint64_t, 0, 'a', info, +VSC_F(s_pipe_out, uint64_t, 0, 'c', info, "Piped bytes to client", "Total number of bytes forwarded to clients in" " pipe sessions" ) -VSC_F(sess_closed, uint64_t, 1, 'a', info, +VSC_F(sess_closed, uint64_t, 1, 'c', info, "Session Closed", "" ) -VSC_F(sess_pipeline, uint64_t, 1, 'a', info, +VSC_F(sess_pipeline, uint64_t, 1, 'c', info, "Session Pipeline", "" ) -VSC_F(sess_readahead, uint64_t, 1, 'a', info, +VSC_F(sess_readahead, uint64_t, 1, 'c', info, "Session Read Ahead", "" ) -VSC_F(sess_herd, uint64_t, 1, 'a', diag, +VSC_F(sess_herd, uint64_t, 1, 'c', diag, "Session herd", "" ) /*--------------------------------------------------------------------*/ -VSC_F(shm_records, uint64_t, 0, 'a', diag, +VSC_F(shm_records, uint64_t, 0, 'c', diag, "SHM records", "" ) -VSC_F(shm_writes, uint64_t, 0, 'a', diag, +VSC_F(shm_writes, uint64_t, 0, 'c', diag, "SHM writes", "" ) -VSC_F(shm_flushes, uint64_t, 0, 'a', diag, +VSC_F(shm_flushes, uint64_t, 0, 'c', diag, "SHM flushes due to overflow", "" ) -VSC_F(shm_cont, uint64_t, 0, 'a', diag, +VSC_F(shm_cont, uint64_t, 0, 'c', diag, "SHM MTX contention", "" ) -VSC_F(shm_cycles, uint64_t, 0, 'a', diag, +VSC_F(shm_cycles, uint64_t, 0, 'c', diag, "SHM cycles through buffer", "" ) /*--------------------------------------------------------------------*/ -VSC_F(backend_req, uint64_t, 0, 'a', info, +VSC_F(backend_req, uint64_t, 0, 'c', info, "Backend requests made", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_vcl, uint64_t, 0, 'a', info, +VSC_F(n_vcl, uint64_t, 0, 'c', info, "Number of loaded VCLs in total", "" ) -VSC_F(n_vcl_avail, uint64_t, 0, 'a', diag, +VSC_F(n_vcl_avail, uint64_t, 0, 'c', diag, "Number of VCLs available", "" ) -VSC_F(n_vcl_discard, uint64_t, 0, 'a', diag, +VSC_F(n_vcl_discard, uint64_t, 0, 'c', diag, "Number of discarded VCLs", "" ) @@ -555,11 +555,11 @@ VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', diag, /*--------------------------------------------------------------------*/ -VSC_F(n_purges, uint64_t, 0, 'i', info, +VSC_F(n_purges, uint64_t, 0, 'g', info, "Number of purge operations executed", "" ) -VSC_F(n_obj_purged, uint64_t, 0, 'i', info, +VSC_F(n_obj_purged, uint64_t, 0, 'g', info, "Number of purged objects", "" ) @@ -578,44 +578,44 @@ VSC_F(exp_received, uint64_t, 0, 'c', diag, /*--------------------------------------------------------------------*/ -VSC_F(hcb_nolock, uint64_t, 1, 'a', debug, +VSC_F(hcb_nolock, uint64_t, 1, 'c', debug, "HCB Lookups without lock", "" ) -VSC_F(hcb_lock, uint64_t, 0, 'a', debug, +VSC_F(hcb_lock, uint64_t, 0, 'c', debug, "HCB Lookups with lock", "" ) -VSC_F(hcb_insert, uint64_t, 0, 'a', debug, +VSC_F(hcb_insert, uint64_t, 0, 'c', debug, "HCB Inserts", "" ) /*--------------------------------------------------------------------*/ -VSC_F(esi_errors, uint64_t, 0, 'a', diag, +VSC_F(esi_errors, uint64_t, 0, 'c', diag, "ESI parse errors (unlock)", "" ) -VSC_F(esi_warnings, uint64_t, 0, 'a', diag, +VSC_F(esi_warnings, uint64_t, 0, 'c', diag, "ESI parse warnings (unlock)", "" ) /*--------------------------------------------------------------------*/ -VSC_F(vmods, uint64_t, 0, 'i', info, +VSC_F(vmods, uint64_t, 0, 'g', info, "Loaded VMODs", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_gzip, uint64_t, 0, 'a', info, +VSC_F(n_gzip, uint64_t, 0, 'c', info, "Gzip operations", "" ) -VSC_F(n_gunzip, uint64_t, 0, 'a', info, +VSC_F(n_gunzip, uint64_t, 0, 'c', info, "Gunzip operations", "" ) diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 19e8ad6..3f20184 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -98,15 +98,15 @@ VSC_F(child_panic, uint64_t, 0, 'c', diag, #ifdef VSC_DO_LCK -VSC_F(creat, uint64_t, 0, 'a', debug, +VSC_F(creat, uint64_t, 0, 'c', debug, "Created locks", "" ) -VSC_F(destroy, uint64_t, 0, 'a', debug, +VSC_F(destroy, uint64_t, 0, 'c', debug, "Destroyed locks", "" ) -VSC_F(locks, uint64_t, 0, 'a', debug, +VSC_F(locks, uint64_t, 0, 'c', debug, "Lock Operations", "" ) @@ -118,31 +118,31 @@ VSC_F(locks, uint64_t, 0, 'a', debug, */ #if defined(VSC_DO_SMA) || defined (VSC_DO_SMF) -VSC_F(c_req, uint64_t, 0, 'a', info, +VSC_F(c_req, uint64_t, 0, 'c', info, "Allocator requests", "" ) -VSC_F(c_fail, uint64_t, 0, 'a', info, +VSC_F(c_fail, uint64_t, 0, 'c', info, "Allocator failures", "" ) -VSC_F(c_bytes, uint64_t, 0, 'a', info, +VSC_F(c_bytes, uint64_t, 0, 'c', info, "Bytes allocated", "" ) -VSC_F(c_freed, uint64_t, 0, 'a', info, +VSC_F(c_freed, uint64_t, 0, 'c', info, "Bytes freed", "" ) -VSC_F(g_alloc, uint64_t, 0, 'i', info, +VSC_F(g_alloc, uint64_t, 0, 'g', info, "Allocations outstanding", "" ) -VSC_F(g_bytes, uint64_t, 0, 'i', info, +VSC_F(g_bytes, uint64_t, 0, 'g', info, "Bytes outstanding", "" ) -VSC_F(g_space, uint64_t, 0, 'i', info, +VSC_F(g_space, uint64_t, 0, 'g', info, "Bytes available", "" ) @@ -158,15 +158,15 @@ VSC_F(g_space, uint64_t, 0, 'i', info, /**********************************************************************/ #ifdef VSC_DO_SMF -VSC_F(g_smf, uint64_t, 0, 'i', info, +VSC_F(g_smf, uint64_t, 0, 'g', info, "N struct smf", "" ) -VSC_F(g_smf_frag, uint64_t, 0, 'i', info, +VSC_F(g_smf_frag, uint64_t, 0, 'g', info, "N small free smf", "" ) -VSC_F(g_smf_large, uint64_t, 0, 'i', info, +VSC_F(g_smf_large, uint64_t, 0, 'g', info, "N large free smf", "" ) @@ -176,7 +176,7 @@ VSC_F(g_smf_large, uint64_t, 0, 'i', info, #ifdef VSC_DO_VBE -VSC_F(vcls, uint64_t, 0, 'i', debug, +VSC_F(vcls, uint64_t, 0, 'g', debug, "VCL references", "" ) @@ -184,32 +184,32 @@ VSC_F(happy, uint64_t, 0, 'b', info, "Happy health probes", "" ) -VSC_F(bereq_hdrbytes, uint64_t, 0, 'a', info, +VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', info, "Request header bytes", "Total backend request header bytes sent" ) -VSC_F(bereq_bodybytes, uint64_t, 0, 'a', info, +VSC_F(bereq_bodybytes, uint64_t, 0, 'c', info, "Request body bytes", "Total backend request body bytes sent" ) -VSC_F(beresp_hdrbytes, uint64_t, 0, 'a', info, +VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', info, "Response header bytes", "Total backend response header bytes received" ) -VSC_F(beresp_bodybytes, uint64_t, 0, 'a', info, +VSC_F(beresp_bodybytes, uint64_t, 0, 'c', info, "Response body bytes", "Total backend response body bytes received" ) -VSC_F(pipe_hdrbytes, uint64_t, 0, 'a', info, +VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', info, "Pipe request header bytes", "Total request bytes sent for piped sessions" ) -VSC_F(pipe_out, uint64_t, 0, 'a', info, +VSC_F(pipe_out, uint64_t, 0, 'c', info, "Piped bytes to backend", "Total number of bytes forwarded to backend in" " pipe sessions" ) -VSC_F(pipe_in, uint64_t, 0, 'a', info, +VSC_F(pipe_in, uint64_t, 0, 'c', info, "Piped bytes from backend", "Total number of bytes forwarded from backend in" " pipe sessions" From nils.goroll at uplex.de Tue Jan 6 18:50:27 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 19:50:27 +0100 Subject: [master] 452852f Fix implicit cache hit reporting in X-Varnish Message-ID: commit 452852f6fbaaf9db23cd7c0a8884a129ef993ec2 Author: Nils Goroll Date: Tue Jan 6 19:41:51 2015 +0100 Fix implicit cache hit reporting in X-Varnish req->wrk->stats->cache_hit only gets reset when workers go to idle and sum up stats. This additional space-wasting byte-flag will get collapsed with the other space-wasting flags soon, it is just added temporarly to separate commits. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1db9644..20b6022 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -542,6 +542,7 @@ struct req { int disable_esi; uint8_t hash_ignore_busy; uint8_t hash_always_miss; + uint8_t hit; struct sess *sp; struct worker *wrk; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b2e5aef..9255bbd 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -74,7 +74,7 @@ cnt_deliver(struct worker *wrk, struct req *req) ObjGetattr(req->wrk, req->objcore, OA_HEADERS, NULL))); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); - if (req->wrk->stats->cache_hit) + if (req->hit) http_PrintfHeader(req->resp, "X-Varnish: %u %u", VXID(req->vsl->wid), ObjGetXID(wrk, req->objcore)); @@ -364,6 +364,7 @@ cnt_lookup(struct worker *wrk, struct req *req) (void)VRB_Ignore(req);// XXX: handle err } wrk->stats->cache_hit++; + req->hit = 1; req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); case VCL_RET_FETCH: @@ -391,6 +392,7 @@ cnt_lookup(struct worker *wrk, struct req *req) break; case VCL_RET_PASS: wrk->stats->cache_hit++; + req->hit = 1; req->req_step = R_STP_PASS; break; default: @@ -546,6 +548,7 @@ cnt_restart(struct worker *wrk, struct req *req) req->err_code = 0; req->req_step = R_STP_RECV; } + req->hit = 0; return (REQ_FSM_MORE); } diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 910dfac..f8814a1 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -186,6 +186,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->hash_always_miss = 0; req->hash_ignore_busy = 0; + req->hit = 0; if (sp->fd >= 0 && req->doclose != SC_NULL) SES_Close(sp, req->doclose); diff --git a/bin/varnishtest/tests/c00010.vtc b/bin/varnishtest/tests/c00010.vtc index 18e364b..5e8b087 100644 --- a/bin/varnishtest/tests/c00010.vtc +++ b/bin/varnishtest/tests/c00010.vtc @@ -7,9 +7,19 @@ server s1 { rxreq expect req.url == "/foo" txresp -body foobar1 + rxreq + expect req.url == "/pass" + txresp -body foobar12 } -start varnish v1 -vcl+backend { + sub vcl_recv { + if (req.url == "/foo") { + return(hash); + } else { + return(pass); + } + } sub vcl_hit { return(pass); } @@ -22,10 +32,19 @@ client c1 { expect resp.bodylen == 6 expect resp.http.x-varnish == "1001" txreq -url "/foo" + rxresp expect resp.status == 200 expect resp.bodylen == 7 expect resp.http.x-varnish == "1003 1004" + + # a pass following a hit on the same wrk should not be + # reported as a hit + txreq -url "/pass" + rxresp + expect resp.status == 200 + expect resp.bodylen == 8 + expect resp.http.x-varnish == "1005" } client c1 -run From nils.goroll at uplex.de Tue Jan 6 18:56:26 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 19:56:26 +0100 Subject: [master] 17dcc37 Add test for the empty and non-existing varied-upon header resulting in individual cache objects Message-ID: commit 17dcc37859f9dfcbb9a4641f503fe6ffac856668 Author: Nils Goroll Date: Tue Jan 6 19:52:54 2015 +0100 Add test for the empty and non-existing varied-upon header resulting in individual cache objects Outcome of a discussion of the suggestion to treat empty headers like non-existing for Vary processing: https://www.varnish-cache.org/lists/pipermail/varnish-dev/2015-January/008131.html diff --git a/bin/varnishtest/tests/c00004.vtc b/bin/varnishtest/tests/c00004.vtc index 56af641..c4d7ad5 100644 --- a/bin/varnishtest/tests/c00004.vtc +++ b/bin/varnishtest/tests/c00004.vtc @@ -4,14 +4,22 @@ server s1 { rxreq expect req.http.foobar == "1" txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -body "1111\n" + rxreq expect req.http.foobar == "2" txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -body "2222\n" + rxreq expect req.http.foobar == "3" txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -body "3333\n" + rxreq + expect req.http.foobar == txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -body "4444\n" + + rxreq + expect req.http.foobar == "" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 5" -body "5555\n" } -start varnish v1 -vcl+backend {} -start @@ -47,4 +55,17 @@ client c1 { expect resp.http.X-Varnish == "1009 1002" expect resp.http.snafu == "1" + txreq -hdr "Foobar: 1 " + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1010 1002" + expect resp.http.snafu == "1" + + # empty header != no header + txreq -hdr "Foobar: " + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1011" + expect resp.http.snafu == "5" + } -run From nils.goroll at uplex.de Tue Jan 6 18:58:19 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 19:58:19 +0100 Subject: [master] 091d231 Cleanup the seen_methods bitfield when done with a task Message-ID: commit 091d23136ccad43440962af1f657313c54551fda Author: Nils Goroll Date: Tue Jan 6 19:58:12 2015 +0100 Cleanup the seen_methods bitfield when done with a task diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index ee84862..015075e 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -409,6 +409,9 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) assert(wrk->pool == pp); tp->func(wrk, tp->priv); + + /* cleanup for next task */ + wrk->seen_methods = 0; } wrk->pool = NULL; } From nils.goroll at uplex.de Tue Jan 6 19:39:06 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 20:39:06 +0100 Subject: [master] 7d0216d Use a bit field for request flags Message-ID: commit 7d0216de575ac47b03510590d08be1894445bc6c Author: Nils Goroll Date: Tue Jan 6 20:36:57 2015 +0100 Use a bit field for request flags ... by example of the backend object flags diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 20b6022..2e7fa47 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -539,10 +539,10 @@ struct req { int restarts; int esi_level; - int disable_esi; - uint8_t hash_ignore_busy; - uint8_t hash_always_miss; - uint8_t hit; + +#define REQ_FLAG(l, r, w, d) unsigned l:1; +#include "tbl/req_flags.h" +#undef REQ_FLAG struct sess *sp; struct worker *wrk; @@ -565,7 +565,6 @@ struct req { enum sess_close doclose; double d_ttl; - unsigned char wantbody; uint64_t req_bodybytes; /* Parsed req bodybytes */ uint16_t err_code; @@ -596,7 +595,6 @@ struct req { struct SHA256Context *sha256ctx; /* ESI delivery stuff */ - int gzip_resp; ssize_t l_crc; uint32_t crc; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 476b252..7c8ec65 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -412,6 +412,12 @@ pan_req(const struct req *req) pan_busyobj(req->objcore->busyobj); } + VSB_printf(pan_vsp, " flags = {\n"); +#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); +#include "tbl/req_flags.h" +#undef REQ_FLAG + VSB_printf(pan_vsp, " }\n"); + VSB_printf(pan_vsp, "},\n"); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9255bbd..c434253 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -74,7 +74,7 @@ cnt_deliver(struct worker *wrk, struct req *req) ObjGetattr(req->wrk, req->objcore, OA_HEADERS, NULL))); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); - if (req->hit) + if (req->is_hit) http_PrintfHeader(req->resp, "X-Varnish: %u %u", VXID(req->vsl->wid), ObjGetXID(wrk, req->objcore)); @@ -364,7 +364,7 @@ cnt_lookup(struct worker *wrk, struct req *req) (void)VRB_Ignore(req);// XXX: handle err } wrk->stats->cache_hit++; - req->hit = 1; + req->is_hit = 1; req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); case VCL_RET_FETCH: @@ -392,7 +392,7 @@ cnt_lookup(struct worker *wrk, struct req *req) break; case VCL_RET_PASS: wrk->stats->cache_hit++; - req->hit = 1; + req->is_hit = 1; req->req_step = R_STP_PASS; break; default: @@ -548,7 +548,7 @@ cnt_restart(struct worker *wrk, struct req *req) req->err_code = 0; req->req_step = R_STP_RECV; } - req->hit = 0; + req->is_hit = 0; return (REQ_FSM_MORE); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index fe4fea8..b57c4b7 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -562,29 +562,35 @@ VRT_r_bereq_xid(VRT_CTX) return (WS_Printf(ctx->bo->bereq->ws, "%u", VXID(ctx->bo->vsl->wid))); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * req fields + */ -#define REQ_BOOL(hash_var) \ -void \ -VRT_l_req_##hash_var(VRT_CTX, unsigned val) \ -{ \ - \ - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ +#define VREQW0(field) +#define VREQW1(field) \ +void \ +VRT_l_req_##field(VRT_CTX, unsigned a) \ +{ \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ - ctx->req->hash_var = val ? 1 : 0; \ -} \ - \ -unsigned \ -VRT_r_req_##hash_var(VRT_CTX) \ -{ \ - \ - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + ctx->req->field = a ? 1 : 0; \ +} + +#define VREQR0(field) +#define VREQR1(field) \ +unsigned \ +VRT_r_req_##field(VRT_CTX) \ +{ \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ - return(ctx->req->hash_var); \ + return (ctx->req->field); \ } -REQ_BOOL(hash_ignore_busy) -REQ_BOOL(hash_always_miss) +#define REQ_FLAG(l, r, w, d) \ + VREQR##r(l) \ + VREQW##r(l) +#include "tbl/req_flags.h" +#undef REQ_FLAG /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index f8814a1..62cfcf1 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -186,7 +186,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->hash_always_miss = 0; req->hash_ignore_busy = 0; - req->hit = 0; + req->is_hit = 0; if (sp->fd >= 0 && req->doclose != SC_NULL) SES_Close(sp, req->doclose); diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h new file mode 100644 index 0000000..6757d90 --- /dev/null +++ b/include/tbl/req_flags.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2014 Varnish Software 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. + * + */ + +/*lint -save -e525 -e539 */ + +/* lower, vcl_r, vcl_w, doc */ +REQ_FLAG(disable_esi, 0, 0, "") +REQ_FLAG(hash_ignore_busy, 1, 1, "") +REQ_FLAG(hash_always_miss, 1, 1, "") +REQ_FLAG(is_hit, 0, 0, "") +REQ_FLAG(wantbody, 0, 0, "") +REQ_FLAG(gzip_resp, 0, 0, "") +/*lint -restore */ From nils.goroll at uplex.de Tue Jan 6 19:41:51 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 20:41:51 +0100 Subject: [master] 5048ac5 create let functions based on the w bit of the table definition Message-ID: commit 5048ac55d97438620b3f79b158c3671d0194f5d0 Author: Nils Goroll Date: Tue Jan 6 20:41:46 2015 +0100 create let functions based on the w bit of the table definition diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index b57c4b7..4c6f2c6 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -198,7 +198,7 @@ VRT_r_beresp_##field(VRT_CTX) \ #define BO_FLAG(l, r, w, d) \ VBERESPR##r(l) \ - VBERESPW##r(l) + VBERESPW##w(l) #include "tbl/bo_flags.h" #undef BO_FLAG @@ -588,7 +588,7 @@ VRT_r_req_##field(VRT_CTX) \ #define REQ_FLAG(l, r, w, d) \ VREQR##r(l) \ - VREQW##r(l) + VREQW##w(l) #include "tbl/req_flags.h" #undef REQ_FLAG From nils.goroll at uplex.de Tue Jan 6 19:55:56 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 20:55:56 +0100 Subject: [master] a07f032 better formatting for bo flags panic string. remove additional is_prefix Message-ID: commit a07f0329e50a19924be6fcc390c060feac72b014 Author: Nils Goroll Date: Tue Jan 6 20:55:40 2015 +0100 better formatting for bo flags panic string. remove additional is_prefix diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 7c8ec65..d45458e 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -326,9 +326,11 @@ pan_busyobj(const struct busyobj *bo) VSB_printf(pan_vsp, " retries = %d\n", bo->retries); VSB_printf(pan_vsp, " failed = %d\n", bo->vfc->failed); VSB_printf(pan_vsp, " state = %d\n", (int)bo->state); -#define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, " is_" #l "\n"); + VSB_printf(pan_vsp, " flags = {\n"); +#define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, " " #l "\n"); #include "tbl/bo_flags.h" #undef BO_FLAG + VSB_printf(pan_vsp, " }\n"); if (bo->htc != NULL) { VSB_printf(pan_vsp, " bodystatus = %d (%s),\n", From nils.goroll at uplex.de Tue Jan 6 21:41:35 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 06 Jan 2015 22:41:35 +0100 Subject: [master] 468a047 Expose is_hit to VCL as resp.is_hit Message-ID: commit 468a0472fa313dbff69269afc085957642011abc Author: Nils Goroll Date: Tue Jan 6 22:24:21 2015 +0100 Expose is_hit to VCL as resp.is_hit The common method to check obj.hits is racy: While the update to the hits counter happens under a lock, a hit could have happened before the missing request gets to read obj.hits. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2e7fa47..82bf5ed 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -540,7 +540,7 @@ struct req { int restarts; int esi_level; -#define REQ_FLAG(l, r, w, d) unsigned l:1; +#define REQ_FLAG(l, o, r, w, d) unsigned l:1; #include "tbl/req_flags.h" #undef REQ_FLAG diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d45458e..9bd99a7 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -415,7 +415,7 @@ pan_req(const struct req *req) } VSB_printf(pan_vsp, " flags = {\n"); -#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); +#define REQ_FLAG(l, o, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); #include "tbl/req_flags.h" #undef REQ_FLAG VSB_printf(pan_vsp, " }\n"); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 4c6f2c6..5b2e5c2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -566,29 +566,29 @@ VRT_r_bereq_xid(VRT_CTX) * req fields */ -#define VREQW0(field) -#define VREQW1(field) \ +#define VREQW0(obj, field) +#define VREQW1(obj, field) \ void \ -VRT_l_req_##field(VRT_CTX, unsigned a) \ +VRT_l_##obj##_##field(VRT_CTX, unsigned a) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ ctx->req->field = a ? 1 : 0; \ } -#define VREQR0(field) -#define VREQR1(field) \ +#define VREQR0(obj, field) +#define VREQR1(obj, field) \ unsigned \ -VRT_r_req_##field(VRT_CTX) \ +VRT_r_##obj##_##field(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ return (ctx->req->field); \ } -#define REQ_FLAG(l, r, w, d) \ - VREQR##r(l) \ - VREQW##w(l) +#define REQ_FLAG(l, o, r, w, d) \ + VREQR##r(o, l) \ + VREQW##w(o, l) #include "tbl/req_flags.h" #undef REQ_FLAG diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index c428add..19e9f26 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -13,6 +13,11 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.foo = obj.hits; + if (resp.is_hit) { + set resp.http.X-Hit = "yes"; + } else { + set resp.http.X-Hit = "no"; + } } } -start @@ -21,16 +26,19 @@ client c1 { rxresp expect resp.status == 200 expect resp.http.foo == 0 + expect resp.http.X-hit == "no" txreq rxresp expect resp.status == 200 expect resp.http.foo == 1 + expect resp.http.X-hit == "yes" txreq -url /foo rxresp expect resp.status == 200 expect resp.http.foo == 0 + expect resp.http.X-hit == "no" delay .1 txreq @@ -38,4 +46,5 @@ client c1 { expect resp.status == 200 expect resp.http.foo == 2 expect resp.http.bar >= 0.100 + expect resp.http.X-hit == "yes" } -run diff --git a/bin/varnishtest/tests/v00039.vtc b/bin/varnishtest/tests/v00039.vtc index 029e114..c248aa8 100644 --- a/bin/varnishtest/tests/v00039.vtc +++ b/bin/varnishtest/tests/v00039.vtc @@ -13,6 +13,11 @@ varnish v1 \ -vcl+backend { sub vcl_deliver { set resp.http.hits = obj.hits; + if (resp.is_hit) { + set resp.http.X-Hit = "yes"; + } else { + set resp.http.X-Hit = "no"; + } } } -start @@ -23,6 +28,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.hits == 0 + expect resp.http.X-Hit == "no" # This is a hit -> hits == 1 txreq -url "/" -hdr "Bar: 1" @@ -30,6 +36,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.hits == 1 + expect resp.http.X-Hit == "yes" # This is a miss on different vary -> hits == 0 txreq -url "/" -hdr "Bar: 2" @@ -37,6 +44,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 4 expect resp.http.hits == 0 + expect resp.http.X-Hit == "no" # This is a hit -> hits == 1 txreq -url "/" -hdr "Bar: 2" @@ -44,6 +52,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 4 expect resp.http.hits == 1 + expect resp.http.X-Hit == "yes" } -run diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index 6757d90..55f20f7 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -29,11 +29,11 @@ /*lint -save -e525 -e539 */ -/* lower, vcl_r, vcl_w, doc */ -REQ_FLAG(disable_esi, 0, 0, "") -REQ_FLAG(hash_ignore_busy, 1, 1, "") -REQ_FLAG(hash_always_miss, 1, 1, "") -REQ_FLAG(is_hit, 0, 0, "") -REQ_FLAG(wantbody, 0, 0, "") -REQ_FLAG(gzip_resp, 0, 0, "") +/* lower, vcl_obj, vcl_r, vcl_w, doc */ +REQ_FLAG(disable_esi, none, 0, 0, "") +REQ_FLAG(hash_ignore_busy, req, 1, 1, "") +REQ_FLAG(hash_always_miss, req, 1, 1, "") +REQ_FLAG(is_hit, resp, 1, 0, "") +REQ_FLAG(wantbody, none, 0, 0, "") +REQ_FLAG(gzip_resp, none, 0, 0, "") /*lint -restore */ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index e582c0f..699bab3 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -564,8 +564,10 @@ sp_variables = [ 'INT', ( 'hit', 'deliver',), ( ), """ - The count of cache-hits on this object. A value of 0 indicates a - cache miss. + The count of cache-hits on this object. + + NB: obj.hits is not a reliable way to determine cache + misses. See resp.is_hit. """ ), ('obj.http.', @@ -645,6 +647,13 @@ sp_variables = [ The corresponding HTTP header. """ ), + ('resp.is_hit', + 'BOOL', + ( 'deliver',), + ( ), """ + If this response is from a cache hit. + """ + ), ('now', 'TIME', ( 'all',), From nils.goroll at uplex.de Wed Jan 7 10:17:12 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 07 Jan 2015 11:17:12 +0100 Subject: [master] 7192541 Revert "Expose is_hit to VCL as resp.is_hit" Message-ID: commit 7192541d6512340e42ecf2b8d0a6ee1ff5a06029 Author: Nils Goroll Date: Wed Jan 7 10:58:22 2015 +0100 Revert "Expose is_hit to VCL as resp.is_hit" This reverts commit 468a0472fa313dbff69269afc085957642011abc. The next commit will make obj.hits reliable diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 82bf5ed..2e7fa47 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -540,7 +540,7 @@ struct req { int restarts; int esi_level; -#define REQ_FLAG(l, o, r, w, d) unsigned l:1; +#define REQ_FLAG(l, r, w, d) unsigned l:1; #include "tbl/req_flags.h" #undef REQ_FLAG diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 9bd99a7..d45458e 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -415,7 +415,7 @@ pan_req(const struct req *req) } VSB_printf(pan_vsp, " flags = {\n"); -#define REQ_FLAG(l, o, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); +#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(pan_vsp, " " #l ",\n"); #include "tbl/req_flags.h" #undef REQ_FLAG VSB_printf(pan_vsp, " }\n"); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5b2e5c2..4c6f2c6 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -566,29 +566,29 @@ VRT_r_bereq_xid(VRT_CTX) * req fields */ -#define VREQW0(obj, field) -#define VREQW1(obj, field) \ +#define VREQW0(field) +#define VREQW1(field) \ void \ -VRT_l_##obj##_##field(VRT_CTX, unsigned a) \ +VRT_l_req_##field(VRT_CTX, unsigned a) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ ctx->req->field = a ? 1 : 0; \ } -#define VREQR0(obj, field) -#define VREQR1(obj, field) \ +#define VREQR0(field) +#define VREQR1(field) \ unsigned \ -VRT_r_##obj##_##field(VRT_CTX) \ +VRT_r_req_##field(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ return (ctx->req->field); \ } -#define REQ_FLAG(l, o, r, w, d) \ - VREQR##r(o, l) \ - VREQW##w(o, l) +#define REQ_FLAG(l, r, w, d) \ + VREQR##r(l) \ + VREQW##w(l) #include "tbl/req_flags.h" #undef REQ_FLAG diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index 19e9f26..c428add 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -13,11 +13,6 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.foo = obj.hits; - if (resp.is_hit) { - set resp.http.X-Hit = "yes"; - } else { - set resp.http.X-Hit = "no"; - } } } -start @@ -26,19 +21,16 @@ client c1 { rxresp expect resp.status == 200 expect resp.http.foo == 0 - expect resp.http.X-hit == "no" txreq rxresp expect resp.status == 200 expect resp.http.foo == 1 - expect resp.http.X-hit == "yes" txreq -url /foo rxresp expect resp.status == 200 expect resp.http.foo == 0 - expect resp.http.X-hit == "no" delay .1 txreq @@ -46,5 +38,4 @@ client c1 { expect resp.status == 200 expect resp.http.foo == 2 expect resp.http.bar >= 0.100 - expect resp.http.X-hit == "yes" } -run diff --git a/bin/varnishtest/tests/v00039.vtc b/bin/varnishtest/tests/v00039.vtc index c248aa8..029e114 100644 --- a/bin/varnishtest/tests/v00039.vtc +++ b/bin/varnishtest/tests/v00039.vtc @@ -13,11 +13,6 @@ varnish v1 \ -vcl+backend { sub vcl_deliver { set resp.http.hits = obj.hits; - if (resp.is_hit) { - set resp.http.X-Hit = "yes"; - } else { - set resp.http.X-Hit = "no"; - } } } -start @@ -28,7 +23,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.hits == 0 - expect resp.http.X-Hit == "no" # This is a hit -> hits == 1 txreq -url "/" -hdr "Bar: 1" @@ -36,7 +30,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.hits == 1 - expect resp.http.X-Hit == "yes" # This is a miss on different vary -> hits == 0 txreq -url "/" -hdr "Bar: 2" @@ -44,7 +37,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 4 expect resp.http.hits == 0 - expect resp.http.X-Hit == "no" # This is a hit -> hits == 1 txreq -url "/" -hdr "Bar: 2" @@ -52,7 +44,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 4 expect resp.http.hits == 1 - expect resp.http.X-Hit == "yes" } -run diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index 55f20f7..6757d90 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -29,11 +29,11 @@ /*lint -save -e525 -e539 */ -/* lower, vcl_obj, vcl_r, vcl_w, doc */ -REQ_FLAG(disable_esi, none, 0, 0, "") -REQ_FLAG(hash_ignore_busy, req, 1, 1, "") -REQ_FLAG(hash_always_miss, req, 1, 1, "") -REQ_FLAG(is_hit, resp, 1, 0, "") -REQ_FLAG(wantbody, none, 0, 0, "") -REQ_FLAG(gzip_resp, none, 0, 0, "") +/* lower, vcl_r, vcl_w, doc */ +REQ_FLAG(disable_esi, 0, 0, "") +REQ_FLAG(hash_ignore_busy, 1, 1, "") +REQ_FLAG(hash_always_miss, 1, 1, "") +REQ_FLAG(is_hit, 0, 0, "") +REQ_FLAG(wantbody, 0, 0, "") +REQ_FLAG(gzip_resp, 0, 0, "") /*lint -restore */ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 699bab3..e582c0f 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -564,10 +564,8 @@ sp_variables = [ 'INT', ( 'hit', 'deliver',), ( ), """ - The count of cache-hits on this object. - - NB: obj.hits is not a reliable way to determine cache - misses. See resp.is_hit. + The count of cache-hits on this object. A value of 0 indicates a + cache miss. """ ), ('obj.http.', @@ -647,13 +645,6 @@ sp_variables = [ The corresponding HTTP header. """ ), - ('resp.is_hit', - 'BOOL', - ( 'deliver',), - ( ), """ - If this response is from a cache hit. - """ - ), ('now', 'TIME', ( 'all',), From nils.goroll at uplex.de Wed Jan 7 10:17:12 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 07 Jan 2015 11:17:12 +0100 Subject: [master] 382c528 obj.hits == 0 now realiably indicates a non-hit (miss or pass) Message-ID: commit 382c5284d2812137fd336c1bcb3d7e4cde50f62f Author: Nils Goroll Date: Wed Jan 7 11:17:07 2015 +0100 obj.hits == 0 now realiably indicates a non-hit (miss or pass) diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 4c6f2c6..845eb99 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -643,7 +643,7 @@ VRT_r_obj_hits(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); - return (ctx->req->objcore->hits); + return (ctx->req->is_hit ? ctx->req->objcore->hits : 0); } unsigned diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index c428add..7d2c9de 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -7,10 +7,17 @@ server s1 { rxreq expect req.url == "/foo" txresp -body "foo" + rxreq + expect req.url == "/pass" + txresp -body "pass" } -start varnish v1 -vcl+backend { - + sub vcl_recv { + if (req.url == "/pass") { + return (pass); + } + } sub vcl_deliver { set resp.http.foo = obj.hits; } @@ -38,4 +45,9 @@ client c1 { expect resp.status == 200 expect resp.http.foo == 2 expect resp.http.bar >= 0.100 + + txreq -url /pass + rxresp + expect resp.status == 200 + expect resp.http.foo == 0 } -run From phk at FreeBSD.org Wed Jan 7 10:24:56 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 07 Jan 2015 11:24:56 +0100 Subject: [master] 530eaf0 De-generalize resp.backend.ip. In the future backends may not have IP numbers. Message-ID: commit 530eaf02b7ce14086dec995525f55065ab1b13ce Author: Poul-Henning Kamp Date: Wed Jan 7 10:22:55 2015 +0000 De-generalize resp.backend.ip. In the future backends may not have IP numbers. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 4dda66b..226f420 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -480,19 +480,6 @@ vbe_dir_getbody(const struct director *d, struct worker *wrk, return (0); } -static struct suckaddr * __match_proto__(vdi_suckaddr_f) -vbe_dir_suckaddr(const struct director *d, struct worker *wrk, - struct busyobj *bo) -{ - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - - if (bo->htc->vbc != NULL) - return(bo->htc->vbc->addr); - return (NULL); -} - /*--------------------------------------------------------------------*/ void @@ -534,7 +521,6 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, vs->dir.gethdrs = vbe_dir_gethdrs; vs->dir.getbody = vbe_dir_getbody; vs->dir.finish = vbe_dir_finish; - vs->dir.suckaddr = vbe_dir_suckaddr; vs->vrt = t; diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 3a1961a..13a25c9 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -152,16 +152,3 @@ VDI_Healthy(const struct director *d, const struct busyobj *bo) AN(d->healthy); return (d->healthy(d, bo, NULL)); } - -/* Get suckaddr ------------------------------------------------------*/ - -struct suckaddr * -VDI_Suckaddr(const struct director *d, struct worker *wrk, struct busyobj *bo) -{ - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - - AN(d->suckaddr); - return (d->suckaddr(d, wrk, bo)); -} diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index e904686..7941213 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -53,8 +53,6 @@ typedef int vdi_getbody_f(const struct director *, struct worker *, struct busyobj *); typedef void vdi_finish_f(const struct director *, struct worker *, struct busyobj *); -typedef struct suckaddr *vdi_suckaddr_f(const struct director *, - struct worker *, struct busyobj *); struct director { unsigned magic; @@ -67,7 +65,6 @@ struct director { vdi_gethdrs_f *gethdrs; vdi_getbody_f *getbody; vdi_finish_f *finish; - vdi_suckaddr_f *suckaddr; void *priv; }; @@ -79,8 +76,6 @@ void VDI_Finish(const struct director *d, struct worker *wrk, struct busyobj *bo); int VDI_GetFd(const struct director *d, struct worker *wrk, struct busyobj *); int VDI_Healthy(const struct director *, const struct busyobj *); -struct suckaddr *VDI_Suckaddr(const struct director *d, struct worker *wrk, - struct busyobj *bo); void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Init(void); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 845eb99..e4007c2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -305,13 +305,21 @@ VRT_r_beresp_backend_name(VRT_CTX) return (NULL); } +/*-------------------------------------------------------------------- + * Backends do not in general have a IP number (any more) and this + * variable is really not about the backend, but the backend connection. + * XXX: we may need a more general beresp.backend.{details|ident} + */ + VCL_IP VRT_r_beresp_backend_ip(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (VDI_Suckaddr(ctx->bo->director_resp, ctx->bo->wrk, ctx->bo)); + if (ctx->bo->htc != NULL && ctx->bo->htc->vbc != NULL) + return(ctx->bo->htc->vbc->addr); + return (NULL); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Wed Jan 7 10:52:38 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 07 Jan 2015 11:52:38 +0100 Subject: [master] adca4ad Rename dir->getfd() to dir->gethttp1fd() and don't assume that the director has it. Message-ID: commit adca4ad282c71c9bd7c4ca7dfe3594f79065fce9 Author: Poul-Henning Kamp Date: Wed Jan 7 10:51:22 2015 +0000 Rename dir->getfd() to dir->gethttp1fd() and don't assume that the director has it. Make VDI_GetBody() and VDI_Finish() operate on the implied bo->director_resp. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 226f420..64139fb 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -516,7 +516,7 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, vs->dir.priv = vs; vs->dir.name = "simple"; REPLACE(vs->dir.vcl_name, t->vcl_name); - vs->dir.getfd = vbe_dir_getfd; + vs->dir.gethttp1fd = vbe_dir_getfd; vs->dir.healthy = vbe_dir_healthy; vs->dir.gethdrs = vbe_dir_gethdrs; vs->dir.getbody = vbe_dir_getbody; diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 13a25c9..199fe3f 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -43,24 +43,24 @@ /* Resolve director --------------------------------------------------*/ static const struct director * -vdi_resolve(struct worker *wrk, struct busyobj *bo, const struct director *d) +vdi_resolve(struct worker *wrk, struct busyobj *bo) { + const struct director *d; + const struct director *d2; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - if (d == NULL) { - VSLb(bo->vsl, SLT_FetchError, "No backend"); - return (NULL); - } - - while (d != NULL && d->resolve != NULL) { + for (d = bo->director_req; d != NULL && d->resolve != NULL; d = d2) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - d = d->resolve(d, wrk, bo); + d2 = d->resolve(d, wrk, bo); + if (d2 == NULL) + VSLb(bo->vsl, SLT_FetchError, + "Director %s returned no backend", d->vcl_name); } CHECK_OBJ_ORNULL(d, DIRECTOR_MAGIC); if (d == NULL) - VSLb(bo->vsl, SLT_FetchError, "Backend selection failed"); + VSLb(bo->vsl, SLT_FetchError, "No backend"); bo->director_resp = d; return (d); } @@ -76,7 +76,7 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - d = vdi_resolve(wrk, bo, bo->director_req); + d = vdi_resolve(wrk, bo); if (d != NULL) { AN(d->gethdrs); bo->director_state = DIR_S_HDRS; @@ -90,13 +90,15 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo) /* Setup body fetch --------------------------------------------------*/ int -VDI_GetBody(const struct director *d, struct worker *wrk, struct busyobj *bo) +VDI_GetBody(struct worker *wrk, struct busyobj *bo) { + const struct director *d; - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + d = bo->director_resp; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); AZ(d->resolve); AN(d->getbody); @@ -108,13 +110,16 @@ VDI_GetBody(const struct director *d, struct worker *wrk, struct busyobj *bo) /* Finish fetch ------------------------------------------------------*/ void -VDI_Finish(const struct director *d, struct worker *wrk, struct busyobj *bo) +VDI_Finish(struct worker *wrk, struct busyobj *bo) { + const struct director *d; - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + d = bo->director_resp; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + AZ(d->resolve); AN(d->finish); @@ -126,22 +131,22 @@ VDI_Finish(const struct director *d, struct worker *wrk, struct busyobj *bo) /* Get a connection --------------------------------------------------*/ int -VDI_GetFd(const struct director *d, struct worker *wrk, struct busyobj *bo) +VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *bo) { + const struct director *d; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - d = vdi_resolve(wrk, bo, d); - if (d == NULL) + d = vdi_resolve(wrk, bo); + if (d == NULL || d->gethttp1fd == NULL) return (-1); - - AN(d->getfd); - return (d->getfd(d, bo)); + return (d->gethttp1fd(d, bo)); } -/* Check health ------------------------------------------------------ +/* Check health -------------------------------------------------------- + * + * If director has no healthy method, we just assume it is healthy. */ int @@ -149,6 +154,7 @@ VDI_Healthy(const struct director *d, const struct busyobj *bo) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - AN(d->healthy); + if (d->healthy == NULL) + return (1); return (d->healthy(d, bo, NULL)); } diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 7941213..3980356 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -42,7 +42,7 @@ * backends to use. */ -typedef int vdi_getfd_f(const struct director *, struct busyobj *); +typedef int vdi_gethttp1fd_f(const struct director *, struct busyobj *); typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, double *changed); typedef const struct director *vdi_resolve_f(const struct director *, @@ -59,7 +59,7 @@ struct director { #define DIRECTOR_MAGIC 0x3336351d const char *name; char *vcl_name; - vdi_getfd_f *getfd; + vdi_gethttp1fd_f *gethttp1fd; vdi_healthy_f *healthy; vdi_resolve_f *resolve; vdi_gethdrs_f *gethdrs; @@ -70,11 +70,9 @@ struct director { /* cache_director.c */ int VDI_GetHdr(struct worker *wrk, struct busyobj *bo); -int VDI_GetBody(const struct director *d, struct worker *wrk, - struct busyobj *bo); -void VDI_Finish(const struct director *d, struct worker *wrk, - struct busyobj *bo); -int VDI_GetFd(const struct director *d, struct worker *wrk, struct busyobj *); +int VDI_GetBody(struct worker *wrk, struct busyobj *bo); +void VDI_Finish(struct worker *wrk, struct busyobj *bo); +int VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *); int VDI_Healthy(const struct director *, const struct busyobj *); void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Init(void); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d53ce82..e0c6941 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -374,7 +374,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->htc->body_status == BS_ERROR) { bo->doclose = SC_RX_BODY; - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); VSLb(bo->vsl, SLT_Error, "Body cannot be fetched"); assert(bo->director_state == DIR_S_NULL); return (F_STP_ERROR); @@ -419,14 +419,14 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_ABANDON) { bo->doclose = SC_RESP_CLOSE; - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_FAIL); } if (wrk->handling == VCL_RET_RETRY) { bo->doclose = SC_RESP_CLOSE; if (bo->director_state != DIR_S_NULL) - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); if (bo->retries++ < cache_param->max_retries) return (F_STP_RETRY); @@ -596,14 +596,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (VFP_Open(bo->vfc)) { (void)VFP_Error(bo->vfc, "Fetch pipeline failed to open"); bo->doclose = SC_RX_BODY; - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_ERROR); } if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo->vfc, "Could not get storage"); bo->doclose = SC_RX_BODY; - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_ERROR); } @@ -625,7 +625,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); if (bo->htc->body_status != BS_NONE) - AZ(VDI_GetBody(bo->director_resp, bo->wrk, bo)); + AZ(VDI_GetBody(bo->wrk, bo)); assert(bo->refcount >= 1); @@ -649,12 +649,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->state < BOS_STREAM); ObjFreeObj(bo->wrk, bo->fetch_objcore); // XXX: doclose = ? - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_ERROR); } if (bo->vfc->failed) { - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_FAIL); } @@ -667,7 +667,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); VBO_setstate(bo, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); @@ -729,7 +729,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (bo->ims_oc->flags & OC_F_FAILED) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); return (F_STP_FAIL); } @@ -741,7 +741,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); VBO_setstate(bo, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); @@ -796,7 +796,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) bo->doclose = SC_RESP_CLOSE; if (bo->director_state != DIR_S_NULL) - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); if (bo->retries++ < cache_param->max_retries) return (F_STP_RETRY); diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c index 84b45a0..a988139 100644 --- a/bin/varnishd/http1/cache_http1_pipe.c +++ b/bin/varnishd/http1/cache_http1_pipe.c @@ -112,7 +112,7 @@ V1P_Process(struct req *req, struct busyobj *bo) acct_pipe.req = req->acct.req_hdrbytes; req->acct.req_hdrbytes = 0; - fd = VDI_GetFd(bo->director_req, wrk, bo); + fd = VDI_GetHttp1Fd(wrk, bo); if (fd < 0) { pipecharge(req, &acct_pipe, NULL); SES_Close(req->sp, SC_OVERLOAD); @@ -172,7 +172,7 @@ V1P_Process(struct req *req, struct busyobj *bo) pipecharge(req, &acct_pipe, bo->htc->vbc->backend->vsc); SES_Close(req->sp, SC_TX_PIPE); bo->doclose = SC_TX_PIPE; - VDI_Finish(bo->director_resp, bo->wrk, bo); + VDI_Finish(bo->wrk, bo); } /*--------------------------------------------------------------------*/ From nils.goroll at uplex.de Wed Jan 7 11:38:30 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 07 Jan 2015 12:38:30 +0100 Subject: [master] 57ff510 varnishtest: fail inequality comparisons if either side is undef'ed Message-ID: commit 57ff51022a850d23e7c976ac7a48b2b49593014a Author: Nils Goroll Date: Wed Jan 7 12:34:58 2015 +0100 varnishtest: fail inequality comparisons if either side is undef'ed e.g. >= 0.1 should fail for being an invalid comparison diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index 7d2c9de..2772a2e 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -44,7 +44,6 @@ client c1 { rxresp expect resp.status == 200 expect resp.http.foo == 2 - expect resp.http.bar >= 0.100 txreq -url /pass rxresp diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index a3dbff4..25db49a 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -224,18 +224,16 @@ cmd_var_resolve(struct http *hp, char *spec) } else return (spec); hdr = http_find_header(hh, hdr); - if (hdr != NULL) - return (hdr); - return (""); + return (hdr); } static void cmd_http_expect(CMD_ARGS) { struct http *hp; - const char *lhs; + const char *lhs, *clhs; char *cmp; - const char *rhs; + const char *rhs, *crhs; vre_t *vre; const char *error; int erroroffset; @@ -252,14 +250,27 @@ cmd_http_expect(CMD_ARGS) AN(av[2]); AZ(av[3]); lhs = cmd_var_resolve(hp, av[0]); - if (lhs == NULL) - lhs = ""; cmp = av[1]; rhs = cmd_var_resolve(hp, av[2]); - if (rhs == NULL) - rhs = ""; - if (!strcmp(cmp, "==")) { - retval = strcmp(lhs, rhs) == 0; + + clhs = lhs ? lhs : ""; + crhs = rhs ? rhs : ""; + + if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { + vre = VRE_compile(crhs, 0, &error, &erroroffset); + if (vre == NULL) + vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", + error, erroroffset, crhs); + i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); + retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); + VRE_free(&vre); + } else if (!strcmp(cmp, "==")) { + retval = strcmp(clhs, crhs) == 0; + } else if (!strcmp(cmp, "!=")) { + retval = strcmp(clhs, crhs) != 0; + } else if (lhs == NULL || rhs == NULL) { + // fail inequality comparisons if either side is undef'ed + retval = 0; } else if (!strcmp(cmp, "<")) { retval = strcmp(lhs, rhs) < 0; } else if (!strcmp(cmp, "<=")) { @@ -268,24 +279,15 @@ cmd_http_expect(CMD_ARGS) retval = strcmp(lhs, rhs) >= 0; } else if (!strcmp(cmp, ">")) { retval = strcmp(lhs, rhs) > 0; - } else if (!strcmp(cmp, "!=")) { - retval = strcmp(lhs, rhs) != 0; - } else if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { - vre = VRE_compile(rhs, 0, &error, &erroroffset); - if (vre == NULL) - vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", - error, erroroffset, rhs); - i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); - retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); - VRE_free(&vre); } + if (retval == -1) vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) test not implemented", - av[0], lhs, av[1], av[2], rhs); + av[0], clhs, av[1], av[2], crhs); else vtc_log(hp->vl, retval ? 4 : 0, "EXPECT %s (%s) %s \"%s\" %s", - av[0], lhs, cmp, rhs, retval ? "match" : "failed"); + av[0], clhs, cmp, crhs, retval ? "match" : "failed"); } /********************************************************************** From phk at FreeBSD.org Wed Jan 7 13:18:04 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 07 Jan 2015 14:18:04 +0100 Subject: [master] 155f11a Adding the default Host: header is a matter between the backend and V1F, it has nothing to do with the VDI layer. Message-ID: commit 155f11a4ae462d2d866d0500d9b477d459277a9a Author: Poul-Henning Kamp Date: Wed Jan 7 13:17:26 2015 +0000 Adding the default Host: header is a matter between the backend and V1F, it has nothing to do with the VDI layer. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2e7fa47..7016fd7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -717,7 +717,7 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); /* cache_http1_fetch.c [V1F] */ -int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo); +int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host); void V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc); /* cache_http1_fsm.c [HTTP1] */ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 64139fb..70991f0 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -62,19 +62,6 @@ struct vbe_dir { const struct vrt_backend *vrt; }; -/*-------------------------------------------------------------------- - * Create default Host: header for backend request - */ -void -VDI_AddHostHeader(struct http *hp, const struct vbc *vbc) -{ - - CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); - CHECK_OBJ_NOTNULL(vbc->vdis, VDI_SIMPLE_MAGIC); - http_PrintfHeader(hp, - "Host: %s", vbc->vdis->vrt->hosthdr); -} - /*--------------------------------------------------------------------*/ /* Private interface from backend_cfg.c */ @@ -425,10 +412,12 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, struct busyobj *bo) { int i; + struct vbe_dir *vs; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); i = vbe_dir_getfd(d, bo); if (i < 0) { @@ -437,7 +426,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, } AN(bo->htc); - i = V1F_fetch_hdr(wrk, bo); + i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr); /* * If we recycle a backend connection, there is a finite chance * that the backend closed it before we get a request to it. @@ -455,7 +444,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, return (-1); } AN(bo->htc); - i = V1F_fetch_hdr(wrk, bo); + i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr); } if (i != 0) { vbe_dir_finish(d, wrk, bo); diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 199fe3f..3fc4983 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -37,7 +37,6 @@ #include "cache.h" -// #include "cache_backend.h" #include "cache_director.h" /* Resolve director --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 3980356..3bdcb40 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -74,6 +74,5 @@ int VDI_GetBody(struct worker *wrk, struct busyobj *bo); void VDI_Finish(struct worker *wrk, struct busyobj *bo); int VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *); int VDI_Healthy(const struct director *, const struct busyobj *); -void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Init(void); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index ac5448c..bb40205 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -74,7 +74,7 @@ vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l) */ int -V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) +V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) { struct vbc *vc; struct http *hp; @@ -101,8 +101,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) * header if one is necessary. This cannot be done in the VCL * because the backend may be chosen by a director. */ - if (!http_GetHdr(bo->bereq, H_Host, NULL)) - VDI_AddHostHeader(bo->bereq, vc); + if (!http_GetHdr(bo->bereq, H_Host, NULL) && def_host != NULL) + http_PrintfHeader(hp, "Host: %s", def_host); if (bo->req != NULL && bo->req->req_body_status == REQ_BODY_WITHOUT_LEN) { From phk at FreeBSD.org Wed Jan 7 14:08:31 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 07 Jan 2015 15:08:31 +0100 Subject: [master] 8c090be Put V1P(ipe) processing firmly below VBE, and access it through VDI. Message-ID: commit 8c090be85176f242a60f2c9069951ec4d218fa7b Author: Poul-Henning Kamp Date: Wed Jan 7 14:07:55 2015 +0000 Put V1P(ipe) processing firmly below VBE, and access it through VDI. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7016fd7..e32f780 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -731,7 +731,7 @@ void V1D_Deliver(struct req *, struct busyobj *); /* cache_http1_pipe.c */ void V1P_Init(void); -void V1P_Process(struct req *req, struct busyobj *bo); +void V1P_Process(struct req *req, struct busyobj *bo, int fd); /* cache_req_body.c */ int VRB_Ignore(struct req *req); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 70991f0..f2d4f8f 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -488,6 +488,19 @@ VRT_fini_vbe(VRT_CTX, struct director *d) d->priv = NULL; } +static void +vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) +{ + int i; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + i = vbe_dir_getfd(d, bo); + V1P_Process(req, bo, i); + vbe_dir_finish(d, bo->wrk, bo); +} + void VRT_init_vbe(VRT_CTX, struct director **bp, int idx, const void *priv) @@ -505,7 +518,7 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, vs->dir.priv = vs; vs->dir.name = "simple"; REPLACE(vs->dir.vcl_name, t->vcl_name); - vs->dir.gethttp1fd = vbe_dir_getfd; + vs->dir.http1pipe = vbe_dir_http1pipe; vs->dir.healthy = vbe_dir_healthy; vs->dir.gethdrs = vbe_dir_gethdrs; vs->dir.getbody = vbe_dir_getbody; diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 3fc4983..962aa9d 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -130,17 +130,18 @@ VDI_Finish(struct worker *wrk, struct busyobj *bo) /* Get a connection --------------------------------------------------*/ int -VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *bo) +VDI_Http1Pipe(struct req *req, struct busyobj *bo) { const struct director *d; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - d = vdi_resolve(wrk, bo); - if (d == NULL || d->gethttp1fd == NULL) + d = vdi_resolve(req->wrk, bo); + if (d == NULL || d->http1pipe == NULL) return (-1); - return (d->gethttp1fd(d, bo)); + d->http1pipe(d, req, bo); + return (0); } /* Check health -------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 3bdcb40..71fa530 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -42,11 +42,13 @@ * backends to use. */ -typedef int vdi_gethttp1fd_f(const struct director *, struct busyobj *); + typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, double *changed); + typedef const struct director *vdi_resolve_f(const struct director *, struct worker *, struct busyobj *); + typedef int vdi_gethdrs_f(const struct director *, struct worker *, struct busyobj *); typedef int vdi_getbody_f(const struct director *, struct worker *, @@ -54,12 +56,15 @@ typedef int vdi_getbody_f(const struct director *, struct worker *, typedef void vdi_finish_f(const struct director *, struct worker *, struct busyobj *); +typedef void vdi_http1pipe_f(const struct director *, struct req *, + struct busyobj *); + struct director { unsigned magic; #define DIRECTOR_MAGIC 0x3336351d const char *name; char *vcl_name; - vdi_gethttp1fd_f *gethttp1fd; + vdi_http1pipe_f *http1pipe; vdi_healthy_f *healthy; vdi_resolve_f *resolve; vdi_gethdrs_f *gethdrs; @@ -69,10 +74,14 @@ struct director { }; /* cache_director.c */ + int VDI_GetHdr(struct worker *wrk, struct busyobj *bo); int VDI_GetBody(struct worker *wrk, struct busyobj *bo); void VDI_Finish(struct worker *wrk, struct busyobj *bo); -int VDI_GetHttp1Fd(struct worker *wrk, struct busyobj *); + +int VDI_Http1Pipe(struct req *, struct busyobj *); + int VDI_Healthy(const struct director *, const struct busyobj *); + void VBE_Init(void); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c434253..3e1e9d0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -43,6 +43,7 @@ #include #include "cache.h" +#include "cache_director.h" #include "hash/hash_slinger.h" #include "vcl.h" @@ -516,7 +517,8 @@ cnt_pipe(struct worker *wrk, struct req *req) INCOMPL(); assert(wrk->handling == VCL_RET_PIPE); - V1P_Process(req, bo); + if (VDI_Http1Pipe(req, bo) < 0) + VSLb(bo->vsl, SLT_VCL_Error, "Backend does not support pipe"); http_Teardown(bo->bereq); VBO_DerefBusyObj(wrk, &bo); THR_SetBusyobj(NULL); diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c index a988139..ac1fb6e 100644 --- a/bin/varnishd/http1/cache_http1_pipe.c +++ b/bin/varnishd/http1/cache_http1_pipe.c @@ -93,11 +93,11 @@ pipecharge(struct req *req, const struct acct_pipe *a, struct VSC_C_vbe *b) } void -V1P_Process(struct req *req, struct busyobj *bo) +V1P_Process(struct req *req, struct busyobj *bo, int fd) { struct worker *wrk; struct pollfd fds[2]; - int i, fd; + int i; struct acct_pipe acct_pipe; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -112,7 +112,6 @@ V1P_Process(struct req *req, struct busyobj *bo) acct_pipe.req = req->acct.req_hdrbytes; req->acct.req_hdrbytes = 0; - fd = VDI_GetHttp1Fd(wrk, bo); if (fd < 0) { pipecharge(req, &acct_pipe, NULL); SES_Close(req->sp, SC_OVERLOAD); @@ -172,7 +171,6 @@ V1P_Process(struct req *req, struct busyobj *bo) pipecharge(req, &acct_pipe, bo->htc->vbc->backend->vsc); SES_Close(req->sp, SC_TX_PIPE); bo->doclose = SC_TX_PIPE; - VDI_Finish(bo->wrk, bo); } /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Wed Jan 7 14:27:57 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 07 Jan 2015 15:27:57 +0100 Subject: [master] 339c88c Update schema definition Message-ID: commit 339c88cd004bb9ba47f6689d67759735f1975ece Author: Federico G. Schwindt Date: Wed Jan 7 09:14:41 2015 +0000 Update schema definition diff --git a/bin/varnishstat/varnishstat.xsd b/bin/varnishstat/varnishstat.xsd index e9c5f3c..f5f14aa 100644 --- a/bin/varnishstat/varnishstat.xsd +++ b/bin/varnishstat/varnishstat.xsd @@ -6,8 +6,13 @@ + + + From fgsch at lodoss.net Wed Jan 7 14:27:57 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 07 Jan 2015 15:27:57 +0100 Subject: [master] f8d8c89 Indent Message-ID: commit f8d8c89492b69f31d44e91aba957243ddd8c5585 Author: Federico G. Schwindt Date: Wed Jan 7 09:17:37 2015 +0000 Indent diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index f5153b4..7f00317 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -104,7 +104,10 @@ do_json_cb(void *priv, const struct VSC_point * const pt) val = *(const volatile uint64_t*)pt->ptr; sec = pt->section; - if (*jp) *jp = 0; else printf(",\n"); + if (*jp) + *jp = 0; + else + printf(",\n"); printf("\t\""); /* build the JSON key name. */ @@ -113,19 +116,17 @@ do_json_cb(void *priv, const struct VSC_point * const pt) if (sec->fantom->ident[0]) printf("%s.", sec->fantom->ident); printf("%s\": {", pt->desc->name); - - if (strcmp(sec->fantom->type, "")) printf("\"type\": \"%s\", ", - sec->fantom->type); - if (strcmp(sec->fantom->ident, "")) printf("\"ident\": \"%s\", ", - sec->fantom->ident); - + if (strcmp(sec->fantom->type, "")) + printf("\"type\": \"%s\", ", sec->fantom->type); + if (strcmp(sec->fantom->ident, "")) + printf("\"ident\": \"%s\", ", sec->fantom->ident); printf("\"value\": %ju, ", (uintmax_t)val); - printf("\"flag\": \"%c\", ", pt->desc->flag); printf("\"description\": \"%s\"", pt->desc->sdesc); printf("}"); - if (*jp) printf("\n"); + if (*jp) + printf("\n"); return (0); } @@ -325,12 +326,12 @@ main(int argc, char * const *argv) do_once(vd, VSC_Main(vd, NULL)); else if (f_list) list_fields(vd); - else { + else assert(0); - } - if (!do_repeat) break; + if (!do_repeat) + break; - // end of output block marker. + /* end of output block marker. */ printf("\n"); (void)usleep(delay * 1e6); From fgsch at lodoss.net Wed Jan 7 14:27:57 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 07 Jan 2015 15:27:57 +0100 Subject: [master] 99cc7a7 Sort options and remove undocumented alias Message-ID: commit 99cc7a7c9da57c770365461116f78e7f71c83148 Author: Federico G. Schwindt Date: Wed Jan 7 09:31:07 2015 +0000 Sort options and remove undocumented alias diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 00c4dac..bea41e2 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -867,6 +867,10 @@ handle_keypress(int ch) if (page_start + l_points < n_ptarray - 1) page_start += l_points; break; + case 'd': + hide_unseen = 1 - hide_unseen; + rebuild = 1; + break; case 'g': current = 0; page_start = 0; @@ -875,10 +879,6 @@ handle_keypress(int ch) current = n_ptarray - 1; page_start = current - l_points + 1; break; - case 'd': - hide_unseen = 1 - hide_unseen; - rebuild = 1; - break; case 'v': verbosity++; if (VSC_LevelDesc(verbosity) == NULL) @@ -886,7 +886,6 @@ handle_keypress(int ch) rebuild = 1; break; case 'q': - case 'Q': keep_running = 0; return; case '\003': /* Ctrl-C */ From nils.goroll at uplex.de Wed Jan 7 15:53:43 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 07 Jan 2015 16:53:43 +0100 Subject: [master] 0302e16 Expire superseded objects also if they are no IMS/INM candidates Message-ID: commit 0302e16e8888d9213931077b9b331f72dcc018b6 Author: Nils Goroll Date: Wed Jan 7 16:53:17 2015 +0100 Expire superseded objects also if they are no IMS/INM candidates diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index e0c6941..8fca585 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -192,7 +192,8 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) http_CopyHome(bo->bereq0); } - if (bo->ims_oc != NULL) { + if (bo->ims_oc != NULL && + ObjCheckFlag(bo->wrk, bo->ims_oc, OF_IMSCAND)) { q = HTTP_GetHdrPack(bo->wrk, bo->ims_oc, H_Last_Modified); if (q != NULL) http_PrintfHeader(bo->bereq0, @@ -974,7 +975,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo->fetch_objcore = oc; AZ(bo->ims_oc); - if (oldoc != NULL && ObjCheckFlag(req->wrk, oldoc, OF_IMSCAND)) { + if (oldoc != NULL) { assert(oldoc->refcnt > 0); HSH_Ref(oldoc); bo->ims_oc = oldoc; diff --git a/bin/varnishtest/tests/c00058.vtc b/bin/varnishtest/tests/c00058.vtc index 440bbf3..8c9940b 100644 --- a/bin/varnishtest/tests/c00058.vtc +++ b/bin/varnishtest/tests/c00058.vtc @@ -22,7 +22,11 @@ client c1 { expect resp.bodylen == 3 delay 1 +} -run + +varnish v1 -expect n_object == 1 +client c1 { # We still get old object txreq rxresp @@ -37,3 +41,6 @@ client c1 { rxresp expect resp.bodylen == 6 } -run + +# and the old one has got superseded +varnish v1 -expect n_object == 1 From fgsch at lodoss.net Wed Jan 7 23:26:48 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 08 Jan 2015 00:26:48 +0100 Subject: [master] e39ac61 Bump serial Message-ID: commit e39ac6197d10c3691772952bdd891a7d8e987ac1 Author: Federico G. Schwindt Date: Wed Jan 7 23:23:24 2015 +0000 Bump serial Forgotten when compatibility for autoconf < 2.63b was added. diff --git a/varnish.m4 b/varnish.m4 index 504b658..e0eff8c 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -1,5 +1,5 @@ # varnish.m4 - Macros to locate Varnish header files. -*- Autoconf -*- -# serial 2 (varnish-4.0) +# serial 3 (varnish-4.0) # Copyright (c) 2013-2014 Varnish Software AS # All rights reserved. From fgsch at lodoss.net Thu Jan 8 03:39:53 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 08 Jan 2015 04:39:53 +0100 Subject: [master] a7ee2b7 Sort options, fix spelling and update formats Message-ID: commit a7ee2b724aa567e8e0c9133a264e0351a3d5c1c1 Author: Federico G. Schwindt Date: Thu Jan 8 03:39:05 2015 +0000 Sort options, fix spelling and update formats diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 8940d80..b8b5ef8 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -65,7 +65,7 @@ CURSES MODE =========== When neither -1, -j or -x options are given, the application starts up -in curses mode. This shows a continously updated view of the counter +in curses mode. This shows a continuously updated view of the counter values, along with their description. The top area shows process uptime information. @@ -119,17 +119,17 @@ The following keys control the interactive display: or Navigate the counter list one page down. + + Toggle between showing and hiding unseen counters. Unseen + counters are those that has been zero for the entire runtime + of varnishstat. Defaults to hide unseen counters. + Go to the top of the counter list. Go to the bottom of the counter list. - - Toggle between showing and hiding unseen counters. Unseen - counters are those that has been zero for the entire runtime - of varnishstat. Defaults to hide unseen counters. - Cycle through the verbosity levels. Defaults to only showing informational counters. @@ -145,11 +145,17 @@ XML Output When using the -x option, the output is:: - - FIELD NAME - FIELD VALUE - FIELD DESCRIPTION - + + + FIELD TYPE + FIELD IDENT + FIELD NAME + FIELD VALUE + FIELD FORMAT + FIELD DESCRIPTION + + [..] + JSON OUTPUT =========== @@ -158,24 +164,15 @@ With -j the output format is:: { "timestamp": "YYYY-MM-DDTHH:mm:SS", - "client_conn": { - "value": 0, "flag": "a", - "description": "Client connections accepted" - }, - "client_drop": { - "value": 0, "flag": "a", - "description": "Connection dropped, no sess/wrk" - }, - "LCK.backend.creat": { - "type": "LCK", "ident": "backend", "value": 1, - "flag": "a", "description": "Created locks" - }, + "FIELD NAME": {"type": "FIELD TYPE", "ident": "FIELD IDENT", "value": FIELD VALUE, "flag": "FIELD FORMAT", "description": "FIELD DESCRIPTION"}, [..] } -Timestamp is the time when the report was generated by varnishstat. +Type and ident are optional. Timestamp is the time when the report was +generated by varnishstat. -Repeated output with -1, -x or -j will have a single empty line (\\n) between each block of output. +Repeated output with -1, -x or -j will have a single empty line (\\n) +between each block of output. SEE ALSO From phk at FreeBSD.org Fri Jan 9 14:54:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 09 Jan 2015 15:54:29 +0100 Subject: [master] 22600aa Add an official VSA_Clone() function. Message-ID: commit 22600aac910468a646f3f529d51f30649b5fc730 Author: Poul-Henning Kamp Date: Thu Jan 8 07:27:01 2015 +0000 Add an official VSA_Clone() function. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index db45f75..432ff05 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -155,21 +155,6 @@ VBE_DropRefConn(struct backend *b, const struct acct_bereq *acct_bereq) } /*-------------------------------------------------------------------- - * See lib/libvcc/vcc_backend.c::emit_sockaddr() - */ - -static void -copy_sockaddr(struct suckaddr **sa, const struct suckaddr *src) -{ - - assert(VSA_Sane(src)); - *sa = calloc(1, vsa_suckaddr_len); - XXXAN(*sa); - memcpy(*sa, src, vsa_suckaddr_len); - assert(VSA_Sane(*sa)); -} - -/*-------------------------------------------------------------------- * Add a backend/director instance when loading a VCL. * If an existing backend is matched, grab a refcount and return. * Else create a new backend structure with reference initialized to one. @@ -232,9 +217,9 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) * Copy over the sockaddrs */ if (vb->ipv4_suckaddr != NULL) - copy_sockaddr(&b->ipv4, vb->ipv4_suckaddr); + b->ipv4 = VSA_Clone(vb->ipv4_suckaddr); if (vb->ipv6_suckaddr != NULL) - copy_sockaddr(&b->ipv6, vb->ipv6_suckaddr); + b->ipv6 = VSA_Clone(vb->ipv6_suckaddr); assert(b->ipv4 != NULL || b->ipv6 != NULL); diff --git a/include/vsa.h b/include/vsa.h index 26f6419..8496278 100644 --- a/include/vsa.h +++ b/include/vsa.h @@ -37,6 +37,7 @@ int VSA_Sane(const struct suckaddr *); socklen_t VSA_Len(const struct suckaddr *); unsigned VSA_Port(const struct suckaddr *); int VSA_Compare(const struct suckaddr *, const struct suckaddr *); +struct suckaddr *VSA_Clone(const struct suckaddr *sua); const struct sockaddr *VSA_Get_Sockaddr(const struct suckaddr *, socklen_t *sl); diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index c2838d6..7057487 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -323,6 +323,18 @@ VSA_Compare(const struct suckaddr *sua1, const struct suckaddr *sua2) return (memcmp(sua1, sua2, vsa_suckaddr_len)); } +struct suckaddr * +VSA_Clone(const struct suckaddr *sua) +{ + struct suckaddr *sua2; + + assert(VSA_Sane(sua)); + sua2 = calloc(1, vsa_suckaddr_len); + XXXAN(sua2); + memcpy(sua2, sua, vsa_suckaddr_len); + return (sua2); +} + unsigned VSA_Port(const struct suckaddr *sua) { From phk at FreeBSD.org Fri Jan 9 14:54:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 09 Jan 2015 15:54:29 +0100 Subject: [master] 356144b Use precise argument type Message-ID: commit 356144b7d9bccc909f3128cf9b096d93a356c9ad Author: Poul-Henning Kamp Date: Thu Jan 8 07:01:03 2015 +0000 Use precise argument type diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index f2d4f8f..a062a48 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -503,14 +503,12 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) void VRT_init_vbe(VRT_CTX, struct director **bp, int idx, - const void *priv) + const struct vrt_backend *t) { - const struct vrt_backend *t; struct vbe_dir *vs; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - t = priv; ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC); XXXAN(vs); diff --git a/include/vrt.h b/include/vrt.h index ff3e996..f9f77ba 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -225,7 +225,7 @@ void VRT_Rollback(VRT_CTX, const struct http *); void VRT_synth_page(VRT_CTX, const char *, ...); /* Backend related */ -void VRT_init_vbe(VRT_CTX, struct director **, int idx, const void *priv); +void VRT_init_vbe(VRT_CTX, struct director **, int idx, const struct vrt_backend *); void VRT_fini_vbe(VRT_CTX, struct director *); /* Suckaddr related */ From fgsch at lodoss.net Sat Jan 10 09:31:21 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 10 Jan 2015 10:31:21 +0100 Subject: [master] a6ad0ea Update varnish-counters(7) Message-ID: commit a6ad0ea2da6647a73986cee927a5187976c5d423 Author: Federico G. Schwindt Date: Sat Jan 10 00:46:00 2015 +0000 Update varnish-counters(7) This manpage is auto-generated. Remove author, date and whatnot, it doesn't make sense here. diff --git a/man/vsc2rst.c b/man/vsc2rst.c index 96500bf..f25d2e1 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -55,11 +55,6 @@ int main(int argc, char **argv) P("---------------------------------"); P("Varnish counter field definitions"); P("---------------------------------"); - - P(":Author: Tollef Fog Heen"); - P(":Date: 2011-09-20"); - P(":Version: 1.0"); - P(":Manual section: 7"); P(""); P("COUNTER LEVELS"); From phk at FreeBSD.org Mon Jan 12 09:21:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 10:21:15 +0100 Subject: [master] a36ad63 Move the cache_waiter stuff from cache.h to waiter.h Message-ID: commit a36ad636d5f614c6f361541e4f39cd092a9f9a75 Author: Poul-Henning Kamp Date: Mon Jan 12 09:10:57 2015 +0000 Move the cache_waiter stuff from cache.h to waiter.h diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e32f780..0f64145 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1063,12 +1063,6 @@ void ESI_DeliverChild(struct req *, struct busyobj *); /* cache_vrt_vmod.c */ void VMOD_Init(void); -/* cache_waiter.c */ -void WAIT_Enter(struct sess *sp); -void WAIT_Init(void); -const char *WAIT_GetName(void); -void WAIT_Write_Session(struct sess *sp, int fd); - /* cache_wrk.c */ void WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index a062a48..14dcf9f 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -503,7 +503,7 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) void VRT_init_vbe(VRT_CTX, struct director **bp, int idx, - const struct vrt_backend *t) + const struct vrt_backend *t) { struct vbe_dir *vs; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d45458e..028f75c 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -47,6 +47,7 @@ #include "cache_backend.h" #include "storage/storage.h" #include "vcl.h" +#include "waiter/waiter.h" /* * The panic string is constructed in memory, then copied to the diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 62cfcf1..1f663ec 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -44,6 +44,7 @@ #include "vcl.h" #include "vtcp.h" #include "vtim.h" +#include "waiter/waiter.h" /*---------------------------------------------------------------------- * Collect a request from the client. diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 5e8e56b..410aa02 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -41,6 +41,12 @@ struct waiter { waiter_pass_f *pass; }; +/* cache_waiter.c */ +void WAIT_Enter(struct sess *sp); +void WAIT_Init(void); +const char *WAIT_GetName(void); +void WAIT_Write_Session(struct sess *sp, int fd); + /* mgt_waiter.c */ extern struct waiter const * waiter; int WAIT_tweak_waiter(struct vsb *vsb, const char *arg); From phk at FreeBSD.org Mon Jan 12 09:21:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 10:21:15 +0100 Subject: [master] eb65a57 Start weaning waiters off sessions. Message-ID: commit eb65a57440c544f530f8b0f2cffe2badea45d674 Author: Poul-Henning Kamp Date: Mon Jan 12 09:20:56 2015 +0000 Start weaning waiters off sessions. diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 1f663ec..032905c 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -111,7 +111,13 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) if (when < now || tmo == 0) { wrk->stats->sess_herd++; SES_ReleaseReq(req); - WAIT_Enter(sp); + if (VTCP_nonblocking(sp->fd)) + SES_Close(sp, SC_REM_CLOSE); + else if (WAIT_Enter(sp)) { + VSC_C_main->sess_pipe_overflow++; + SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, + NAN); + } return (REQ_FSM_DONE); } } else { diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index d14e21b..2ed1904 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -38,8 +38,6 @@ #include "waiter/waiter.h" -#include "vtcp.h" - static void *waiter_priv; const char * @@ -63,31 +61,27 @@ WAIT_Init(void) waiter_priv = waiter->init(); } -void +int WAIT_Enter(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); assert(sp->fd >= 0); - /* - * Set nonblocking in the worker-thread, before passing to the - * acceptor thread, to reduce syscall density of the latter. - */ - if (VTCP_nonblocking(sp->fd)) - SES_Close(sp, SC_REM_CLOSE); - waiter->pass(waiter_priv, sp); + return (waiter->pass(waiter_priv, sp)); } -void +/* + * We do not make sp a const, in order to hint that we actually do take + * control of it. + */ +int __match_proto__() WAIT_Write_Session(struct sess *sp, int fd) { ssize_t written; written = write(fd, &sp, sizeof sp); - if (written != sizeof sp && (errno == EAGAIN || errno == EWOULDBLOCK)) { - VSC_C_main->sess_pipe_overflow++; - SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); - return; - } + if (written != sizeof sp && (errno == EAGAIN || errno == EWOULDBLOCK)) + return (-1); assert (written == sizeof sp); + return (0); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index ea875e7..b907bbe 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -219,14 +219,14 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ -static void +static int vwe_pass(void *priv, struct sess *sp) { struct vwe *vwe; CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC); - WAIT_Write_Session(sp, vwe->pipes[1]); + return (WAIT_Write_Session(sp, vwe->pipes[1])); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 68f7fba..86efe68 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -215,14 +215,14 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ -static void +static int vwk_pass(void *priv, struct sess *sp) { struct vwk *vwk; CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); - WAIT_Write_Session(sp, vwk->pipes[1]); + return (WAIT_Write_Session(sp, vwk->pipes[1])); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index de8fd58..dbec205 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -192,14 +192,14 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ -static void +static int vwp_poll_pass(void *priv, struct sess *sp) { struct vwp *vwp; CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); - WAIT_Write_Session(sp, vwp->pipes[1]); + return (WAIT_Write_Session(sp, vwp->pipes[1])); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index a3bd96d..2cede4b 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -239,7 +239,7 @@ vws_thread(void *priv) /*--------------------------------------------------------------------*/ -static void +static int vws_pass(void *priv, struct sess *sp) { int r; @@ -247,12 +247,10 @@ vws_pass(void *priv, struct sess *sp) CAST_OBJ_NOTNULL(vws, priv, VWS_MAGIC); r = port_send(vws->dport, 0, TRUST_ME(sp)); - if (r == -1 && errno == EAGAIN) { - VSC_C_main->sess_pipe_overflow++; - SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); - return; - } + if (r == -1 && errno == EAGAIN) + return (-1); AZ(r); + return (0); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 410aa02..4e2e079 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -31,7 +31,7 @@ struct sess; typedef void* waiter_init_f(void); -typedef void waiter_pass_f(void *priv, struct sess *); +typedef int waiter_pass_f(void *priv, struct sess *); #define WAITER_DEFAULT "platform dependent" @@ -42,10 +42,10 @@ struct waiter { }; /* cache_waiter.c */ -void WAIT_Enter(struct sess *sp); +int WAIT_Enter(struct sess *sp); void WAIT_Init(void); const char *WAIT_GetName(void); -void WAIT_Write_Session(struct sess *sp, int fd); +int WAIT_Write_Session(struct sess *sp, int fd); /* mgt_waiter.c */ extern struct waiter const * waiter; From phk at FreeBSD.org Mon Jan 12 09:52:08 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 10:52:08 +0100 Subject: [master] 917566c Pass a (dummy) handler argument into waiter-instantiation Message-ID: commit 917566c170694aa015b9dda6d58de28c52899ddb Author: Poul-Henning Kamp Date: Mon Jan 12 09:28:15 2015 +0000 Pass a (dummy) handler argument into waiter-instantiation diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 880f7cf..67e02ee 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -211,7 +211,7 @@ child_main(void) Lck_New(&vxid_lock, lck_vxid); - WAIT_Init(); + WAIT_Init(NULL); PAN_Init(); CLI_Init(); VFP_Init(); diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 2ed1904..ca32433 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -51,14 +51,14 @@ WAIT_GetName(void) } void -WAIT_Init(void) +WAIT_Init(waiter_handle_f *func) { AN(waiter); AN(waiter->name); AN(waiter->init); AN(waiter->pass); - waiter_priv = waiter->init(); + waiter_priv = waiter->init(func); } int diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index b907bbe..28d113d 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -232,10 +232,11 @@ vwe_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ static void * -vwe_init(void) +vwe_init(waiter_handle_f *func) { struct vwe *vwe; + (void)func; ALLOC_OBJ(vwe, VWE_MAGIC); AN(vwe); VTAILQ_INIT(&vwe->sesshead); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 86efe68..4214eb9 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -228,10 +228,11 @@ vwk_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ static void * -vwk_init(void) +vwk_init(waiter_handle_f *func) { struct vwk *vwk; + (void)func; ALLOC_OBJ(vwk, VWK_MAGIC); AN(vwk); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index dbec205..96f37cd 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -205,10 +205,11 @@ vwp_poll_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ static void * -vwp_poll_init(void) +vwp_poll_init(waiter_handle_f *func) { struct vwp *vwp; + (void)func; ALLOC_OBJ(vwp, VWP_MAGIC); AN(vwp); VTAILQ_INIT(&vwp->sesshead); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 2cede4b..fd397ac 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -256,10 +256,11 @@ vws_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ static void * -vws_init(void) +vws_init(waiter_handle_f *func) { struct vws *vws; + (void)func ALLOC_OBJ(vws, VWS_MAGIC); AN(vws); VTAILQ_INIT(&vws->sesshead); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 4e2e079..d01b4fd 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -30,7 +30,14 @@ struct sess; -typedef void* waiter_init_f(void); +enum wait_event { + WAITER_REMCLOSE, + WAITER_TIMEOUT, + WAITER_ACTION +}; + +typedef void waiter_handle_f(void *ptr, int fd, enum wait_event); +typedef void* waiter_init_f(waiter_handle_f *); typedef int waiter_pass_f(void *priv, struct sess *); #define WAITER_DEFAULT "platform dependent" @@ -43,7 +50,7 @@ struct waiter { /* cache_waiter.c */ int WAIT_Enter(struct sess *sp); -void WAIT_Init(void); +void WAIT_Init(waiter_handle_f *); const char *WAIT_GetName(void); int WAIT_Write_Session(struct sess *sp, int fd); From phk at FreeBSD.org Mon Jan 12 09:52:08 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 10:52:08 +0100 Subject: [master] df7a865 Pass the handling function (SES_Handle) as param to WAIT_Init() and call back into that from the waiters. Message-ID: commit df7a86572663095bd8b74a057cc63f430f888a2d Author: Poul-Henning Kamp Date: Mon Jan 12 09:51:33 2015 +0000 Pass the handling function (SES_Handle) as param to WAIT_Init() and call back into that from the waiters. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0f64145..1e63b8d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -975,7 +975,6 @@ struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no); void SES_DeletePool(struct sesspool *sp); int SES_ScheduleReq(struct req *); struct req *SES_GetReq(const struct worker *, struct sess *); -void SES_Handle(struct sess *sp, double now); void SES_ReleaseReq(struct req *); pool_func_t SES_pool_accept_task; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 67e02ee..2868fd4 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -211,7 +211,7 @@ child_main(void) Lck_New(&vxid_lock, lck_vxid); - WAIT_Init(NULL); + WAIT_Init(SES_Handle); PAN_Init(); CLI_Init(); VFP_Init(); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 60c893e..de78982 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -245,19 +245,34 @@ SES_ScheduleReq(struct req *req) * Handle a session (from waiter) */ -void -SES_Handle(struct sess *sp, double now) +void __match_proto__(waiter_handle_f) +SES_Handle(void *ptr, int fd, enum wait_event ev, double now) { + struct sess *sp; struct sesspool *pp; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - pp = sp->sesspool; - CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); - AN(pp->pool); - sp->task.func = ses_sess_pool_task; - sp->task.priv = sp; - if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) - SES_Delete(sp, SC_OVERLOAD, now); + CAST_OBJ_NOTNULL(sp, ptr, SESS_MAGIC); + (void)fd; + + switch (ev) { + case WAITER_TIMEOUT: + SES_Delete(sp, SC_RX_TIMEOUT, now); + break; + case WAITER_REMCLOSE: + SES_Delete(sp, SC_REM_CLOSE, now); + break; + case WAITER_ACTION: + pp = sp->sesspool; + CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); + AN(pp->pool); + sp->task.func = ses_sess_pool_task; + sp->task.priv = sp; + if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) + SES_Delete(sp, SC_OVERLOAD, now); + break; + default: + WRONG("Wrong event in SES_Handle"); + } } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 28d113d..6609677 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -59,6 +59,8 @@ struct vwe { pthread_t timer_thread; int epfd; + waiter_handle_f *func + VTAILQ_HEAD(,sess) sesshead; int pipes[2]; int timer_pipes[2]; @@ -130,16 +132,16 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) CAST_OBJ_NOTNULL(sp, ep->data.ptr, SESS_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - SES_Handle(sp, now); + vwe->func(sp, sp->fd, WAITER_ACTION, now) } else if (ep->events & EPOLLERR) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - SES_Delete(sp, SC_REM_CLOSE, now); + vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLHUP) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - SES_Delete(sp, SC_REM_CLOSE, now); + vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLRDHUP) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - SES_Delete(sp, SC_REM_CLOSE, now); + vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); } } } @@ -192,7 +194,7 @@ vwe_thread(void *priv) break; VTAILQ_REMOVE(&vwe->sesshead, sp, list); // XXX: not yet VTCP_linger(sp->fd, 0); - SES_Delete(sp, SC_RX_TIMEOUT, now); + vwe->func(sp, sp->fd, WAITER_TIMEOUT, now); } } return (NULL); @@ -236,7 +238,7 @@ vwe_init(waiter_handle_f *func) { struct vwe *vwe; - (void)func; + AN(func); ALLOC_OBJ(vwe, VWE_MAGIC); AN(vwe); VTAILQ_INIT(&vwe->sesshead); @@ -247,6 +249,8 @@ vwe_init(waiter_handle_f *func) AZ(VFIL_nonblocking(vwe->pipes[1])); AZ(VFIL_nonblocking(vwe->timer_pipes[0])); + vwe->func = func; + AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 4214eb9..03e0b12 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -52,6 +52,7 @@ struct vwk { unsigned magic; #define VWK_MAGIC 0x1cc2acc2 + waiter_handle_f *func; pthread_t thread; int pipes[2]; int kq; @@ -127,11 +128,11 @@ vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now) if (kp->data > 0) { VTAILQ_REMOVE(&vwk->sesshead, sp, list); - SES_Handle(sp, now); + vwk->func(sp, sp->fd, WAITER_ACTION, now); return; } else if (kp->flags & EV_EOF) { VTAILQ_REMOVE(&vwk->sesshead, sp, list); - SES_Delete(sp, SC_REM_CLOSE, now); + vwk->func(sp, sp->fd, WAITER_REMCLOSE, now); return; } else { VSL(SLT_Debug, sp->vxid, @@ -207,7 +208,7 @@ vwk_thread(void *priv) break; VTAILQ_REMOVE(&vwk->sesshead, sp, list); // XXX: not yet (void)VTCP_linger(sp->fd, 0); - SES_Delete(sp, SC_RX_TIMEOUT, now); + vwk->func(sp, sp->fd, WAITER_TIMEOUT, now); } } NEEDLESS_RETURN(NULL); @@ -232,10 +233,12 @@ vwk_init(waiter_handle_f *func) { struct vwk *vwk; - (void)func; + AN(func); ALLOC_OBJ(vwk, VWK_MAGIC); AN(vwk); + vwk->func = func; + VTAILQ_INIT(&vwk->sesshead); AZ(pipe(vwk->pipes)); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 96f37cd..3af524b 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -45,6 +45,7 @@ struct vwp { unsigned magic; #define VWP_MAGIC 0x4b2cc735 + waiter_handle_f *func; int pipes[2]; pthread_t poll_thread; struct pollfd *pollfd; @@ -159,12 +160,12 @@ vwp_main(void *priv) vwp->pollfd[fd].revents = 0; VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); - SES_Handle(sp, now); + vwp->func(sp, sp->fd, WAITER_ACTION, now); } else if (sp->t_idle <= deadline) { VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); // XXX: not yet (void)VTCP_linger(sp->fd, 0); - SES_Delete(sp, SC_RX_TIMEOUT, now); + vwp->func(sp, sp->fd, WAITER_TIMEOUT, now); } } if (v2 && vwp->pollfd[vwp->pipes[0]].revents) { @@ -209,12 +210,14 @@ vwp_poll_init(waiter_handle_f *func) { struct vwp *vwp; - (void)func; + AN(func); ALLOC_OBJ(vwp, VWP_MAGIC); AN(vwp); VTAILQ_INIT(&vwp->sesshead); AZ(pipe(vwp->pipes)); + vwp->func = func; + AZ(VFIL_nonblocking(vwp->pipes[1])); vwp_pollspace(vwp, 256); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index fd397ac..79cddaa 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -50,6 +50,7 @@ struct vws { unsigned magic; #define VWS_MAGIC 0x0b771473 + waiter_handle_f *func; pthread_t ports_thread; int dport; VTAILQ_HEAD(,sess) sesshead; @@ -86,7 +87,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { if(ev->portev_events & POLLERR) { vws_del(vws, sp->fd); VTAILQ_REMOVE(&vws->sesshead, sp, list); - SES_Delete(sp, SC_REM_CLOSE, now); + vws->func(sp, sp->fd, WAITER_REMCLOSE); return; } @@ -106,8 +107,8 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { vws_del(vws, sp->fd); VTAILQ_REMOVE(&vws->sesshead, sp, list); - /* SES_Handle will also handle errors */ - SES_Handle(sp, now); + /* also handle errors */ + vws->func(sp, sp->fd, WAITER_ACTION); } return; } @@ -211,7 +212,7 @@ vws_thread(void *priv) if(sp->fd != -1) { vws_del(vws, sp->fd); } - SES_Delete(sp, SC_RX_TIMEOUT, now); + vws->func(sp, sp->fd, WAITER_TIMEOUT); } /* @@ -260,9 +261,10 @@ vws_init(waiter_handle_f *func) { struct vws *vws; - (void)func + AN(func); ALLOC_OBJ(vws, VWS_MAGIC); AN(vws); + vws->func = func; VTAILQ_INIT(&vws->sesshead); AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); return (vws); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index d01b4fd..795b017 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -36,7 +36,7 @@ enum wait_event { WAITER_ACTION }; -typedef void waiter_handle_f(void *ptr, int fd, enum wait_event); +typedef void waiter_handle_f(void *ptr, int fd, enum wait_event, double now); typedef void* waiter_init_f(waiter_handle_f *); typedef int waiter_pass_f(void *priv, struct sess *); @@ -48,6 +48,8 @@ struct waiter { waiter_pass_f *pass; }; +waiter_handle_f SES_Handle; + /* cache_waiter.c */ int WAIT_Enter(struct sess *sp); void WAIT_Init(waiter_handle_f *); From phk at FreeBSD.org Mon Jan 12 10:16:07 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 11:16:07 +0100 Subject: [master] 55ea33a Missing semicolon Message-ID: commit 55ea33aeaad84c6e643d51cd8d5f07fa38b43de4 Author: Poul-Henning Kamp Date: Mon Jan 12 10:15:47 2015 +0000 Missing semicolon diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 6609677..2e0d69f 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -59,7 +59,7 @@ struct vwe { pthread_t timer_thread; int epfd; - waiter_handle_f *func + waiter_handle_f *func; VTAILQ_HEAD(,sess) sesshead; int pipes[2]; From phk at FreeBSD.org Mon Jan 12 10:27:06 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 11:27:06 +0100 Subject: [master] b2731b8 another missing semicolon Message-ID: commit b2731b843ab272af9177de7b2d9b5c167774f92a Author: Poul-Henning Kamp Date: Mon Jan 12 10:26:57 2015 +0000 another missing semicolon diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index de78982..0034203 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -59,6 +59,8 @@ struct sesspool { struct pool *pool; struct mempool *mpl_req; struct mempool *mpl_sess; + + void *http1_waiter; }; /*-------------------------------------------------------------------- @@ -245,7 +247,7 @@ SES_ScheduleReq(struct req *req) * Handle a session (from waiter) */ -void __match_proto__(waiter_handle_f) +static void __match_proto__(waiter_handle_f) SES_Handle(void *ptr, int fd, enum wait_event ev, double now) { struct sess *sp; @@ -276,6 +278,23 @@ SES_Handle(void *ptr, int fd, enum wait_event ev, double now) } /*-------------------------------------------------------------------- + */ + +void +SES_Wait(struct sess *sp) +{ + struct sesspool *pp; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + pp = sp->sesspool; + CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); + if (WAIT_Enter(pp->http1_waiter, sp)) { + VSC_C_main->sess_pipe_overflow++; + SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); + } +} + +/*-------------------------------------------------------------------- * Close a sessions connection. * XXX: Technically speaking we should catch a t_end timestamp here * XXX: for SES_Delete() to use. @@ -440,6 +459,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no) bprintf(nb, "sess%u", pool_no); pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &cache_param->workspace_session); + pp->http1_waiter = WAIT_Init(SES_Handle); return (pp); } From phk at FreeBSD.org Mon Jan 12 10:30:37 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 11:30:37 +0100 Subject: [master] ab4018d Make the waiter per session pool Message-ID: commit ab4018d70c6268a0aa1423fe16a067523f69314a Author: Poul-Henning Kamp Date: Mon Jan 12 10:30:28 2015 +0000 Make the waiter per session pool diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1e63b8d..ed654c8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -970,6 +970,7 @@ void VRG_dorange(struct req *req, struct busyobj *bo, const char *r); /* cache_session.c [SES] */ void SES_Close(struct sess *sp, enum sess_close reason); +void SES_Wait(struct sess *sp); void SES_Delete(struct sess *sp, enum sess_close reason, double now); struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no); void SES_DeletePool(struct sesspool *sp); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 2868fd4..6a65668 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -211,7 +211,6 @@ child_main(void) Lck_New(&vxid_lock, lck_vxid); - WAIT_Init(SES_Handle); PAN_Init(); CLI_Init(); VFP_Init(); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 032905c..c1e98d4 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -44,7 +44,6 @@ #include "vcl.h" #include "vtcp.h" #include "vtim.h" -#include "waiter/waiter.h" /*---------------------------------------------------------------------- * Collect a request from the client. @@ -113,11 +112,8 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) SES_ReleaseReq(req); if (VTCP_nonblocking(sp->fd)) SES_Close(sp, SC_REM_CLOSE); - else if (WAIT_Enter(sp)) { - VSC_C_main->sess_pipe_overflow++; - SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, - NAN); - } + else + SES_Wait(sp); return (REQ_FSM_DONE); } } else { diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index ca32433..7f457e5 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -38,8 +38,6 @@ #include "waiter/waiter.h" -static void *waiter_priv; - const char * WAIT_GetName(void) { @@ -50,7 +48,7 @@ WAIT_GetName(void) return ("no_waiter"); } -void +void * WAIT_Init(waiter_handle_f *func) { @@ -58,11 +56,11 @@ WAIT_Init(waiter_handle_f *func) AN(waiter->name); AN(waiter->init); AN(waiter->pass); - waiter_priv = waiter->init(func); + return (waiter->init(func)); } int -WAIT_Enter(struct sess *sp) +WAIT_Enter(void *waiter_priv, struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 2e0d69f..6f3cff7 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -132,7 +132,7 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) CAST_OBJ_NOTNULL(sp, ep->data.ptr, SESS_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, sp->fd, WAITER_ACTION, now) + vwe->func(sp, sp->fd, WAITER_ACTION, now); } else if (ep->events & EPOLLERR) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 795b017..b16ad79 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -48,11 +48,9 @@ struct waiter { waiter_pass_f *pass; }; -waiter_handle_f SES_Handle; - /* cache_waiter.c */ -int WAIT_Enter(struct sess *sp); -void WAIT_Init(waiter_handle_f *); +int WAIT_Enter(void *waiter_priv, struct sess *sp); +void *WAIT_Init(waiter_handle_f *); const char *WAIT_GetName(void); int WAIT_Write_Session(struct sess *sp, int fd); From phk at FreeBSD.org Mon Jan 12 10:38:33 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 11:38:33 +0100 Subject: [master] 178b065 Add req_flags.h to Makefile Message-ID: commit 178b065966fe14e02fdbcde2bb61f2536294bc97 Author: Poul-Henning Kamp Date: Mon Jan 12 10:38:21 2015 +0000 Add req_flags.h to Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 28ce8a9..cda44ee 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -15,6 +15,7 @@ nobase_pkginclude_HEADERS = \ tbl/locks.h \ tbl/obj_attr.h \ tbl/req_body.h \ + tbl/req_flags.h \ tbl/sess_close.h \ tbl/steps.h \ tbl/symbol_kind.h \ From phk at FreeBSD.org Mon Jan 12 10:47:01 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 11:47:01 +0100 Subject: [master] c0613e9 Try to make this compile again Message-ID: commit c0613e99bce03c31796ade9d8fa4e62428a1fe11 Author: Poul-Henning Kamp Date: Mon Jan 12 10:46:50 2015 +0000 Try to make this compile again diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 79cddaa..eb1581b 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -87,7 +87,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { if(ev->portev_events & POLLERR) { vws_del(vws, sp->fd); VTAILQ_REMOVE(&vws->sesshead, sp, list); - vws->func(sp, sp->fd, WAITER_REMCLOSE); + vws->func(sp, sp->fd, WAITER_REMCLOSE, now); return; } @@ -108,7 +108,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { VTAILQ_REMOVE(&vws->sesshead, sp, list); /* also handle errors */ - vws->func(sp, sp->fd, WAITER_ACTION); + vws->func(sp, sp->fd, WAITER_ACTION, now); } return; } @@ -212,7 +212,7 @@ vws_thread(void *priv) if(sp->fd != -1) { vws_del(vws, sp->fd); } - vws->func(sp, sp->fd, WAITER_TIMEOUT); + vws->func(sp, sp->fd, WAITER_TIMEOUT, now); } /* From phk at FreeBSD.org Mon Jan 12 11:55:40 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 12:55:40 +0100 Subject: [master] a0e052c Rename "struct waiter" to "struct waiter_impl", so we can repurpose the former for an instance of a waiter. Message-ID: commit a0e052c1ef4609a0adb1dc824987cf45c9cd4f4b Author: Poul-Henning Kamp Date: Mon Jan 12 11:55:00 2015 +0000 Rename "struct waiter" to "struct waiter_impl", so we can repurpose the former for an instance of a waiter. diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 6f3cff7..bc4573d 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -259,7 +259,7 @@ vwe_init(waiter_handle_f *func) /*--------------------------------------------------------------------*/ -const struct waiter waiter_epoll = { +const struct waiter_impl waiter_epoll = { .name = "epoll", .init = vwe_init, .pass = vwe_pass, diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 03e0b12..d1f5a79 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -251,7 +251,7 @@ vwk_init(waiter_handle_f *func) /*--------------------------------------------------------------------*/ -const struct waiter waiter_kqueue = { +const struct waiter_impl waiter_kqueue = { .name = "kqueue", .init = vwk_init, .pass = vwk_pass, diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 3af524b..3a10b26 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -227,7 +227,7 @@ vwp_poll_init(waiter_handle_f *func) /*--------------------------------------------------------------------*/ -const struct waiter waiter_poll = { +const struct waiter_impl waiter_poll = { .name = "poll", .init = vwp_poll_init, .pass = vwp_poll_pass, diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index eb1581b..9f5a13f 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -272,7 +272,7 @@ vws_init(waiter_handle_f *func) /*--------------------------------------------------------------------*/ -const struct waiter waiter_ports = { +const struct waiter_impl waiter_ports = { .name = "ports", .init = vws_init, .pass = vws_pass diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index c36e089..89f2949 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -37,7 +37,7 @@ #include "waiter/waiter.h" -static const struct waiter *const vca_waiters[] = { +static const struct waiter_impl *const waiter_impls[] = { #if defined(HAVE_KQUEUE) &waiter_kqueue, #endif @@ -51,7 +51,7 @@ static const struct waiter *const vca_waiters[] = { NULL, }; -struct waiter const *waiter; +struct waiter_impl const *waiter; int WAIT_tweak_waiter(struct vsb *vsb, const char *arg) @@ -67,19 +67,19 @@ WAIT_tweak_waiter(struct vsb *vsb, const char *arg) VSB_printf(vsb, "%s", waiter->name); VSB_printf(vsb, " (possible values: "); - for (i = 0; vca_waiters[i] != NULL; i++) + for (i = 0; waiter_impls[i] != NULL; i++) VSB_printf(vsb, "%s%s", i == 0 ? "" : ", ", - vca_waiters[i]->name); + waiter_impls[i]->name); VSB_printf(vsb, ")"); return(0); } if (!strcmp(arg, WAITER_DEFAULT)) { - waiter = vca_waiters[0]; + waiter = waiter_impls[0]; return(0); } - for (i = 0; vca_waiters[i]; i++) { - if (!strcmp(arg, vca_waiters[i]->name)) { - waiter = vca_waiters[i]; + for (i = 0; waiter_impls[i]; i++) { + if (!strcmp(arg, waiter_impls[i]->name)) { + waiter = waiter_impls[i]; return(0); } } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index b16ad79..5ea4720 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -42,7 +42,7 @@ typedef int waiter_pass_f(void *priv, struct sess *); #define WAITER_DEFAULT "platform dependent" -struct waiter { +struct waiter_impl { const char *name; waiter_init_f *init; waiter_pass_f *pass; @@ -55,19 +55,19 @@ const char *WAIT_GetName(void); int WAIT_Write_Session(struct sess *sp, int fd); /* mgt_waiter.c */ -extern struct waiter const * waiter; +extern struct waiter_impl const * waiter; int WAIT_tweak_waiter(struct vsb *vsb, const char *arg); #if defined(HAVE_EPOLL_CTL) -extern const struct waiter waiter_epoll; +extern const struct waiter_impl waiter_epoll; #endif #if defined(HAVE_KQUEUE) -extern const struct waiter waiter_kqueue; +extern const struct waiter_impl waiter_kqueue; #endif #if defined(HAVE_PORT_CREATE) -extern const struct waiter waiter_ports; +extern const struct waiter_impl waiter_ports; #endif -extern const struct waiter waiter_poll; +extern const struct waiter_impl waiter_poll; From phk at FreeBSD.org Mon Jan 12 12:21:48 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 13:21:48 +0100 Subject: [master] f1da3c4 Implement "struct waiter" for a waiter instance Message-ID: commit f1da3c43a8709321962ac2d3dbdf91a26cf99ad1 Author: Poul-Henning Kamp Date: Mon Jan 12 12:21:33 2015 +0000 Implement "struct waiter" for a waiter instance diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 0034203..e0fec6e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -60,7 +60,7 @@ struct sesspool { struct mempool *mpl_req; struct mempool *mpl_sess; - void *http1_waiter; + struct waiter *http1_waiter; }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 7f457e5..af01124 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include #include @@ -38,6 +39,13 @@ #include "waiter/waiter.h" +struct waiter { + unsigned magic; +#define WAITER_MAGIC 0x17c399db + const struct waiter_impl *impl; + void *priv; +}; + const char * WAIT_GetName(void) { @@ -48,25 +56,32 @@ WAIT_GetName(void) return ("no_waiter"); } -void * +struct waiter * WAIT_Init(waiter_handle_f *func) { + struct waiter *w; + + ALLOC_OBJ(w, WAITER_MAGIC); + AN(w); AN(waiter); AN(waiter->name); AN(waiter->init); AN(waiter->pass); - return (waiter->init(func)); + w->impl = waiter; + w->priv = w->impl->init(func); + return (w); } int -WAIT_Enter(void *waiter_priv, struct sess *sp) +WAIT_Enter(const struct waiter *w, struct sess *sp) { + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); assert(sp->fd >= 0); - return (waiter->pass(waiter_priv, sp)); + return (w->impl->pass(w->priv, sp)); } /* diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 5ea4720..902356d 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -29,6 +29,7 @@ */ struct sess; +struct waiter; enum wait_event { WAITER_REMCLOSE, @@ -49,8 +50,8 @@ struct waiter_impl { }; /* cache_waiter.c */ -int WAIT_Enter(void *waiter_priv, struct sess *sp); -void *WAIT_Init(waiter_handle_f *); +int WAIT_Enter(const struct waiter *, struct sess *sp); +struct waiter *WAIT_Init(waiter_handle_f *); const char *WAIT_GetName(void); int WAIT_Write_Session(struct sess *sp, int fd); From phk at FreeBSD.org Mon Jan 12 12:36:41 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 13:36:41 +0100 Subject: [master] bbf9e25 Change calling convenction of WAIT_Enter() to be sess agnostic Message-ID: commit bbf9e25b20a33a344b2984cba7346c3edee8c213 Author: Poul-Henning Kamp Date: Mon Jan 12 12:36:26 2015 +0000 Change calling convenction of WAIT_Enter() to be sess agnostic diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index e0fec6e..4d46e32 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -288,7 +288,7 @@ SES_Wait(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); - if (WAIT_Enter(pp->http1_waiter, sp)) { + if (WAIT_Enter(pp->http1_waiter, sp, sp->fd)) { VSC_C_main->sess_pipe_overflow++; SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index af01124..1313766 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -74,11 +74,13 @@ WAIT_Init(waiter_handle_f *func) } int -WAIT_Enter(const struct waiter *w, struct sess *sp) +WAIT_Enter(const struct waiter *w, void *ptr, int fd) { + struct sess *sp; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CAST_OBJ_NOTNULL(sp, ptr, SESS_MAGIC); + assert(fd >= 0); assert(sp->fd >= 0); return (w->impl->pass(w->priv, sp)); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 902356d..7d6cbac 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -50,7 +50,7 @@ struct waiter_impl { }; /* cache_waiter.c */ -int WAIT_Enter(const struct waiter *, struct sess *sp); +int WAIT_Enter(const struct waiter *, void *ptr, int fd); struct waiter *WAIT_Init(waiter_handle_f *); const char *WAIT_GetName(void); int WAIT_Write_Session(struct sess *sp, int fd); From phk at FreeBSD.org Mon Jan 12 13:36:40 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 14:36:40 +0100 Subject: [master] 8ff174a Add a pointer arg for waiter->init to generalize the handling for waiters which pass over a pipe. Message-ID: commit 8ff174a4ebe6d6f16eabb8b8396e1f0c218e518f Author: Poul-Henning Kamp Date: Mon Jan 12 12:49:49 2015 +0000 Add a pointer arg for waiter->init to generalize the handling for waiters which pass over a pipe. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 1313766..8214b71 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -44,6 +44,7 @@ struct waiter { #define WAITER_MAGIC 0x17c399db const struct waiter_impl *impl; void *priv; + int pfd; }; const char * @@ -63,13 +64,14 @@ WAIT_Init(waiter_handle_f *func) ALLOC_OBJ(w, WAITER_MAGIC); AN(w); + w->pfd = -1; AN(waiter); AN(waiter->name); AN(waiter->init); - AN(waiter->pass); w->impl = waiter; - w->priv = w->impl->init(func); + w->priv = w->impl->init(func, &w->pfd); + AN(waiter->pass || w->pfd >= 0); return (w); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index bc4573d..082422f 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -233,12 +233,13 @@ vwe_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ -static void * -vwe_init(waiter_handle_f *func) +static void * __match_proto__(waiter_init_f) +vwe_init(waiter_handle_f *func, int *pfd) { struct vwe *vwe; AN(func); + AN(pfd); ALLOC_OBJ(vwe, VWE_MAGIC); AN(vwe); VTAILQ_INIT(&vwe->sesshead); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index d1f5a79..a1950f7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -228,12 +228,13 @@ vwk_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ -static void * -vwk_init(waiter_handle_f *func) +static void * __match_proto__(waiter_init_f) +vwk_init(waiter_handle_f *func, int *pfd) { struct vwk *vwk; AN(func); + AN(pfd); ALLOC_OBJ(vwk, VWK_MAGIC); AN(vwk); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 3a10b26..ef3426f 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -205,12 +205,13 @@ vwp_poll_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ -static void * -vwp_poll_init(waiter_handle_f *func) +static void * __match_proto__(waiter_init_f) +vwp_poll_init(waiter_handle_f *func, int *pfd) { struct vwp *vwp; AN(func); + AN(pfd); ALLOC_OBJ(vwp, VWP_MAGIC); AN(vwp); VTAILQ_INIT(&vwp->sesshead); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 9f5a13f..d9c55b4 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -256,12 +256,13 @@ vws_pass(void *priv, struct sess *sp) /*--------------------------------------------------------------------*/ -static void * -vws_init(waiter_handle_f *func) +static void * __match_proto__(waiter_init_f) +vws_init(waiter_handle_f *func, int *pfd) { struct vws *vws; AN(func); + AN(pfd); ALLOC_OBJ(vws, VWS_MAGIC); AN(vws); vws->func = func; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 7d6cbac..218eca5 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -38,7 +38,7 @@ enum wait_event { }; typedef void waiter_handle_f(void *ptr, int fd, enum wait_event, double now); -typedef void* waiter_init_f(waiter_handle_f *); +typedef void* waiter_init_f(waiter_handle_f *, int *); typedef int waiter_pass_f(void *priv, struct sess *); #define WAITER_DEFAULT "platform dependent" From phk at FreeBSD.org Mon Jan 12 13:36:40 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 14:36:40 +0100 Subject: [master] 07cf9e5 unify the waiter->pass for the common case Message-ID: commit 07cf9e50ce4e921fbcab26228c0ba4ea40b74f95 Author: Poul-Henning Kamp Date: Mon Jan 12 13:05:41 2015 +0000 unify the waiter->pass for the common case diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 8214b71..93ce37c 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -85,7 +85,10 @@ WAIT_Enter(const struct waiter *w, void *ptr, int fd) assert(fd >= 0); assert(sp->fd >= 0); - return (w->impl->pass(w->priv, sp)); + if (w->impl->pass != NULL) + return (w->impl->pass(w->priv, sp)); + assert(w->pfd >= 0); + return (WAIT_Write_Session(sp, w->pfd)); } /* diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 082422f..67f6ce6 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -221,18 +221,6 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ -static int -vwe_pass(void *priv, struct sess *sp) -{ - struct vwe *vwe; - - CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC); - - return (WAIT_Write_Session(sp, vwe->pipes[1])); -} - -/*--------------------------------------------------------------------*/ - static void * __match_proto__(waiter_init_f) vwe_init(waiter_handle_f *func, int *pfd) { @@ -251,6 +239,7 @@ vwe_init(waiter_handle_f *func, int *pfd) AZ(VFIL_nonblocking(vwe->timer_pipes[0])); vwe->func = func; + *pfd = vwe->pipes[1]; AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index a1950f7..7533109 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -216,18 +216,6 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ -static int -vwk_pass(void *priv, struct sess *sp) -{ - struct vwk *vwk; - - CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); - - return (WAIT_Write_Session(sp, vwk->pipes[1])); -} - -/*--------------------------------------------------------------------*/ - static void * __match_proto__(waiter_init_f) vwk_init(waiter_handle_f *func, int *pfd) { @@ -245,6 +233,7 @@ vwk_init(waiter_handle_f *func, int *pfd) AZ(VFIL_nonblocking(vwk->pipes[0])); AZ(VFIL_nonblocking(vwk->pipes[1])); + *pfd = vwk->pipes[1]; AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); return (vwk); @@ -255,7 +244,6 @@ vwk_init(waiter_handle_f *func, int *pfd) const struct waiter_impl waiter_kqueue = { .name = "kqueue", .init = vwk_init, - .pass = vwk_pass, }; #endif /* defined(HAVE_KQUEUE) */ diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ef3426f..37413d3 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -193,18 +193,6 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ -static int -vwp_poll_pass(void *priv, struct sess *sp) -{ - struct vwp *vwp; - - CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); - - return (WAIT_Write_Session(sp, vwp->pipes[1])); -} - -/*--------------------------------------------------------------------*/ - static void * __match_proto__(waiter_init_f) vwp_poll_init(waiter_handle_f *func, int *pfd) { @@ -220,6 +208,7 @@ vwp_poll_init(waiter_handle_f *func, int *pfd) vwp->func = func; AZ(VFIL_nonblocking(vwp->pipes[1])); + *pfd = vwp->pipes[1]; vwp_pollspace(vwp, 256); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); @@ -231,5 +220,4 @@ vwp_poll_init(waiter_handle_f *func, int *pfd) const struct waiter_impl waiter_poll = { .name = "poll", .init = vwp_poll_init, - .pass = vwp_poll_pass, }; From phk at FreeBSD.org Mon Jan 12 13:36:40 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 14:36:40 +0100 Subject: [master] fcbc795 Add a "struct waited" for FD's being waited on, and make it possible to allocate it as part of the "real" structure owning the fd. Message-ID: commit fcbc79510967d7a985bc00bfea20edcb8993f95f Author: Poul-Henning Kamp Date: Mon Jan 12 13:35:54 2015 +0000 Add a "struct waited" for FD's being waited on, and make it possible to allocate it as part of the "real" structure owning the fd. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ed654c8..7b8f14d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -383,6 +383,19 @@ struct lru { unsigned n_objcore; }; +/* Connection waiter ------------------------------------------------- + * Describing a file-descriptor/connection being waited on + */ + +struct waited { + unsigned magic; +#define WAITED_MAGIC 0x1743992d + VTAILQ_ENTRY(waited) list; + int fd; + void *ptr; + double deadline; +}; + /* Stored object ----------------------------------------------------- * Pointer to a stored object, and the methods it supports */ @@ -647,7 +660,7 @@ struct sess { struct sesspool *sesspool; struct pool_task task; - VTAILQ_ENTRY(sess) list; + struct waited waited; /* Session related fields ------------------------------------*/ diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 6a65668..10bf5e9 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -40,7 +40,6 @@ #include "vcli_priv.h" #include "vrnd.h" -#include "waiter/waiter.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 4d46e32..7d9b17f 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -248,13 +248,13 @@ SES_ScheduleReq(struct req *req) */ static void __match_proto__(waiter_handle_f) -SES_Handle(void *ptr, int fd, enum wait_event ev, double now) +ses_handle(struct waited *wp, enum wait_event ev, double now) { struct sess *sp; struct sesspool *pp; - CAST_OBJ_NOTNULL(sp, ptr, SESS_MAGIC); - (void)fd; + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + CAST_OBJ_NOTNULL(sp, wp->ptr, SESS_MAGIC); switch (ev) { case WAITER_TIMEOUT: @@ -273,7 +273,7 @@ SES_Handle(void *ptr, int fd, enum wait_event ev, double now) SES_Delete(sp, SC_OVERLOAD, now); break; default: - WRONG("Wrong event in SES_Handle"); + WRONG("Wrong event in ses_handle"); } } @@ -288,7 +288,11 @@ SES_Wait(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); - if (WAIT_Enter(pp->http1_waiter, sp, sp->fd)) { + INIT_OBJ(&sp->waited, WAITED_MAGIC); + sp->waited.fd = sp->fd; + sp->waited.ptr = sp; + sp->waited.deadline = sp->t_idle; + if (WAIT_Enter(pp->http1_waiter, &sp->waited)) { VSC_C_main->sess_pipe_overflow++; SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); } @@ -459,7 +463,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no) bprintf(nb, "sess%u", pool_no); pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &cache_param->workspace_session); - pp->http1_waiter = WAIT_Init(SES_Handle); + pp->http1_waiter = WAIT_Init(ses_handle); return (pp); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 93ce37c..20129bd 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -76,32 +76,21 @@ WAIT_Init(waiter_handle_f *func) } int -WAIT_Enter(const struct waiter *w, void *ptr, int fd) +WAIT_Enter(const struct waiter *w, struct waited *wp) { - struct sess *sp; + ssize_t written; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); - CAST_OBJ_NOTNULL(sp, ptr, SESS_MAGIC); - assert(fd >= 0); - assert(sp->fd >= 0); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + assert(wp->fd >= 0); if (w->impl->pass != NULL) - return (w->impl->pass(w->priv, sp)); + return (w->impl->pass(w->priv, wp)); assert(w->pfd >= 0); - return (WAIT_Write_Session(sp, w->pfd)); -} -/* - * We do not make sp a const, in order to hint that we actually do take - * control of it. - */ -int __match_proto__() -WAIT_Write_Session(struct sess *sp, int fd) -{ - ssize_t written; - written = write(fd, &sp, sizeof sp); - if (written != sizeof sp && (errno == EAGAIN || errno == EWOULDBLOCK)) + written = write(w->pfd, &wp, sizeof wp); + if (written != sizeof wp && (errno == EAGAIN || errno == EWOULDBLOCK)) return (-1); - assert (written == sizeof sp); + assert (written == sizeof wp); return (0); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 67f6ce6..4df476e 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -61,7 +61,7 @@ struct vwe { waiter_handle_f *func; - VTAILQ_HEAD(,sess) sesshead; + VTAILQ_HEAD(,waited) sesshead; int pipes[2]; int timer_pipes[2]; }; @@ -81,7 +81,7 @@ vwe_modadd(struct vwe *vwe, int fd, void *data, short arm) }; AZ(epoll_ctl(vwe->epfd, arm, fd, &ev)); } else { - struct sess *sp = (struct sess *)data; + struct waited *sp = (struct waited *)data; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); sp->ev.data.ptr = data; sp->ev.events = EPOLLIN | EPOLLPRI | EPOLLONESHOT | EPOLLRDHUP; @@ -92,7 +92,7 @@ vwe_modadd(struct vwe *vwe, int fd, void *data, short arm) static void vwe_cond_modadd(struct vwe *vwe, int fd, void *data) { - struct sess *sp = (struct sess *)data; + struct waited *sp = (struct waited *)data; assert(fd >= 0); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -108,7 +108,7 @@ vwe_cond_modadd(struct vwe *vwe, int fd, void *data) static void vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) { - struct sess *ss[NEEV], *sp; + struct waited *ss[NEEV], *sp; int i, j; AN(ep->data.ptr); @@ -132,16 +132,16 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) CAST_OBJ_NOTNULL(sp, ep->data.ptr, SESS_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, sp->fd, WAITER_ACTION, now); + vwe->func(sp, WAITER_ACTION, now); } else if (ep->events & EPOLLERR) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); + vwe->func(sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLHUP) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); + vwe->func(sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLRDHUP) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, sp->fd, WAITER_REMCLOSE, now); + vwe->func(sp, WAITER_REMCLOSE, now); } } } @@ -152,7 +152,7 @@ static void * vwe_thread(void *priv) { struct epoll_event ev[NEEV], *ep; - struct sess *sp; + struct waited *sp; char junk; double now, deadline; int dotimer, i, n; @@ -190,11 +190,11 @@ vwe_thread(void *priv) sp = VTAILQ_FIRST(&vwe->sesshead); if (sp == NULL) break; - if (sp->t_idle > deadline) + if (sp->deadline > deadline) break; VTAILQ_REMOVE(&vwe->sesshead, sp, list); // XXX: not yet VTCP_linger(sp->fd, 0); - vwe->func(sp, sp->fd, WAITER_TIMEOUT, now); + vwe->func(sp, WAITER_TIMEOUT, now); } } return (NULL); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 7533109..f6fff9a 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -58,7 +58,7 @@ struct vwk { int kq; struct kevent ki[NKEV]; unsigned nki; - VTAILQ_HEAD(,sess) sesshead; + VTAILQ_HEAD(,waited) sesshead; }; /*--------------------------------------------------------------------*/ @@ -76,12 +76,11 @@ vwk_kq_flush(struct vwk *vwk) } static void -vwk_kq_sess(struct vwk *vwk, struct sess *sp, short arm) +vwk_kq_sess(struct vwk *vwk, struct waited *sp, short arm) { - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); assert(sp->fd >= 0); - DSL(DBG_WAITER, sp->vxid, "KQ: EV_SET sp %p arm %x", sp, arm); EV_SET(&vwk->ki[vwk->nki], sp->fd, EVFILT_READ, arm, 0, 0, sp); if (++vwk->nki == NKEV) vwk_kq_flush(vwk); @@ -93,7 +92,7 @@ static void vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp) { int i, j; - struct sess *ss[NKEV]; + struct waited *ss[NKEV]; AN(kp->udata); assert(kp->udata == vwk->pipes); @@ -102,7 +101,7 @@ vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp) if (i == -1 && errno == EAGAIN) return; while (i >= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); + CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); VTAILQ_INSERT_TAIL(&vwk->sesshead, ss[j], list); vwk_kq_sess(vwk, ss[j], EV_ADD | EV_ONESHOT); @@ -117,28 +116,22 @@ vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp) static void vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now) { - struct sess *sp; + struct waited *sp; AN(kp->udata); assert(kp->udata != vwk->pipes); - CAST_OBJ_NOTNULL(sp, kp->udata, SESS_MAGIC); - DSL(DBG_WAITER, sp->vxid, "KQ: sp %p kev data %lu flags 0x%x%s", - sp, (unsigned long)kp->data, kp->flags, - (kp->flags & EV_EOF) ? " EOF" : ""); + CAST_OBJ_NOTNULL(sp, kp->udata, WAITED_MAGIC); if (kp->data > 0) { VTAILQ_REMOVE(&vwk->sesshead, sp, list); - vwk->func(sp, sp->fd, WAITER_ACTION, now); + vwk->func(sp, WAITER_ACTION, now); return; } else if (kp->flags & EV_EOF) { VTAILQ_REMOVE(&vwk->sesshead, sp, list); - vwk->func(sp, sp->fd, WAITER_REMCLOSE, now); + vwk->func(sp, WAITER_REMCLOSE, now); return; } else { - VSL(SLT_Debug, sp->vxid, - "KQ: sp %p kev data %lu flags 0x%x%s", - sp, (unsigned long)kp->data, kp->flags, - (kp->flags & EV_EOF) ? " EOF" : ""); + WRONG("unknown kqueue state"); } } @@ -151,7 +144,7 @@ vwk_thread(void *priv) struct kevent ke[NKEV], *kp; int j, n, dotimer; double now, deadline; - struct sess *sp; + struct waited *sp; CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); THR_SetName("cache-kqueue"); @@ -204,11 +197,11 @@ vwk_thread(void *priv) sp = VTAILQ_FIRST(&vwk->sesshead); if (sp == NULL) break; - if (sp->t_idle > deadline) + if (sp->deadline > deadline) break; VTAILQ_REMOVE(&vwk->sesshead, sp, list); // XXX: not yet (void)VTCP_linger(sp->fd, 0); - vwk->func(sp, sp->fd, WAITER_TIMEOUT, now); + vwk->func(sp, WAITER_TIMEOUT, now); } } NEEDLESS_RETURN(NULL); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 37413d3..b347205 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -52,7 +52,7 @@ struct vwp { unsigned npoll; unsigned hpoll; - VTAILQ_HEAD(,sess) sesshead; + VTAILQ_HEAD(,waited) sesshead; }; /*--------------------------------------------------------------------*/ @@ -125,7 +125,7 @@ vwp_main(void *priv) { int v, v2; struct vwp *vwp; - struct sess *ss[NEEV], *sp, *sp2; + struct waited *ss[NEEV], *sp, *sp2; double now, deadline; int i, j, fd; @@ -149,7 +149,7 @@ vwp_main(void *priv) VTAILQ_FOREACH_SAFE(sp, &vwp->sesshead, list, sp2) { if (v != 0 && v2 == 0) break; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); fd = sp->fd; assert(fd >= 0); assert(fd <= vwp->hpoll); @@ -160,12 +160,12 @@ vwp_main(void *priv) vwp->pollfd[fd].revents = 0; VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); - vwp->func(sp, sp->fd, WAITER_ACTION, now); - } else if (sp->t_idle <= deadline) { + vwp->func(sp, WAITER_ACTION, now); + } else if (sp->deadline <= deadline) { VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); // XXX: not yet (void)VTCP_linger(sp->fd, 0); - vwp->func(sp, sp->fd, WAITER_TIMEOUT, now); + vwp->func(sp, WAITER_TIMEOUT, now); } } if (v2 && vwp->pollfd[vwp->pipes[0]].revents) { @@ -180,7 +180,7 @@ vwp_main(void *priv) assert(i >= 0); AZ((unsigned)i % sizeof ss[0]); for (j = 0; j * sizeof ss[0] < i; j++) { - CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); + CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); VTAILQ_INSERT_TAIL(&vwp->sesshead, ss[j], list); vwp_poll(vwp, ss[j]->fd); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index d9c55b4..f6b1803 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -53,7 +53,7 @@ struct vws { waiter_handle_f *func; pthread_t ports_thread; int dport; - VTAILQ_HEAD(,sess) sesshead; + VTAILQ_HEAD(,waited) sesshead; }; static inline void @@ -74,20 +74,20 @@ vws_del(struct vws *vws, int fd) static inline void vws_port_ev(struct vws *vws, port_event_t *ev, double now) { - struct sess *sp; + struct waited *sp; if(ev->portev_source == PORT_SOURCE_USER) { - CAST_OBJ_NOTNULL(sp, ev->portev_user, SESS_MAGIC); + CAST_OBJ_NOTNULL(sp, ev->portev_user, WAITED_MAGIC); assert(sp->fd >= 0); VTAILQ_INSERT_TAIL(&vws->sesshead, sp, list); vws_add(vws, sp->fd, sp); } else { assert(ev->portev_source == PORT_SOURCE_FD); - CAST_OBJ_NOTNULL(sp, ev->portev_user, SESS_MAGIC); + CAST_OBJ_NOTNULL(sp, ev->portev_user, WAITED_MAGIC); assert(sp->fd >= 0); if(ev->portev_events & POLLERR) { vws_del(vws, sp->fd); VTAILQ_REMOVE(&vws->sesshead, sp, list); - vws->func(sp, sp->fd, WAITER_REMCLOSE, now); + vws->func(sp, WAITER_REMCLOSE, now); return; } @@ -108,7 +108,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { VTAILQ_REMOVE(&vws->sesshead, sp, list); /* also handle errors */ - vws->func(sp, sp->fd, WAITER_ACTION, now); + vws->func(sp, WAITER_ACTION, now); } return; } @@ -116,7 +116,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { static void * vws_thread(void *priv) { - struct sess *sp; + struct waited *sp; struct vws *vws; CAST_OBJ_NOTNULL(vws, priv, VWS_MAGIC); @@ -205,14 +205,14 @@ vws_thread(void *priv) sp = VTAILQ_FIRST(&vws->sesshead); if (sp == NULL) break; - if (sp->t_idle > deadline) { + if (sp->deadline > deadline) { break; } VTAILQ_REMOVE(&vws->sesshead, sp, list); if(sp->fd != -1) { vws_del(vws, sp->fd); } - vws->func(sp, sp->fd, WAITER_TIMEOUT, now); + vws->func(sp, WAITER_TIMEOUT, now); } /* @@ -241,7 +241,7 @@ vws_thread(void *priv) /*--------------------------------------------------------------------*/ static int -vws_pass(void *priv, struct sess *sp) +vws_pass(void *priv, struct waited *sp) { int r; struct vws *vws; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 218eca5..4173e86 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -28,7 +28,7 @@ * */ -struct sess; +struct waited; struct waiter; enum wait_event { @@ -37,9 +37,9 @@ enum wait_event { WAITER_ACTION }; -typedef void waiter_handle_f(void *ptr, int fd, enum wait_event, double now); +typedef void waiter_handle_f(struct waited *, enum wait_event, double now); typedef void* waiter_init_f(waiter_handle_f *, int *); -typedef int waiter_pass_f(void *priv, struct sess *); +typedef int waiter_pass_f(void *priv, struct waited *); #define WAITER_DEFAULT "platform dependent" @@ -50,10 +50,9 @@ struct waiter_impl { }; /* cache_waiter.c */ -int WAIT_Enter(const struct waiter *, void *ptr, int fd); +int WAIT_Enter(const struct waiter *, struct waited *); struct waiter *WAIT_Init(waiter_handle_f *); const char *WAIT_GetName(void); -int WAIT_Write_Session(struct sess *sp, int fd); /* mgt_waiter.c */ extern struct waiter_impl const * waiter; From phk at FreeBSD.org Mon Jan 12 13:48:02 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 14:48:02 +0100 Subject: [master] 86a9156 Fix epoll Message-ID: commit 86a9156b32995bdd153f01ecd859c909f3dfffd8 Author: Poul-Henning Kamp Date: Mon Jan 12 13:47:56 2015 +0000 Fix epoll diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7b8f14d..5c9955e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -394,6 +394,9 @@ struct waited { int fd; void *ptr; double deadline; +#if defined(HAVE_EPOLL_CTL) + struct epoll_event ev; +#endif }; /* Stored object ----------------------------------------------------- @@ -686,9 +689,6 @@ struct sess { struct vrt_privs privs[1]; -#if defined(HAVE_EPOLL_CTL) - struct epoll_event ev; -#endif }; /* Prototypes etc ----------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 4df476e..67b2729 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -252,7 +252,6 @@ vwe_init(waiter_handle_f *func, int *pfd) const struct waiter_impl waiter_epoll = { .name = "epoll", .init = vwe_init, - .pass = vwe_pass, }; #endif /* defined(HAVE_EPOLL_CTL) */ From phk at FreeBSD.org Mon Jan 12 13:55:11 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 14:55:11 +0100 Subject: [master] 5ea1572 More epoll fixes Message-ID: commit 5ea15724aae7a1d8307d853e7609f95d5e5e7777 Author: Poul-Henning Kamp Date: Mon Jan 12 13:55:06 2015 +0000 More epoll fixes diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 67b2729..fb214b2 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -82,7 +82,7 @@ vwe_modadd(struct vwe *vwe, int fd, void *data, short arm) AZ(epoll_ctl(vwe->epfd, arm, fd, &ev)); } else { struct waited *sp = (struct waited *)data; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); sp->ev.data.ptr = data; sp->ev.events = EPOLLIN | EPOLLPRI | EPOLLONESHOT | EPOLLRDHUP; AZ(epoll_ctl(vwe->epfd, arm, fd, &sp->ev)); @@ -95,7 +95,7 @@ vwe_cond_modadd(struct vwe *vwe, int fd, void *data) struct waited *sp = (struct waited *)data; assert(fd >= 0); - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); if (sp->ev.data.ptr) AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_MOD, fd, &sp->ev)); else { @@ -119,7 +119,7 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) if (i == -1 && errno == EAGAIN) return; while (i >= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC); + CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); VTAILQ_INSERT_TAIL(&vwe->sesshead, ss[j], list); vwe_cond_modadd(vwe, ss[j]->fd, ss[j]); @@ -129,7 +129,7 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) AZ(i); } } else { - CAST_OBJ_NOTNULL(sp, ep->data.ptr, SESS_MAGIC); + CAST_OBJ_NOTNULL(sp, ep->data.ptr, WAITED_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { VTAILQ_REMOVE(&vwe->sesshead, sp, list); vwe->func(sp, WAITER_ACTION, now); From phk at FreeBSD.org Mon Jan 12 14:32:26 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 15:32:26 +0100 Subject: [master] 8668010 Try to make epoll waiter work again Message-ID: commit 8668010b08b33f2a3b0dc235d53a6774e5e3e12b Author: Poul-Henning Kamp Date: Mon Jan 12 14:32:15 2015 +0000 Try to make epoll waiter work again diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 7d9b17f..a577a0c 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -288,7 +288,11 @@ SES_Wait(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); - INIT_OBJ(&sp->waited, WAITED_MAGIC); + /* + * XXX: waiter_epoll prevents us from zeroing the struct because + * XXX: it keeps state across calls. + */ + sp->waited.magic = WAITED_MAGIC; sp->waited.fd = sp->fd; sp->waited.ptr = sp; sp->waited.deadline = sp->t_idle; diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index fb214b2..2890696 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -75,18 +75,11 @@ vwe_modadd(struct vwe *vwe, int fd, void *data, short arm) * XXX: will hang. See #644. */ assert(fd >= 0); - if (data == vwe->pipes || data == vwe->timer_pipes) { - struct epoll_event ev = { - EPOLLIN | EPOLLPRI , { data } - }; - AZ(epoll_ctl(vwe->epfd, arm, fd, &ev)); - } else { - struct waited *sp = (struct waited *)data; - CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); - sp->ev.data.ptr = data; - sp->ev.events = EPOLLIN | EPOLLPRI | EPOLLONESHOT | EPOLLRDHUP; - AZ(epoll_ctl(vwe->epfd, arm, fd, &sp->ev)); - } + assert(data == vwe->pipes || data == vwe->timer_pipes); + struct epoll_event ev = { + EPOLLIN | EPOLLPRI , { data } + }; + AZ(epoll_ctl(vwe->epfd, arm, fd, &ev)); } static void From phk at FreeBSD.org Mon Jan 12 14:51:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 15:51:27 +0100 Subject: [master] 55918a6 Try to fix waiter ports Message-ID: commit 55918a63fb199c9838533e158817f4dab09ec8ff Author: Poul-Henning Kamp Date: Mon Jan 12 14:51:17 2015 +0000 Try to fix waiter ports diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index f6b1803..b8ed116 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -221,7 +221,7 @@ vws_thread(void *priv) if (sp) { double tmo = - (sp->t_idle + cache_param->timeout_idle) - now; + (sp->deadline + cache_param->timeout_idle) - now; if (tmo < min_t) { timeout = &min_ts; From martin at varnish-software.com Mon Jan 12 15:38:20 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 12 Jan 2015 16:38:20 +0100 Subject: [master] 363fde2 Remove the unused per random director struct bitmap Message-ID: commit 363fde20c0c322bfd319da69e3764ba3d3a4ca06 Author: Martin Blix Grydeland Date: Mon Jan 12 15:06:36 2015 +0100 Remove the unused per random director struct bitmap diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index c368392..4c1b462 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -46,7 +46,6 @@ struct vmod_directors_random { #define VMOD_DIRECTORS_RANDOM_MAGIC 0x4732d092 struct vdir *vd; unsigned n_backend; - struct vbitmap *vbm; }; static unsigned __match_proto__(vdi_healthy) @@ -88,8 +87,6 @@ vmod_random__init(VRT_CTX, struct vmod_directors_random **rrp, AZ(*rrp); ALLOC_OBJ(rr, VMOD_DIRECTORS_RANDOM_MAGIC); AN(rr); - rr->vbm = vbit_init(8); - AN(rr->vbm); *rrp = rr; vdir_new(&rr->vd, vcl_name, vmod_random_healthy, vmod_random_resolve, rr); @@ -104,7 +101,6 @@ vmod_random__fini(struct vmod_directors_random **rrp) *rrp = NULL; CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); vdir_delete(&rr->vd); - vbit_destroy(rr->vbm); FREE_OBJ(rr); } From martin at varnish-software.com Mon Jan 12 15:38:20 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 12 Jan 2015 16:38:20 +0100 Subject: [master] a49d550 Always take the number of healthy backends into account when selecting a backend by weight. Message-ID: commit a49d5507fdd2abc5cbd6245ae93e768722e96733 Author: Martin Blix Grydeland Date: Mon Jan 12 16:13:43 2015 +0100 Always take the number of healthy backends into account when selecting a backend by weight. This removes the bias problems the current code exhibits when there is a sick backend in the set. Spotted by: xcir Fixes: #1658 diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index e7b63a0..698e48d 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -47,7 +47,6 @@ struct vmod_directors_hash { unsigned magic; #define VMOD_DIRECTORS_HASH_MAGIC 0xc08dd611 struct vdir *vd; - unsigned n_backend; struct vbitmap *vbm; }; @@ -89,7 +88,6 @@ vmod_hash_add_backend(VRT_CTX, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_HASH_MAGIC); (void)vdir_add_backend(rr->vd, be, w); - rr->n_backend++; } VCL_BACKEND __match_proto__() @@ -120,6 +118,6 @@ vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, r = vbe32dec(sha256); r = scalbn(r, -32); assert(r >= 0 && r <= 1.0); - be = vdir_pick_be(rr->vd, r, rr->n_backend); + be = vdir_pick_be(rr->vd, r); return (be); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 4c1b462..415a8ad 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -45,7 +45,6 @@ struct vmod_directors_random { unsigned magic; #define VMOD_DIRECTORS_RANDOM_MAGIC 0x4732d092 struct vdir *vd; - unsigned n_backend; }; static unsigned __match_proto__(vdi_healthy) @@ -72,7 +71,7 @@ vmod_random_resolve(const struct director *dir, struct worker *wrk, CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); r = scalbn(random(), -31); assert(r >= 0 && r < 1.0); - be = vdir_pick_be(rr->vd, r, rr->n_backend); + be = vdir_pick_be(rr->vd, r); return (be); } @@ -112,7 +111,6 @@ vmod_random_add_backend(VRT_CTX, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); (void)vdir_add_backend(rr->vd, be, w); - rr->n_backend++; } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 0ed64ec..8ebefa4 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -175,33 +175,25 @@ vdir_pick_by_weight(const struct vdir *vd, double w, } VCL_BACKEND -vdir_pick_be(struct vdir *vd, double w, unsigned nloops) +vdir_pick_be(struct vdir *vd, double w) { - struct vbitmap *vbm = NULL; - unsigned u, v, l; + unsigned u; + double tw = 0.0; VCL_BACKEND be = NULL; - double tw; - int nbe; - tw = vd->total_weight; - nbe = vd->n_backend; - assert(w >= 0.0 && w < 1.0); vdir_lock(vd); - for (l = 0; nbe > 0 && tw > 0.0 && l < nloops; l++) { - u = vdir_pick_by_weight(vd, w * tw, vbm); + for (u = 0; u < vd->n_backend; u++) { + if (vd->backend[u]->healthy(vd->backend[u], NULL, NULL)) { + vbit_clr(vd->vbm, u); + tw += vd->weight[u]; + } else + vbit_set(vd->vbm, u); + } + if (tw > 0.0) { + u = vdir_pick_by_weight(vd, w * tw, vd->vbm); + assert(u < vd->n_backend); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, NULL, NULL)) - break; - if (l == 0) { - vbm = vd->vbm; - for (v = 0; v < nbe; v++) - vbit_clr(vbm, v); - } - vbit_set(vbm, u); - nbe--; - tw -= vd->weight[u]; - be = NULL; } vdir_unlock(vd); return (be); diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 0d21e2f..e8107ab 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -49,4 +49,4 @@ void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *, VCL_BACKEND be, double weight); unsigned vdir_any_healthy(struct vdir *, const struct busyobj *, double *changed); -VCL_BACKEND vdir_pick_be(struct vdir *, double w, unsigned nloops); +VCL_BACKEND vdir_pick_be(struct vdir *, double w); From fgsch at lodoss.net Mon Jan 12 18:34:53 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 12 Jan 2015 19:34:53 +0100 Subject: [master] 5d28479 Fix vcl.show -v handling with no VCL Message-ID: commit 5d28479654464b5fe0c61a532a7c5a7557005296 Author: Federico G. Schwindt Date: Mon Jan 12 04:48:12 2015 +0000 Fix vcl.show -v handling with no VCL While here display the right VCL name if -v is used and the VCL is not found. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index d0fc13e..e401da1 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -392,18 +392,23 @@ ccf_config_show(struct cli *cli, const char * const *av, void *priv) int i; (void)priv; - if (!strcmp(av[2], "-v")) { - verbose = 1; - vcl = vcl_find(av[3]); - } else if (av[3] != NULL) { + if (!strcmp(av[2], "-v") && av[3] == NULL) { + VCLI_Out(cli, "Too few parameters"); + VCLI_SetResult(cli, CLIS_TOOFEW); + return; + } else if (strcmp(av[2], "-v") && av[3] != NULL) { VCLI_Out(cli, "Unknown options '%s'", av[2]); VCLI_SetResult(cli, CLIS_PARAM); return; + } else if (av[3] != NULL) { + verbose = 1; + vcl = vcl_find(av[3]); } else vcl = vcl_find(av[2]); if (vcl == NULL) { - VCLI_Out(cli, "No VCL named '%s'", av[2]); + VCLI_Out(cli, "No VCL named '%s'", + av[3] == NULL ? av[2] : av[3]); VCLI_SetResult(cli, CLIS_PARAM); return; } From fgsch at lodoss.net Mon Jan 12 18:34:53 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 12 Jan 2015 19:34:53 +0100 Subject: [master] d6ef2cd Normalise help output Message-ID: commit d6ef2cdbe63e730829012689d62b8b9b62c66437 Author: Federico G. Schwindt Date: Mon Jan 12 10:47:18 2015 +0000 Normalise help output Remove extra newlines, add tabs and ending punctuation. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index f178d10..d67ed8f 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -460,9 +460,8 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv) static struct cli_proto vca_cmds[] = { { CLI_SERVER_START, "i", ccf_start }, - { "debug.listen_address", - "debug.listen_address", - "Report the actual listen address\n", 0, 0, + { "debug.listen_address", "debug.listen_address", + "\tReport the actual listen address.", 0, 0, "d", ccf_listen_address, NULL }, { NULL } }; diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 4773785..479872b 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -430,7 +430,7 @@ vbp_health(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.health", "debug.health", - "\tDump backend health stuff\n", + "\tDump backend health information.", 0, 0, "d", vbp_health }, { NULL } }; diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index 9e1fa4e..c53d360 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -201,10 +201,10 @@ static struct cli_proto master_cmds[] = { { CLI_PING, "i", VCLS_func_ping }, { CLI_HELP, "i", VCLS_func_help }, { "debug.sizeof", "debug.sizeof", - "\tDump sizeof various data structures\n", + "\tDump sizeof various data structures.", 0, 0, "d", cli_debug_sizeof }, { "debug.panic.worker", "debug.panic.worker", - "\tPanic the worker process.\n", + "\tPanic the worker process.", 0, 0, "d", ccf_panic }, { NULL } }; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 91bf0e1..fad6a2d 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -230,7 +230,7 @@ debug_fragfetch(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.fragfetch", "debug.fragfetch", - "\tEnable fetch fragmentation\n", 1, 1, "d", debug_fragfetch }, + "\tEnable fetch fragmentation.", 1, 1, "d", debug_fragfetch }, { NULL } }; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 10bf5e9..cfce5cc 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -176,9 +176,9 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.xid", "debug.xid", - "\tExamine or set XID\n", 0, 1, "d", cli_debug_xid }, + "\tExamine or set XID.", 0, 1, "d", cli_debug_xid }, { "debug.srandom", "debug.srandom", - "\tSeed the random(3) function\n", 0, 1, "d", + "\tSeed the random(3) function.", 0, 1, "d", cli_debug_srandom }, { NULL } }; diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 2c393b7..9d08437 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -183,7 +183,7 @@ ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) } static struct cli_proto vcl_cmds[] = { - { "debug.vmod", "debug.vmod", "show loaded vmods", 0, 0, + { "debug.vmod", "debug.vmod", "\tShow loaded vmods.", 0, 0, "d", ccf_debug_vmod }, { NULL } }; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 78d5576..c4239b6 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -343,7 +343,7 @@ hcb_dump(struct cli *cli, const char * const *av, void *priv) } static struct cli_proto hcb_cmds[] = { - { "hcb.dump", "hcb.dump", "dump HCB tree\n", 0, 0, "d", hcb_dump }, + { "hcb.dump", "hcb.dump", "\tDump HCB tree.", 0, 0, "d", hcb_dump }, { NULL } }; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 21fecfb..8c16692 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -120,7 +120,7 @@ mcf_panic(struct cli *cli, const char * const *av, void *priv) static struct cli_proto cli_debug[] = { { "debug.panic.master", "debug.panic.master", - "\tPanic the master process.\n", + "\tPanic the master process.", 0, 0, "d", mcf_panic, NULL}, { NULL } }; diff --git a/bin/varnishd/storage/stevedore_mgt.c b/bin/varnishd/storage/stevedore_mgt.c index 7a38171..109290f 100644 --- a/bin/varnishd/storage/stevedore_mgt.c +++ b/bin/varnishd/storage/stevedore_mgt.c @@ -70,7 +70,7 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ struct cli_proto cli_stv[] = { - { "storage.list", "storage.list", "List storage devices\n", + { "storage.list", "storage.list", "\tList storage devices.", 0, 0, "", stv_cli_list }, { NULL} }; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index a4648fc..491ed62 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -668,12 +668,11 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.persistent", "debug.persistent", "Persistent debugging magic:\n" - "\tdebug.persistent [stevedore [cmd]]\n" + "\tdebug.persistent [ []]\n" "With no cmd arg, a summary of the silo is returned.\n" "Possible commands:\n" "\tsync\tClose current segment, open a new one\n" - "\tdump\tinclude objcores in silo summary\n" - "", + "\tdump\tinclude objcores in silo summary", 0, 2, "d", debug_persistent }, { NULL } }; diff --git a/include/vcli.h b/include/vcli.h index 4a18c82..e6762f0 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -122,7 +122,7 @@ #define CLI_SERVER_STOP \ "stop", \ "stop", \ - "\tStop the Varnish cache process", \ + "\tStop the Varnish cache process.", \ 0, 0 #define CLI_SERVER_START \ @@ -133,20 +133,20 @@ #define CLI_PING \ "ping", \ - "ping [timestamp]", \ - "\tKeep connection alive", \ + "ping []", \ + "\tKeep connection alive.", \ 0, 1 #define CLI_HELP \ "help", \ - "help [command]", \ - "\tShow command/protocol help", \ + "help []", \ + "\tShow command/protocol help.", \ 0, 1 #define CLI_QUIT \ "quit", \ "quit", \ - "\tClose connection", \ + "\tClose connection.", \ 0, 0 #define CLI_SERVER_STATUS \ @@ -163,7 +163,7 @@ #define CLI_AUTH \ "auth", \ - "auth response", \ + "auth ", \ "\tAuthenticate.", \ 1, 1 From phk at FreeBSD.org Mon Jan 12 19:06:23 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 20:06:23 +0100 Subject: [master] 6109c1d Pass pointer to the timeout variable into the waiter on creation. Message-ID: commit 6109c1d402ca04c345827c8c6453efed80d57666 Author: Poul-Henning Kamp Date: Mon Jan 12 19:05:32 2015 +0000 Pass pointer to the timeout variable into the waiter on creation. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index a577a0c..0089282 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -467,7 +467,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no) bprintf(nb, "sess%u", pool_no); pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &cache_param->workspace_session); - pp->http1_waiter = WAIT_Init(ses_handle); + pp->http1_waiter = WAIT_Init(ses_handle, &cache_param->timeout_idle); return (pp); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 20129bd..f9d3a42 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -58,7 +58,7 @@ WAIT_GetName(void) } struct waiter * -WAIT_Init(waiter_handle_f *func) +WAIT_Init(waiter_handle_f *func, volatile double *tmo) { struct waiter *w; @@ -70,7 +70,7 @@ WAIT_Init(waiter_handle_f *func) AN(waiter->name); AN(waiter->init); w->impl = waiter; - w->priv = w->impl->init(func, &w->pfd); + w->priv = w->impl->init(func, &w->pfd, tmo); AN(waiter->pass || w->pfd >= 0); return (w); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 2890696..e8c7110 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -60,6 +60,7 @@ struct vwe { int epfd; waiter_handle_f *func; + volatile double *tmo; VTAILQ_HEAD(,waited) sesshead; int pipes[2]; @@ -178,7 +179,7 @@ vwe_thread(void *priv) continue; /* check for timeouts */ - deadline = now - cache_param->timeout_idle; + deadline = now - *vwe->tmo; for (;;) { sp = VTAILQ_FIRST(&vwe->sesshead); if (sp == NULL) @@ -186,7 +187,6 @@ vwe_thread(void *priv) if (sp->deadline > deadline) break; VTAILQ_REMOVE(&vwe->sesshead, sp, list); - // XXX: not yet VTCP_linger(sp->fd, 0); vwe->func(sp, WAITER_TIMEOUT, now); } } @@ -215,14 +215,17 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ static void * __match_proto__(waiter_init_f) -vwe_init(waiter_handle_f *func, int *pfd) +vwe_init(waiter_handle_f *func, int *pfd, volatile double *tmo) { struct vwe *vwe; AN(func); AN(pfd); + AN(tmo); + ALLOC_OBJ(vwe, VWE_MAGIC); AN(vwe); + VTAILQ_INIT(&vwe->sesshead); AZ(pipe(vwe->pipes)); AZ(pipe(vwe->timer_pipes)); @@ -232,6 +235,7 @@ vwe_init(waiter_handle_f *func, int *pfd) AZ(VFIL_nonblocking(vwe->timer_pipes[0])); vwe->func = func; + vwe->tmo = tmo; *pfd = vwe->pipes[1]; AZ(pthread_create(&vwe->timer_thread, diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index f6fff9a..4fcdbfa 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -53,6 +53,7 @@ struct vwk { unsigned magic; #define VWK_MAGIC 0x1cc2acc2 waiter_handle_f *func; + volatile double *tmo; pthread_t thread; int pipes[2]; int kq; @@ -192,7 +193,7 @@ vwk_thread(void *priv) * would not know we meant "the old fd of this number". */ vwk_kq_flush(vwk); - deadline = now - cache_param->timeout_idle; + deadline = now - *vwk->tmo; for (;;) { sp = VTAILQ_FIRST(&vwk->sesshead); if (sp == NULL) @@ -210,16 +211,18 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ static void * __match_proto__(waiter_init_f) -vwk_init(waiter_handle_f *func, int *pfd) +vwk_init(waiter_handle_f *func, int *pfd, volatile double *tmo) { struct vwk *vwk; AN(func); AN(pfd); + AN(tmo); ALLOC_OBJ(vwk, VWK_MAGIC); AN(vwk); vwk->func = func; + vwk->tmo = tmo; VTAILQ_INIT(&vwk->sesshead); AZ(pipe(vwk->pipes)); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index b347205..d7c8f92 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -46,6 +46,7 @@ struct vwp { unsigned magic; #define VWP_MAGIC 0x4b2cc735 waiter_handle_f *func; + volatile double *tmo; int pipes[2]; pthread_t poll_thread; struct pollfd *pollfd; @@ -144,7 +145,7 @@ vwp_main(void *priv) v = poll(vwp->pollfd, vwp->hpoll + 1, 100); assert(v >= 0); now = VTIM_real(); - deadline = now - cache_param->timeout_idle; + deadline = now - *vwp->tmo; v2 = v; VTAILQ_FOREACH_SAFE(sp, &vwp->sesshead, list, sp2) { if (v != 0 && v2 == 0) @@ -194,7 +195,7 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ static void * __match_proto__(waiter_init_f) -vwp_poll_init(waiter_handle_f *func, int *pfd) +vwp_poll_init(waiter_handle_f *func, int *pfd, volatile double *tmo) { struct vwp *vwp; @@ -206,6 +207,7 @@ vwp_poll_init(waiter_handle_f *func, int *pfd) AZ(pipe(vwp->pipes)); vwp->func = func; + vwp->tmo = tmo; AZ(VFIL_nonblocking(vwp->pipes[1])); *pfd = vwp->pipes[1]; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index b8ed116..2f2aa87 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -51,6 +51,7 @@ struct vws { unsigned magic; #define VWS_MAGIC 0x0b771473 waiter_handle_f *func; + volatile double *tmo; pthread_t ports_thread; int dport; VTAILQ_HEAD(,waited) sesshead; @@ -192,7 +193,7 @@ vws_thread(void *priv) vws_port_ev(vws, ev + ei, now); /* check for timeouts */ - deadline = now - cache_param->timeout_idle; + deadline = now - *vwk->tmo; /* * This loop assumes that the oldest sessions are always at the @@ -220,8 +221,7 @@ vws_thread(void *priv) */ if (sp) { - double tmo = - (sp->deadline + cache_param->timeout_idle) - now; + double tmo = (sp->deadline + *vws->tmo) - now; if (tmo < min_t) { timeout = &min_ts; @@ -257,15 +257,17 @@ vws_pass(void *priv, struct waited *sp) /*--------------------------------------------------------------------*/ static void * __match_proto__(waiter_init_f) -vws_init(waiter_handle_f *func, int *pfd) +vws_init(waiter_handle_f *func, int *pfd, volatile double *tmo) { struct vws *vws; AN(func); AN(pfd); + AN(tmo); ALLOC_OBJ(vws, VWS_MAGIC); AN(vws); vws->func = func; + vws->tmo = tmo; VTAILQ_INIT(&vws->sesshead); AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); return (vws); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 4173e86..1b9f305 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -38,7 +38,7 @@ enum wait_event { }; typedef void waiter_handle_f(struct waited *, enum wait_event, double now); -typedef void* waiter_init_f(waiter_handle_f *, int *); +typedef void* waiter_init_f(waiter_handle_f *, int *, volatile double *); typedef int waiter_pass_f(void *priv, struct waited *); #define WAITER_DEFAULT "platform dependent" @@ -51,7 +51,7 @@ struct waiter_impl { /* cache_waiter.c */ int WAIT_Enter(const struct waiter *, struct waited *); -struct waiter *WAIT_Init(waiter_handle_f *); +struct waiter *WAIT_Init(waiter_handle_f *, volatile double *timeout); const char *WAIT_GetName(void); /* mgt_waiter.c */ From phk at FreeBSD.org Mon Jan 12 19:13:44 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 20:13:44 +0100 Subject: [master] e4289bb Add descriptive comment Message-ID: commit e4289bb0b8fbe72ad42bbebd4c0c832d216fcea3 Author: Poul-Henning Kamp Date: Mon Jan 12 19:13:28 2015 +0000 Add descriptive comment diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 1b9f305..3cb237d 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -26,6 +26,18 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * Waiters are herders of connections: The monitor a large number of + * connections and react if data arrives, the connection is closed or + * if nothing happens for a specified timeout period. + * + * The "poll" waiter should be portable to just about anything, but it + * is not very efficient because it has to setup state on each call to + * poll(2). Almost all kernels have made better facilities for that + * reason, needless to say, each with its own NIH-controlled API: + * + * - kqueue on FreeBSD + * - epoll on Linux + * - ports on Solaris */ struct waited; From phk at FreeBSD.org Mon Jan 12 20:18:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 21:18:24 +0100 Subject: [master] e5261b2 Polish Message-ID: commit e5261b289206fd07cac8cc995564ef6594e45753 Author: Poul-Henning Kamp Date: Mon Jan 12 20:18:16 2015 +0000 Polish diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 14dcf9f..21b599c 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -503,7 +503,7 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) void VRT_init_vbe(VRT_CTX, struct director **bp, int idx, - const struct vrt_backend *t) + const struct vrt_backend *vrt) { struct vbe_dir *vs; @@ -515,16 +515,16 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, vs->dir.magic = DIRECTOR_MAGIC; vs->dir.priv = vs; vs->dir.name = "simple"; - REPLACE(vs->dir.vcl_name, t->vcl_name); + REPLACE(vs->dir.vcl_name, vrt->vcl_name); vs->dir.http1pipe = vbe_dir_http1pipe; vs->dir.healthy = vbe_dir_healthy; vs->dir.gethdrs = vbe_dir_gethdrs; vs->dir.getbody = vbe_dir_getbody; vs->dir.finish = vbe_dir_finish; - vs->vrt = t; + vs->vrt = vrt; - vs->backend = VBE_AddBackend(NULL, t); + vs->backend = VBE_AddBackend(NULL, vrt); if (vs->vrt->probe != NULL) VBP_Insert(vs->backend, vs->vrt->probe, vs->vrt->hosthdr); diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index bf3e789..26cd2c9 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -88,7 +88,7 @@ struct vbc { #define VBC_MAGIC 0x0c5e6592 VTAILQ_ENTRY(vbc) list; struct backend *backend; - struct vbe_dir *vdis; + struct vbe_dir *vdis; int fd; struct suckaddr *addr; From phk at FreeBSD.org Mon Jan 12 21:03:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 22:03:51 +0100 Subject: [master] 87cb4ae Have VTCP_connect() also call socket(2), I have no idea why it didn't just do that from the start. Message-ID: commit 87cb4ae7e9f85deff0423a8c8fde1d28f6214591 Author: Poul-Henning Kamp Date: Mon Jan 12 21:02:59 2015 +0000 Have VTCP_connect() also call socket(2), I have no idea why it didn't just do that from the start. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 21b599c..8f12e91 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -85,49 +85,13 @@ VBE_ReleaseConn(struct vbc *vc) dst = cache_param->tmx; \ } while (0) -/*-------------------------------------------------------------------- - * Attempt to connect to a given addrinfo entry. - * - * Must be called with locked backend, but will release the backend - * lock during the slow/sleeping stuff, so that other worker threads - * can have a go, while we ponder. - * - */ - -static int -vbe_TryConnect(const struct busyobj *bo, int pf, - const struct suckaddr *sa, const struct vbe_dir *vs) -{ - int s, i, tmo; - double tmod; - - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); - - s = socket(pf, SOCK_STREAM, 0); - if (s < 0) - return (s); - - FIND_TMO(connect_timeout, tmod, bo, vs->vrt); - - tmo = (int)(tmod * 1000.0); - - i = VTCP_connect(s, sa, tmo); - - if (i != 0) { - AZ(close(s)); - return (-1); - } - - return (s); -} - /*--------------------------------------------------------------------*/ static void bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) { - int s; + int s, msec; + double tmod; struct backend *bp = vs->backend; char abuf1[VTCP_ADDRBUFSIZE]; char pbuf1[VTCP_PORTBUFSIZE]; @@ -146,16 +110,19 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) /* release lock during stuff that can take a long time */ + FIND_TMO(connect_timeout, tmod, bo, vs->vrt); + msec = (int)floor(tmod * 1000.0); + if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = vbe_TryConnect(bo, PF_INET6, bp->ipv6, vs); + s = VTCP_connect(bp->ipv6, msec); vc->addr = bp->ipv6; } if (s == -1 && bp->ipv4 != NULL) { - s = vbe_TryConnect(bo, PF_INET, bp->ipv4, vs); + s = VTCP_connect(bp->ipv4, msec); vc->addr = bp->ipv4; } if (s == -1 && !cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = vbe_TryConnect(bo, PF_INET6, bp->ipv6, vs); + s = VTCP_connect(bp->ipv6, msec); vc->addr = bp->ipv6; } diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 479872b..1519e0e 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -104,22 +104,6 @@ static struct lock vbp_mtx; * want to measure the backends response without local distractions. */ -static int -vbp_connect(int pf, const struct suckaddr *sa, int tmo) -{ - int s, i; - - s = socket(pf, SOCK_STREAM, 0); - if (s < 0) - return (s); - - i = VTCP_connect(s, sa, tmo); - if (i == 0) - return (s); - VTCP_close(&s); - return (-1); -} - static void vbp_poke(struct vbp_target *vt) { @@ -139,21 +123,21 @@ vbp_poke(struct vbp_target *vt) s = -1; if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = vbp_connect(PF_INET6, bp->ipv6, tmo); + s = VTCP_connect(bp->ipv6, tmo); t_now = VTIM_real(); tmo = (int)round((t_end - t_now) * 1e3); if (s >= 0) vt->good_ipv6 |= 1; } if (tmo > 0 && s < 0 && bp->ipv4 != NULL) { - s = vbp_connect(PF_INET, bp->ipv4, tmo); + s = VTCP_connect(bp->ipv4, tmo); t_now = VTIM_real(); tmo = (int)round((t_end - t_now) * 1e3); if (s >= 0) vt->good_ipv4 |= 1; } if (tmo > 0 && s < 0 && bp->ipv6 != NULL) { - s = vbp_connect(PF_INET6, bp->ipv6, tmo); + s = VTCP_connect(bp->ipv6, tmo); t_now = VTIM_real(); tmo = (int)round((t_end - t_now) * 1e3); if (s >= 0) diff --git a/include/vtcp.h b/include/vtcp.h index d89d383..f4a9690 100644 --- a/include/vtcp.h +++ b/include/vtcp.h @@ -69,7 +69,7 @@ int VTCP_check_hup(int sock); #ifdef SOL_SOCKET void VTCP_name(const struct suckaddr *addr, char *abuf, unsigned alen, char *pbuf, unsigned plen); -int VTCP_connect(int s, const struct suckaddr *name, int msec); +int VTCP_connect(const struct suckaddr *name, int msec); void VTCP_close(int *s); void VTCP_set_read_timeout(int s, double seconds); #endif diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 624dbb8..dcfb0cb 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -212,26 +212,37 @@ VTCP_nonblocking(int sock) */ int -VTCP_connect(int s, const struct suckaddr *name, int msec) +VTCP_connect(const struct suckaddr *name, int msec) { - int i, k; + int s, i, k; socklen_t l; struct pollfd fds[1]; const struct sockaddr *sa; socklen_t sl; - assert(s >= 0); + if (name == NULL) + return (-1); + /* Attempt the connect */ + AN(VSA_Sane(name)); + sa = VSA_Get_Sockaddr(name, &sl); + AN(sa); + AN(sl); + + s = socket(sa->sa_family, SOCK_STREAM, 0); + if (s < 0) + return (s); /* Set the socket non-blocking */ if (msec > 0) (void)VTCP_nonblocking(s); - /* Attempt the connect */ - AN(VSA_Sane(name)); - sa = VSA_Get_Sockaddr(name, &sl); i = connect(s, sa, sl); - if (i == 0 || errno != EINPROGRESS) - return (i); + if (i == 0) + return (s); + if (errno != EINPROGRESS) { + AZ(close(s)); + return (-1); + } assert(msec > 0); /* Exercise our patience, polling for write */ @@ -242,6 +253,7 @@ VTCP_connect(int s, const struct suckaddr *name, int msec) if (i == 0) { /* Timeout, close and give up */ + AZ(close(s)); errno = ETIMEDOUT; return (-1); } @@ -252,11 +264,13 @@ VTCP_connect(int s, const struct suckaddr *name, int msec) /* An error means no connection established */ errno = k; - if (k) + if (k) { + AZ(close(s)); return (-1); + } (void)VTCP_blocking(s); - return (0); + return (s); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Mon Jan 12 21:10:35 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 22:10:35 +0100 Subject: [master] 7970b7e White space nits Message-ID: commit 7970b7ed02047330d9dcb4b650cf882c67cacf6c Author: Poul-Henning Kamp Date: Mon Jan 12 21:06:38 2015 +0000 White space nits diff --git a/bin/varnishtest/tests/r01644.vtc b/bin/varnishtest/tests/r01644.vtc index f845213..90728a0 100644 --- a/bin/varnishtest/tests/r01644.vtc +++ b/bin/varnishtest/tests/r01644.vtc @@ -7,7 +7,7 @@ server s1 { } -start varnish v1 -vcl+backend { - + import ${vmod_debug}; sub vcl_deliver { @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set pcre_match_limit 100" client c1 { - txreq + txreq rxresp expect resp.http.foo == 100 } -run @@ -27,7 +27,7 @@ client c1 { varnish v1 -cliok "param.set pcre_match_limit 200" client c1 { - txreq + txreq rxresp expect resp.http.foo == 200 } -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 627ec14..c5d7c45 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -224,7 +224,7 @@ Description Note that the comparison is case sensitive. Example | if (std.strstr(req.url, req.http.x-restrict)) { - | ... + | ... | } $Function TIME time(STRING s, TIME fallback) @@ -243,7 +243,7 @@ Description | "784111777" Example | if (std.time(resp.http.last-modified, now) < now - 1w) { - | ... + | ... | } From phk at FreeBSD.org Mon Jan 12 21:10:35 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 12 Jan 2015 22:10:35 +0100 Subject: [master] 6f53e59 Typo Message-ID: commit 6f53e597918fa7723a256d0582a742af1a60315e Author: Poul-Henning Kamp Date: Mon Jan 12 21:10:23 2015 +0000 Typo diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 2f2aa87..be110c0 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -193,7 +193,7 @@ vws_thread(void *priv) vws_port_ev(vws, ev + ei, now); /* check for timeouts */ - deadline = now - *vwk->tmo; + deadline = now - *vws->tmo; /* * This loop assumes that the oldest sessions are always at the From phk at FreeBSD.org Tue Jan 13 09:54:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 13 Jan 2015 10:54:29 +0100 Subject: [master] 672efcf Typo Message-ID: commit 672efcf8e029008a1625b971ced5aed6f795f3a4 Author: Poul-Henning Kamp Date: Tue Jan 13 09:14:34 2015 +0000 Typo diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 3cb237d..e1b24d3 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Waiters are herders of connections: The monitor a large number of + * Waiters are herders of connections: They monitor a large number of * connections and react if data arrives, the connection is closed or * if nothing happens for a specified timeout period. * From phk at FreeBSD.org Tue Jan 13 09:54:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 13 Jan 2015 10:54:29 +0100 Subject: [master] a6a74b1 Rename HTTP_Init() to the more precise HTTP_RxInit() and relieve it of the job of setting htc->fd. Message-ID: commit a6a74b19bef0b75d5769da12418e42c7b5f3c0b4 Author: Poul-Henning Kamp Date: Tue Jan 13 09:53:46 2015 +0000 Rename HTTP_Init() to the more precise HTTP_RxInit() and relieve it of the job of setting htc->fd. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5c9955e..b6d286a 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -864,7 +864,7 @@ enum http1_status_e { HTTP1_COMPLETE = 1 }; -void HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, +void HTTP1_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes, unsigned maxhdr); enum http1_status_e HTTP1_Reinit(struct http_conn *htc); enum http1_status_e HTTP1_Rx(struct http_conn *htc); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 8f12e91..0debdf1 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -321,6 +321,7 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) AN(bo->htc); INIT_OBJ(bo->htc, HTTP_CONN_MAGIC); bo->htc->vbc = vc; + bo->htc->fd = vc->fd; FIND_TMO(first_byte_timeout, vc->first_byte_timeout, bo, vs->vrt); FIND_TMO(between_bytes_timeout, vc->between_bytes_timeout, bo, vs->vrt); return (vc->fd); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index bb40205..1fbb071 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -110,8 +110,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) do_chunked = 1; } - (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ - V1L_Reserve(wrk, wrk->aws, &vc->fd, bo->vsl, bo->t_prev); + (void)VTCP_blocking(htc->fd); /* XXX: we should timeout instead */ + V1L_Reserve(wrk, wrk->aws, &htc->fd, bo->vsl, bo->t_prev); bo->acct.bereq_hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req); /* Deal with any message-body the request might (still) have */ @@ -149,12 +149,12 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) /* Receive response */ - HTTP1_Init(htc, bo->ws, vc->fd, cache_param->http_resp_size, + HTTP1_RxInit(htc, bo->ws, cache_param->http_resp_size, cache_param->http_resp_hdr_len); CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - VTCP_set_read_timeout(vc->fd, vc->first_byte_timeout); + VTCP_set_read_timeout(htc->fd, vc->first_byte_timeout); first = 1; do { @@ -179,7 +179,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) if (first) { retry = -1; first = 0; - VTCP_set_read_timeout(vc->fd, + VTCP_set_read_timeout(htc->fd, vc->between_bytes_timeout); } } while (hs != HTTP1_COMPLETE); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index c1e98d4..5747b6a 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -368,7 +368,8 @@ HTTP1_Session(struct worker *wrk, struct req *req) } if (sp->sess_step == S_STP_NEWREQ) { - HTTP1_Init(req->htc, req->ws, sp->fd, + req->htc->fd = sp->fd; + HTTP1_RxInit(req->htc, req->ws, cache_param->http_req_size, cache_param->http_req_hdr_len); } diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 45f4784..ca013c6 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -60,13 +60,12 @@ const int HTTP1_Resp[3] = { /*--------------------------------------------------------------------*/ void -HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned maxbytes, +HTTP1_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes, unsigned maxhdr) { htc->magic = HTTP_CONN_MAGIC; htc->ws = ws; - htc->fd = fd; htc->maxbytes = maxbytes; htc->maxhdr = maxhdr; From phk at FreeBSD.org Tue Jan 13 10:09:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 13 Jan 2015 11:09:29 +0100 Subject: [master] 07b8a99 Wean V1F_fetch_hdr() of struct vbc which should be and now is an internal matter in cache_backend_* Message-ID: commit 07b8a996f1cf982fee0072f6fe2374b5c4ede0a4 Author: Poul-Henning Kamp Date: Tue Jan 13 10:08:49 2015 +0000 Wean V1F_fetch_hdr() of struct vbc which should be and now is an internal matter in cache_backend_* diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b6d286a..6bbe87d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -242,6 +242,10 @@ struct http_conn { enum body_status body_status; struct vfp_ctx vfc[1]; struct vbc *vbc; + + /* Timeouts */ + double first_byte_timeout; + double between_bytes_timeout; }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 0debdf1..706ec0b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -322,8 +322,10 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) INIT_OBJ(bo->htc, HTTP_CONN_MAGIC); bo->htc->vbc = vc; bo->htc->fd = vc->fd; - FIND_TMO(first_byte_timeout, vc->first_byte_timeout, bo, vs->vrt); - FIND_TMO(between_bytes_timeout, vc->between_bytes_timeout, bo, vs->vrt); + FIND_TMO(first_byte_timeout, + bo->htc->first_byte_timeout, bo, vs->vrt); + FIND_TMO(between_bytes_timeout, + bo->htc->between_bytes_timeout, bo, vs->vrt); return (vc->fd); } @@ -400,7 +402,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, * that the backend closed it before we get a request to it. * Do a single retry in that case. */ - if (i == 1) { + if (i == 1 && bo->htc->vbc->recycled) { vbe_dir_finish(d, wrk, bo); AZ(bo->htc); VSC_C_main->backend_retry++; diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 26cd2c9..dc7c85d 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -94,10 +94,6 @@ struct vbc { struct suckaddr *addr; uint8_t recycled; - - /* Timeouts */ - double first_byte_timeout; - double between_bytes_timeout; }; /* cache_backend.c */ diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 1fbb071..15e1bf4 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -76,10 +76,9 @@ vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l) int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) { - struct vbc *vc; struct http *hp; enum http1_status_e hs; - int retry = -1; + int retry = 1; int i, j, first; struct http_conn *htc; int do_chunked = 0; @@ -87,14 +86,10 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - CHECK_OBJ_NOTNULL(bo->htc->vbc, VBC_MAGIC); CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC); htc = bo->htc; hp = bo->bereq; - vc = htc->vbc; - if (vc->recycled) - retry = 1; /* * Now that we know our backend, we can set a default Host: @@ -154,7 +149,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - VTCP_set_read_timeout(htc->fd, vc->first_byte_timeout); + VTCP_set_read_timeout(htc->fd, htc->first_byte_timeout); first = 1; do { @@ -180,7 +175,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host) retry = -1; first = 0; VTCP_set_read_timeout(htc->fd, - vc->between_bytes_timeout); + htc->between_bytes_timeout); } } while (hs != HTTP1_COMPLETE); bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; From phk at FreeBSD.org Tue Jan 13 11:10:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 13 Jan 2015 12:10:00 +0100 Subject: [master] cab1d55 Add VSA_Get_Proto() to find out what protocol it is. Message-ID: commit cab1d55670cb0b9225833e375070de3f18fdf224 Author: Poul-Henning Kamp Date: Tue Jan 13 11:09:41 2015 +0000 Add VSA_Get_Proto() to find out what protocol it is. diff --git a/include/vsa.h b/include/vsa.h index 8496278..5974974 100644 --- a/include/vsa.h +++ b/include/vsa.h @@ -40,6 +40,7 @@ int VSA_Compare(const struct suckaddr *, const struct suckaddr *); struct suckaddr *VSA_Clone(const struct suckaddr *sua); const struct sockaddr *VSA_Get_Sockaddr(const struct suckaddr *, socklen_t *sl); +int VSA_Get_Proto(const struct suckaddr *); /* * 's' is a sockaddr of some kind, 'sal' is its length diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 7057487..b543d55 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -286,6 +286,14 @@ VSA_Get_Sockaddr(const struct suckaddr *sua, socklen_t *sl) } int +VSA_Get_Proto(const struct suckaddr *sua) +{ + + CHECK_OBJ_NOTNULL(sua, SUCKADDR_MAGIC); + return (sua->sa.sa_family); +} + +int VSA_Sane(const struct suckaddr *sua) { CHECK_OBJ_NOTNULL(sua, SUCKADDR_MAGIC); From phk at FreeBSD.org Tue Jan 13 11:13:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 13 Jan 2015 12:13:24 +0100 Subject: [master] edf9ecc Add "tcp_pools" which is where struct vbc is headed now. Message-ID: commit edf9ecc6af705ff60b5bbbce2c9b94e847991cd8 Author: Poul-Henning Kamp Date: Tue Jan 13 11:12:40 2015 +0000 Add "tcp_pools" which is where struct vbc is headed now. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 3d614c8..c0f6c1f 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -13,6 +13,7 @@ varnishd_SOURCES = \ cache/cache_backend.c \ cache/cache_backend_cfg.c \ cache/cache_backend_poll.c \ + cache/cache_backend_tcp.c \ cache/cache_ban.c \ cache/cache_busyobj.c \ cache/cache_cli.c \ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 706ec0b..a5c2b22 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -90,7 +90,7 @@ VBE_ReleaseConn(struct vbc *vc) static void bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) { - int s, msec; + int s; double tmod; struct backend *bp = vs->backend; char abuf1[VTCP_ADDRBUFSIZE]; @@ -111,20 +111,7 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) /* release lock during stuff that can take a long time */ FIND_TMO(connect_timeout, tmod, bo, vs->vrt); - msec = (int)floor(tmod * 1000.0); - - if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = VTCP_connect(bp->ipv6, msec); - vc->addr = bp->ipv6; - } - if (s == -1 && bp->ipv4 != NULL) { - s = VTCP_connect(bp->ipv4, msec); - vc->addr = bp->ipv4; - } - if (s == -1 && !cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = VTCP_connect(bp->ipv6, msec); - vc->addr = bp->ipv6; - } + s = VBT_Open(bp->tcp_pool, tmod, &vc->addr); vc->fd = s; if (s < 0) { diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index dc7c85d..b7c27e0 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -40,6 +40,7 @@ struct vbp_target; struct vbc; struct vrt_backend_probe; +struct tcp_pool; /*-------------------------------------------------------------------- * An instance of a backend from a VCL program. @@ -78,6 +79,8 @@ struct backend { double health_changed; struct VSC_C_vbe *vsc; + + struct tcp_pool *tcp_pool; }; /* -------------------------------------------------------------------*/ @@ -91,7 +94,7 @@ struct vbc { struct vbe_dir *vdis; int fd; - struct suckaddr *addr; + const struct suckaddr *addr; uint8_t recycled; }; @@ -120,3 +123,8 @@ void VBP_Summary(struct cli *cli, const struct vbp_target *vt); /* cache_backend_poll.c */ void VBP_Init(void); +struct tcp_pool *VBT_Ref(const char *name, const struct suckaddr *ip4, + const struct suckaddr *ip6); +void VBT_Rel(struct tcp_pool **tpp); +int VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa); + diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 432ff05..29c9be9 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -66,6 +66,7 @@ VBE_Nuke(struct backend *b) free(b->ipv6_addr); free(b->port); VSM_Free(b->vsc); + VBT_Rel(&b->tcp_pool); FREE_OBJ(b); VSC_C_main->n_backend--; } @@ -213,6 +214,9 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) REPLACE(b->ipv6_addr, vb->ipv6_addr); REPLACE(b->port, vb->port); + b->tcp_pool = VBT_Ref(vb->vcl_name, + vb->ipv4_suckaddr, vb->ipv6_suckaddr); + /* * Copy over the sockaddrs */ diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 1519e0e..10fd4c3 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -41,14 +41,16 @@ #include #include #include +#include #include "cache.h" #include "cache_backend.h" #include "vcli_priv.h" #include "vrt.h" -#include "vtcp.h" #include "vtim.h" +#include "vtcp.h" +#include "vsa.h" /* Default averaging rate, we want something pretty responsive */ #define AVG_RATE 4 @@ -113,6 +115,7 @@ vbp_poke(struct vbp_target *vt) struct backend *bp; char buf[8192], *p; struct pollfd pfda[1], *pfd = pfda; + const struct suckaddr *sa; bp = vt->backend; CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); @@ -121,32 +124,22 @@ vbp_poke(struct vbp_target *vt) t_end = t_start + vt->probe.timeout; tmo = (int)round((t_end - t_now) * 1e3); - s = -1; - if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = VTCP_connect(bp->ipv6, tmo); - t_now = VTIM_real(); - tmo = (int)round((t_end - t_now) * 1e3); - if (s >= 0) - vt->good_ipv6 |= 1; - } - if (tmo > 0 && s < 0 && bp->ipv4 != NULL) { - s = VTCP_connect(bp->ipv4, tmo); - t_now = VTIM_real(); - tmo = (int)round((t_end - t_now) * 1e3); - if (s >= 0) - vt->good_ipv4 |= 1; - } - if (tmo > 0 && s < 0 && bp->ipv6 != NULL) { - s = VTCP_connect(bp->ipv6, tmo); - t_now = VTIM_real(); - tmo = (int)round((t_end - t_now) * 1e3); - if (s >= 0) - vt->good_ipv6 |= 1; - } + s = VBT_Open(bp->tcp_pool, t_end - t_now, &sa); if (s < 0) { /* Got no connection: failed */ return; } + + i = VSA_Get_Proto(sa); + if (i == AF_INET) + vt->good_ipv4 |= 1; + else if(i == AF_INET6) + vt->good_ipv6 |= 1; + else + WRONG("Wrong probe protocol family"); + + t_now = VTIM_real(); + tmo = (int)round((t_end - t_now) * 1e3); if (tmo <= 0) { /* Spent too long time getting it */ VTCP_close(&s); diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c new file mode 100644 index 0000000..175ab48 --- /dev/null +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -0,0 +1,158 @@ +/*- + * Copyright (c) 2015 Varnish Software 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. + * + * TCP connection pools for backends + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "cache.h" + +#include "cache_backend.h" +#include "vrt.h" +#include "vtcp.h" +#include "vsa.h" + +struct tcp_pool { + unsigned magic; +#define TCP_POOL_MAGIC 0x28b0e42a + + char *name; + struct suckaddr *ip4; + struct suckaddr *ip6; + + VTAILQ_ENTRY(tcp_pool) list; + int refcnt; + + +}; + +static VTAILQ_HEAD(, tcp_pool) pools = VTAILQ_HEAD_INITIALIZER(pools); + +/*-------------------------------------------------------------------- + */ + +struct tcp_pool * +VBT_Ref(const char *name, const struct suckaddr *ip4, + const struct suckaddr *ip6) +{ + struct tcp_pool *tp; + + ASSERT_CLI(); + VTAILQ_FOREACH(tp, &pools, list) { + assert(tp->refcnt > 0); + if (strcmp(tp->name, name)) + continue; + if (ip4 == NULL) { + if (tp->ip4 != NULL) + continue; + } else { + if (tp->ip4 == NULL) + continue; + if (VSA_Compare(ip4, tp->ip4)) + continue; + } + if (ip6 == NULL) { + if (tp->ip6 != NULL) + continue; + } else { + if (tp->ip6 == NULL) + continue; + if (VSA_Compare(ip6, tp->ip6)) + continue; + } + tp->refcnt++; + return (tp); + } + + ALLOC_OBJ(tp, TCP_POOL_MAGIC); + AN(tp); + REPLACE(tp->name, name); + if (ip4 != NULL) + tp->ip4 = VSA_Clone(ip4); + if (ip6 != NULL) + tp->ip6 = VSA_Clone(ip6); + tp->refcnt = 1; + VTAILQ_INSERT_HEAD(&pools, tp, list); + return (tp); +} + +/*-------------------------------------------------------------------- + */ + +void +VBT_Rel(struct tcp_pool **tpp) +{ + struct tcp_pool *tp; + + AN(tpp); + tp = *tpp; + *tpp = NULL; + CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); + assert(tp->refcnt > 0); + if (--tp->refcnt > 0) + return; + VTAILQ_REMOVE(&pools, tp, list); + free(tp->name); + free(tp->ip4); + free(tp->ip6); + FREE_OBJ(tp); +} + +/*-------------------------------------------------------------------- + */ + +int +VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa) +{ + int s; + int msec; + + CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); + + msec = (int)floor(tmo * 1000.0); + if (cache_param->prefer_ipv6) { + *sa = tp->ip6; + s = VTCP_connect(tp->ip6, msec); + if (s >= 0) + return(s); + } + *sa = tp->ip4; + s = VTCP_connect(tp->ip4, msec); + if (s < 0 && !cache_param->prefer_ipv6) { + *sa = tp->ip6; + s = VTCP_connect(tp->ip6, msec); + } + return(s); +} From fgsch at lodoss.net Wed Jan 14 05:27:22 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 14 Jan 2015 06:27:22 +0100 Subject: [master] 63d3cdd Remove unexistent cli command and comment Message-ID: commit 63d3cdd80abd3f4610cdeed2bd1d0ce782582a10 Author: Federico G. Schwindt Date: Tue Jan 13 10:17:20 2015 +0000 Remove unexistent cli command and comment diff --git a/include/vcli.h b/include/vcli.h index e6762f0..19dace3 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -43,21 +43,8 @@ * const char * request_help (for long help) * unsigned minimum_arguments * unsigned maximum_arguments - * - * If you only want a subset of these fields do this: - * #define CLIF145(a,b,c,d,e) a,d,e - * [...] - * CLIF145(CLI_URL_QUERY) - * */ -#define CLI_URL_QUERY \ - "url.query", \ - "url.query ", \ - "\tQuery the cache status of a specific URL.\n" \ - "\tReturns the TTL, size and checksum of the object.", \ - 1, 1 - #define CLI_BAN \ "ban", \ "ban [&& ]...", \ From fgsch at lodoss.net Wed Jan 14 05:27:22 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 14 Jan 2015 06:27:22 +0100 Subject: [master] bbd4e79 Collapse multiple X-Forwarded-For headers Message-ID: commit bbd4e79adc2ac44fe3866b5288fed8a3ecb05bb0 Author: Federico G. Schwindt Date: Wed Jan 14 04:32:50 2015 +0000 Collapse multiple X-Forwarded-For headers Fixes #1650 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3e1e9d0..66da39e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -587,6 +587,7 @@ cnt_recv(struct worker *wrk, struct req *req) * This really should be done earlier, but we want to capture * it in the VSL log. */ + http_CollectHdr(req->http, H_X_Forwarded_For); if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) { http_Unset(req->http, H_X_Forwarded_For); http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s", diff --git a/bin/varnishtest/tests/r01650.vtc b/bin/varnishtest/tests/r01650.vtc new file mode 100644 index 0000000..e21ceba --- /dev/null +++ b/bin/varnishtest/tests/r01650.vtc @@ -0,0 +1,16 @@ +varnishtest "xff handling discards multiple headers" + +server s1 { + rxreq + expect req.http.X-Forwarded-For == "1.2.3.4, 5.6.7.8, 127.0.0.1" + txresp +} -start + +varnish v1 -vcl+backend { +} -start + +client c1 { + txreq -hdr "X-Forwarded-For: 1.2.3.4" -hdr "X-Forwarded-For: 5.6.7.8" + rxresp +} -run + From phk at FreeBSD.org Wed Jan 14 08:37:57 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 09:37:57 +0100 Subject: [master] 3864e66 Move the vbc list into the new tcp_pool class. Message-ID: commit 3864e664636225fd9a879433dba8cd64d085f2f9 Author: Poul-Henning Kamp Date: Wed Jan 14 08:37:16 2015 +0000 Move the vbc list into the new tcp_pool class. When the first backend connection fails (likely because of timeout from the backend) we ditch the rest of the list. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index a5c2b22..0f02784 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -105,7 +105,6 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) bp->vsc->conn++; Lck_Unlock(&bp->mtx); - s = -1; assert(bp->ipv6 != NULL || bp->ipv4 != NULL); /* release lock during stuff that can take a long time */ @@ -181,23 +180,25 @@ vbe_GetVbe(struct busyobj *bo, struct vbe_dir *vs) bp = vs->backend; CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); + if (!VBE_Healthy(bp, NULL)) { + VSC_C_main->backend_unhealthy++; + return (NULL); + } + /* first look for vbc's we can recycle */ while (1) { - Lck_Lock(&bp->mtx); - vc = VTAILQ_FIRST(&bp->connlist); - if (vc != NULL) { - bp->refcount++; - assert(vc->backend == bp); - assert(vc->fd >= 0); - AN(vc->addr); - VTAILQ_REMOVE(&bp->connlist, vc, list); - } - Lck_Unlock(&bp->mtx); + vc = VBT_Get(bp->tcp_pool); if (vc == NULL) break; + + Lck_Lock(&bp->mtx); + bp->refcount++; + assert(vc->backend == bp); + assert(vc->fd >= 0); + AN(vc->addr); + Lck_Unlock(&bp->mtx); + if (vbe_CheckFd(vc->fd)) { - /* XXX locking of stats */ - VSC_C_main->backend_reuse += 1; VSLb(bo->vsl, SLT_Backend, "%d %s %s", vc->fd, bo->director_resp->vcl_name, bp->display_name); @@ -205,7 +206,6 @@ vbe_GetVbe(struct busyobj *bo, struct vbe_dir *vs) vc->recycled = 1; return (vc); } - VSC_C_main->backend_toolate++; VSLb(bo->vsl, SLT_BackendClose, "%d %s toolate", vc->fd, bp->display_name); @@ -215,11 +215,6 @@ vbe_GetVbe(struct busyobj *bo, struct vbe_dir *vs) VBE_ReleaseConn(vc); } - if (!VBE_Healthy(bp, NULL)) { - VSC_C_main->backend_unhealthy++; - return (NULL); - } - if (vs->vrt->max_connections > 0 && bp->n_conn >= vs->vrt->max_connections) { VSC_C_main->backend_busy++; @@ -357,8 +352,8 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, bp->display_name); Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; - VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list); VBE_DropRefLocked(bp, &bo->acct); + VBT_Recycle(bp->tcp_pool, &bo->htc->vbc); } bo->htc->vbc = NULL; bo->htc = NULL; diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index b7c27e0..89e1649 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -71,7 +71,6 @@ struct backend { struct suckaddr *ipv6; unsigned n_conn; - VTAILQ_HEAD(, vbc) connlist; struct vbp_target *probe; unsigned healthy; @@ -127,4 +126,7 @@ struct tcp_pool *VBT_Ref(const char *name, const struct suckaddr *ip4, const struct suckaddr *ip6); void VBT_Rel(struct tcp_pool **tpp); int VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa); +void VBT_Recycle(struct tcp_pool *tp, struct vbc **vbc); +struct vbc *VBT_Get(struct tcp_pool *tp); + diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 29c9be9..bb46761 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -101,7 +101,6 @@ void VBE_DropRefLocked(struct backend *b, const struct acct_bereq *acct_bereq) { int i; - struct vbc *vbe, *vbe2; CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); assert(b->refcount > 0); @@ -119,15 +118,6 @@ VBE_DropRefLocked(struct backend *b, const struct acct_bereq *acct_bereq) return; ASSERT_CLI(); - VTAILQ_FOREACH_SAFE(vbe, &b->connlist, list, vbe2) { - VTAILQ_REMOVE(&b->connlist, vbe, list); - if (vbe->fd >= 0) { - AZ(close(vbe->fd)); - vbe->fd = -1; - } - vbe->backend = NULL; - VBE_ReleaseConn(vbe); - } VBE_Nuke(b); } @@ -202,7 +192,6 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) b->vsc = VSM_Alloc(sizeof *b->vsc, VSC_CLASS, VSC_type_vbe, buf); b->vsc->vcls++; - VTAILQ_INIT(&b->connlist); /* * This backend may live longer than the VCL that instantiated it diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 10fd4c3..319b23b 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -122,7 +122,6 @@ vbp_poke(struct vbp_target *vt) t_start = t_now = VTIM_real(); t_end = t_start + vt->probe.timeout; - tmo = (int)round((t_end - t_now) * 1e3); s = VBT_Open(bp->tcp_pool, t_end - t_now, &sa); if (s < 0) { diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 175ab48..5495cff 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -54,13 +54,18 @@ struct tcp_pool { VTAILQ_ENTRY(tcp_pool) list; int refcnt; + struct lock mtx; + VTAILQ_HEAD(, vbc) connlist; + VTAILQ_HEAD(, vbc) killlist; }; static VTAILQ_HEAD(, tcp_pool) pools = VTAILQ_HEAD_INITIALIZER(pools); /*-------------------------------------------------------------------- + * Reference a TCP pool given by {name, ip4, ip6} triplet. Create if + * it doesn't exist already. */ struct tcp_pool * @@ -104,17 +109,22 @@ VBT_Ref(const char *name, const struct suckaddr *ip4, if (ip6 != NULL) tp->ip6 = VSA_Clone(ip6); tp->refcnt = 1; + Lck_New(&tp->mtx, lck_backend); + VTAILQ_INIT(&tp->connlist); + VTAILQ_INIT(&tp->killlist); VTAILQ_INSERT_HEAD(&pools, tp, list); return (tp); } /*-------------------------------------------------------------------- + * Release TCP pool, destroy if last reference. */ void VBT_Rel(struct tcp_pool **tpp) { struct tcp_pool *tp; + struct vbc *vbc, *vbc2; AN(tpp); tp = *tpp; @@ -127,10 +137,27 @@ VBT_Rel(struct tcp_pool **tpp) free(tp->name); free(tp->ip4); free(tp->ip6); + Lck_Delete(&tp->mtx); + VTAILQ_FOREACH_SAFE(vbc, &tp->connlist, list, vbc2) { + VTAILQ_REMOVE(&tp->connlist, vbc, list); + vbc->backend = NULL; + (void)close(vbc->fd); + vbc->fd = -1; + VBE_ReleaseConn(vbc); + } + VTAILQ_FOREACH_SAFE(vbc, &tp->killlist, list, vbc2) { + VTAILQ_REMOVE(&tp->killlist, vbc, list); + vbc->backend = NULL; + (void)close(vbc->fd); + vbc->fd = -1; + VBE_ReleaseConn(vbc); + } FREE_OBJ(tp); } /*-------------------------------------------------------------------- + * Open a new connection from pool. This is a distinct function since + * probing cannot use a recycled connection. */ int @@ -156,3 +183,69 @@ VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa) } return(s); } + +/*-------------------------------------------------------------------- + * Recycle a connection. + */ + +void +VBT_Recycle(struct tcp_pool *tp, struct vbc **vbc) +{ + + CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); + CHECK_OBJ_NOTNULL((*vbc), VBC_MAGIC); + + Lck_Lock(&tp->mtx); + VTAILQ_INSERT_HEAD(&tp->connlist, *vbc, list); + Lck_Unlock(&tp->mtx); + *vbc = NULL; +} + +/*-------------------------------------------------------------------- + * Get a connection + */ + +struct vbc * +VBT_Get(struct tcp_pool *tp) +{ + struct vbc *vbc; + struct pollfd pfd; + + CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); + + Lck_Lock(&tp->mtx); + vbc = VTAILQ_FIRST(&tp->connlist); + if (vbc != NULL) { + CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); + + pfd.fd = vbc->fd; + pfd.events = POLLIN; + pfd.revents = 0; + if (poll(&pfd, 1, 0)) { + /* + * If this vbc is dead assume the rest of the list + * has also been chopped from the other end. + */ + VSC_C_main->backend_toolate++; + do { + VTAILQ_REMOVE(&tp->connlist, vbc, list); +#if 0 + VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); +#else + vbc->backend = NULL; + (void)close(vbc->fd); + vbc->fd = -1; + VBE_ReleaseConn(vbc); +#endif + vbc = VTAILQ_FIRST(&tp->connlist); + } while (vbc != NULL); + } else { + VTAILQ_REMOVE(&tp->connlist, vbc, list); + VSC_C_main->backend_reuse += 1; + } + } + Lck_Unlock(&tp->mtx); + if (vbc != NULL) + return (vbc); + return (NULL); +} From phk at FreeBSD.org Wed Jan 14 09:01:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 10:01:24 +0100 Subject: [master] bf43a64 Split waiter stuff into private and public headers Message-ID: commit bf43a6479bbb623d3aff70db208350cb17e4dd39 Author: Poul-Henning Kamp Date: Wed Jan 14 09:00:53 2015 +0000 Split waiter stuff into private and public headers diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index c0f6c1f..b5aafb0 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -102,7 +102,8 @@ noinst_HEADERS = \ mgt/mgt_param.h \ storage/storage.h \ storage/storage_persistent.h \ - waiter/waiter.h + waiter/waiter.h \ + waiter/waiter_priv.h # Headers for use with vmods nobase_pkginclude_HEADERS = \ diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index f9d3a42..82f2175 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -38,14 +38,7 @@ #include "cache/cache.h" #include "waiter/waiter.h" - -struct waiter { - unsigned magic; -#define WAITER_MAGIC 0x17c399db - const struct waiter_impl *impl; - void *priv; - int pfd; -}; +#include "waiter/waiter_priv.h" const char * WAIT_GetName(void) diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index e8c7110..6c25918 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -42,6 +42,7 @@ #include "cache/cache.h" #include "waiter/waiter.h" +#include "waiter/waiter_priv.h" #include "vtim.h" #include "vfil.h" diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 4fcdbfa..162c799 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -44,6 +44,7 @@ #include "cache/cache.h" #include "waiter/waiter.h" +#include "waiter/waiter_priv.h" #include "vtim.h" #include "vfil.h" diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index d7c8f92..9029007 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -37,6 +37,7 @@ #include "cache/cache.h" #include "waiter/waiter.h" +#include "waiter/waiter_priv.h" #include "vtim.h" #include "vfil.h" diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index be110c0..6599ea3 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -43,6 +43,7 @@ #include "cache/cache.h" #include "waiter/waiter.h" +#include "waiter/waiter_priv.h" #include "vtim.h" #define MAX_EVENTS 256 diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 89f2949..54c3c34 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -36,6 +36,7 @@ #include "common/common.h" #include "waiter/waiter.h" +#include "waiter/waiter_priv.h" static const struct waiter_impl *const waiter_impls[] = { #if defined(HAVE_KQUEUE) diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index e1b24d3..be9791d 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -38,6 +38,8 @@ * - kqueue on FreeBSD * - epoll on Linux * - ports on Solaris + * + * Public interfaces */ struct waited; @@ -49,17 +51,9 @@ enum wait_event { WAITER_ACTION }; -typedef void waiter_handle_f(struct waited *, enum wait_event, double now); -typedef void* waiter_init_f(waiter_handle_f *, int *, volatile double *); -typedef int waiter_pass_f(void *priv, struct waited *); - #define WAITER_DEFAULT "platform dependent" -struct waiter_impl { - const char *name; - waiter_init_f *init; - waiter_pass_f *pass; -}; +typedef void waiter_handle_f(struct waited *, enum wait_event, double now); /* cache_waiter.c */ int WAIT_Enter(const struct waiter *, struct waited *); @@ -67,19 +61,4 @@ struct waiter *WAIT_Init(waiter_handle_f *, volatile double *timeout); const char *WAIT_GetName(void); /* mgt_waiter.c */ -extern struct waiter_impl const * waiter; int WAIT_tweak_waiter(struct vsb *vsb, const char *arg); - -#if defined(HAVE_EPOLL_CTL) -extern const struct waiter_impl waiter_epoll; -#endif - -#if defined(HAVE_KQUEUE) -extern const struct waiter_impl waiter_kqueue; -#endif - -#if defined(HAVE_PORT_CREATE) -extern const struct waiter_impl waiter_ports; -#endif - -extern const struct waiter_impl waiter_poll; diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h new file mode 100644 index 0000000..afa8cf0 --- /dev/null +++ b/bin/varnishd/waiter/waiter_priv.h @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software 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. + * + * Private interfaces + */ + +struct waited; + +struct waiter { + unsigned magic; + #define WAITER_MAGIC 0x17c399db + const struct waiter_impl *impl; + void *priv; + int pfd; +}; + +typedef void* waiter_init_f(waiter_handle_f *, int *, volatile double *); +typedef int waiter_pass_f(void *priv, struct waited *); + +struct waiter_impl { + const char *name; + waiter_init_f *init; + waiter_pass_f *pass; +}; + +/* mgt_waiter.c */ +extern struct waiter_impl const * waiter; + +#if defined(HAVE_EPOLL_CTL) +extern const struct waiter_impl waiter_epoll; +#endif + +#if defined(HAVE_KQUEUE) +extern const struct waiter_impl waiter_kqueue; +#endif + +#if defined(HAVE_PORT_CREATE) +extern const struct waiter_impl waiter_ports; +#endif + +extern const struct waiter_impl waiter_poll; From lkarsten at varnish-software.com Wed Jan 14 09:19:16 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 14 Jan 2015 10:19:16 +0100 Subject: [master] 61a8700 Bump copyright. Message-ID: commit 61a8700674bcdc2a7e93277be3fa7fad5f0880ff Author: Lasse Karstensen Date: Wed Jan 14 10:16:46 2015 +0100 Bump copyright. This adds a minor change I by mistake added to a merge commit in an 4.0 commit. (12a6d79c) diff --git a/varnish.m4 b/varnish.m4 index e0eff8c..8339cb0 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -1,7 +1,7 @@ # varnish.m4 - Macros to locate Varnish header files. -*- Autoconf -*- # serial 3 (varnish-4.0) -# Copyright (c) 2013-2014 Varnish Software AS +# Copyright (c) 2013-2015 Varnish Software AS # All rights reserved. # # Author: Tollef Fog Heen From phk at FreeBSD.org Wed Jan 14 09:24:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 10:24:13 +0100 Subject: [master] 777bbff Slight shuffling of deskchairs. Message-ID: commit 777bbffc9da811016bab90a34621e3f2626039cb Author: Poul-Henning Kamp Date: Wed Jan 14 09:23:51 2015 +0000 Slight shuffling of deskchairs. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 82f2175..e44b896 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -55,16 +55,12 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) { struct waiter *w; - ALLOC_OBJ(w, WAITER_MAGIC); - AN(w); - w->pfd = -1; - AN(waiter); AN(waiter->name); AN(waiter->init); + w = waiter->init(func, tmo); w->impl = waiter; - w->priv = w->impl->init(func, &w->pfd, tmo); - AN(waiter->pass || w->pfd >= 0); + AN(w->impl->pass || w->pfd > 0); return (w); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 6c25918..8a753f4 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -55,6 +55,7 @@ struct vwe { unsigned magic; #define VWE_MAGIC 0x6bd73424 + struct waiter waiter[1]; pthread_t epoll_thread; pthread_t timer_thread; @@ -215,18 +216,19 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ -static void * __match_proto__(waiter_init_f) -vwe_init(waiter_handle_f *func, int *pfd, volatile double *tmo) +static struct waiter * __match_proto__(waiter_init_f) +vwe_init(waiter_handle_f *func, volatile double *tmo) { struct vwe *vwe; AN(func); - AN(pfd); AN(tmo); ALLOC_OBJ(vwe, VWE_MAGIC); AN(vwe); + INIT_OBJ(vwe->waiter, WAITER_MAGIC); + VTAILQ_INIT(&vwe->sesshead); AZ(pipe(vwe->pipes)); AZ(pipe(vwe->timer_pipes)); @@ -237,12 +239,12 @@ vwe_init(waiter_handle_f *func, int *pfd, volatile double *tmo) vwe->func = func; vwe->tmo = tmo; - *pfd = vwe->pipes[1]; + vwe->waiter->pfd = vwe->pipes[1]; AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); - return(vwe); + return(vwe->waiter); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 162c799..77c41e4 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -53,6 +53,8 @@ struct vwk { unsigned magic; #define VWK_MAGIC 0x1cc2acc2 + struct waiter waiter[1]; + waiter_handle_f *func; volatile double *tmo; pthread_t thread; @@ -211,17 +213,18 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ -static void * __match_proto__(waiter_init_f) -vwk_init(waiter_handle_f *func, int *pfd, volatile double *tmo) +static struct waiter * __match_proto__(waiter_init_f) +vwk_init(waiter_handle_f *func, volatile double *tmo) { struct vwk *vwk; AN(func); - AN(pfd); AN(tmo); ALLOC_OBJ(vwk, VWK_MAGIC); AN(vwk); + INIT_OBJ(vwk->waiter, WAITER_MAGIC); + vwk->func = func; vwk->tmo = tmo; @@ -230,10 +233,10 @@ vwk_init(waiter_handle_f *func, int *pfd, volatile double *tmo) AZ(VFIL_nonblocking(vwk->pipes[0])); AZ(VFIL_nonblocking(vwk->pipes[1])); - *pfd = vwk->pipes[1]; + vwk->waiter->pfd = vwk->pipes[1]; AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); - return (vwk); + return (vwk->waiter); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 9029007..bb8e791 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -46,6 +46,8 @@ struct vwp { unsigned magic; #define VWP_MAGIC 0x4b2cc735 + struct waiter waiter[1]; + waiter_handle_f *func; volatile double *tmo; int pipes[2]; @@ -195,15 +197,16 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ -static void * __match_proto__(waiter_init_f) -vwp_poll_init(waiter_handle_f *func, int *pfd, volatile double *tmo) +static struct waiter * __match_proto__(waiter_init_f) +vwp_poll_init(waiter_handle_f *func, volatile double *tmo) { struct vwp *vwp; AN(func); - AN(pfd); ALLOC_OBJ(vwp, VWP_MAGIC); AN(vwp); + INIT_OBJ(vwp->waiter, WAITER_MAGIC); + VTAILQ_INIT(&vwp->sesshead); AZ(pipe(vwp->pipes)); @@ -211,11 +214,11 @@ vwp_poll_init(waiter_handle_f *func, int *pfd, volatile double *tmo) vwp->tmo = tmo; AZ(VFIL_nonblocking(vwp->pipes[1])); - *pfd = vwp->pipes[1]; + vwp->waiter->pfd = vwp->pipes[1]; vwp_pollspace(vwp, 256); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); - return (vwp); + return (vwp->waiter); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 6599ea3..ab764c2 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -51,6 +51,8 @@ struct vws { unsigned magic; #define VWS_MAGIC 0x0b771473 + struct waiter waiter[1]; + waiter_handle_f *func; volatile double *tmo; pthread_t ports_thread; @@ -257,21 +259,22 @@ vws_pass(void *priv, struct waited *sp) /*--------------------------------------------------------------------*/ -static void * __match_proto__(waiter_init_f) -vws_init(waiter_handle_f *func, int *pfd, volatile double *tmo) +static struct waiter * __match_proto__(waiter_init_f) +vws_init(waiter_handle_f *func, volatile double *tmo) { struct vws *vws; AN(func); - AN(pfd); AN(tmo); ALLOC_OBJ(vws, VWS_MAGIC); AN(vws); + INIT_OBJ(vws->waiter, WAITER_MAGIC); + vws->func = func; vws->tmo = tmo; VTAILQ_INIT(&vws->sesshead); AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); - return (vws); + return (vws->waiter); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index afa8cf0..b397bba 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -39,7 +39,7 @@ struct waiter { int pfd; }; -typedef void* waiter_init_f(waiter_handle_f *, int *, volatile double *); +typedef struct waiter* waiter_init_f(waiter_handle_f *, volatile double *); typedef int waiter_pass_f(void *priv, struct waited *); struct waiter_impl { From phk at FreeBSD.org Wed Jan 14 09:47:03 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 10:47:03 +0100 Subject: [master] cbdb487 More shuffling deskchairs in waiters. Message-ID: commit cbdb48740bf6321d337d6bf3d952b8763b6291af Author: Poul-Henning Kamp Date: Wed Jan 14 09:46:49 2015 +0000 More shuffling deskchairs in waiters. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index e44b896..5f22f38 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -60,6 +60,8 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) AN(waiter->init); w = waiter->init(func, tmo); w->impl = waiter; + w->func = func; + w->tmo = tmo; AN(w->impl->pass || w->pfd > 0); return (w); } @@ -83,3 +85,13 @@ WAIT_Enter(const struct waiter *w, struct waited *wp) assert (written == sizeof wp); return (0); } + +void +WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) +{ + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + + VTAILQ_REMOVE(&w->sesshead, wp, list); + w->func(wp, ev, now); +} diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 8a753f4..ae0d831 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -64,7 +64,6 @@ struct vwe { waiter_handle_f *func; volatile double *tmo; - VTAILQ_HEAD(,waited) sesshead; int pipes[2]; int timer_pipes[2]; }; @@ -117,7 +116,7 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) while (i >= sizeof ss[0]) { CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwe->sesshead, ss[j], list); + VTAILQ_INSERT_TAIL(&vwe->waiter->sesshead, ss[j], list); vwe_cond_modadd(vwe, ss[j]->fd, ss[j]); j++; i -= sizeof ss[0]; @@ -127,17 +126,13 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) } else { CAST_OBJ_NOTNULL(sp, ep->data.ptr, WAITED_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { - VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, WAITER_ACTION, now); + WAIT_handle(vwe->waiter, sp, WAITER_ACTION, now); } else if (ep->events & EPOLLERR) { - VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, WAITER_REMCLOSE, now); + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLHUP) { - VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, WAITER_REMCLOSE, now); + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLRDHUP) { - VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, WAITER_REMCLOSE, now); + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } } } @@ -183,13 +178,12 @@ vwe_thread(void *priv) /* check for timeouts */ deadline = now - *vwe->tmo; for (;;) { - sp = VTAILQ_FIRST(&vwe->sesshead); + sp = VTAILQ_FIRST(&vwe->waiter->sesshead); if (sp == NULL) break; if (sp->deadline > deadline) break; - VTAILQ_REMOVE(&vwe->sesshead, sp, list); - vwe->func(sp, WAITER_TIMEOUT, now); + WAIT_handle(vwe->waiter, sp, WAITER_TIMEOUT, now); } } return (NULL); @@ -229,7 +223,7 @@ vwe_init(waiter_handle_f *func, volatile double *tmo) INIT_OBJ(vwe->waiter, WAITER_MAGIC); - VTAILQ_INIT(&vwe->sesshead); + VTAILQ_INIT(&vwe->waiter->sesshead); AZ(pipe(vwe->pipes)); AZ(pipe(vwe->timer_pipes)); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 77c41e4..d5017a4 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -62,7 +62,6 @@ struct vwk { int kq; struct kevent ki[NKEV]; unsigned nki; - VTAILQ_HEAD(,waited) sesshead; }; /*--------------------------------------------------------------------*/ @@ -107,7 +106,7 @@ vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp) while (i >= sizeof ss[0]) { CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwk->sesshead, ss[j], list); + VTAILQ_INSERT_TAIL(&vwk->waiter->sesshead, ss[j], list); vwk_kq_sess(vwk, ss[j], EV_ADD | EV_ONESHOT); j++; i -= sizeof ss[0]; @@ -127,12 +126,10 @@ vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now) CAST_OBJ_NOTNULL(sp, kp->udata, WAITED_MAGIC); if (kp->data > 0) { - VTAILQ_REMOVE(&vwk->sesshead, sp, list); - vwk->func(sp, WAITER_ACTION, now); + WAIT_handle(vwk->waiter, sp, WAITER_ACTION, now); return; } else if (kp->flags & EV_EOF) { - VTAILQ_REMOVE(&vwk->sesshead, sp, list); - vwk->func(sp, WAITER_REMCLOSE, now); + WAIT_handle(vwk->waiter, sp, WAITER_REMCLOSE, now); return; } else { WRONG("unknown kqueue state"); @@ -198,14 +195,12 @@ vwk_thread(void *priv) vwk_kq_flush(vwk); deadline = now - *vwk->tmo; for (;;) { - sp = VTAILQ_FIRST(&vwk->sesshead); + sp = VTAILQ_FIRST(&vwk->waiter->sesshead); if (sp == NULL) break; if (sp->deadline > deadline) break; - VTAILQ_REMOVE(&vwk->sesshead, sp, list); - // XXX: not yet (void)VTCP_linger(sp->fd, 0); - vwk->func(sp, WAITER_TIMEOUT, now); + WAIT_handle(vwk->waiter, sp, WAITER_TIMEOUT, now); } } NEEDLESS_RETURN(NULL); @@ -228,7 +223,7 @@ vwk_init(waiter_handle_f *func, volatile double *tmo) vwk->func = func; vwk->tmo = tmo; - VTAILQ_INIT(&vwk->sesshead); + VTAILQ_INIT(&vwk->waiter->sesshead); AZ(pipe(vwk->pipes)); AZ(VFIL_nonblocking(vwk->pipes[0])); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index bb8e791..d504d14 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -55,8 +55,6 @@ struct vwp { struct pollfd *pollfd; unsigned npoll; unsigned hpoll; - - VTAILQ_HEAD(,waited) sesshead; }; /*--------------------------------------------------------------------*/ @@ -150,7 +148,7 @@ vwp_main(void *priv) now = VTIM_real(); deadline = now - *vwp->tmo; v2 = v; - VTAILQ_FOREACH_SAFE(sp, &vwp->sesshead, list, sp2) { + VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->sesshead, list, sp2) { if (v != 0 && v2 == 0) break; CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); @@ -162,14 +160,13 @@ vwp_main(void *priv) if (vwp->pollfd[fd].revents) { v2--; vwp->pollfd[fd].revents = 0; - VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); - vwp->func(sp, WAITER_ACTION, now); + WAIT_handle(vwp->waiter, sp, WAITER_ACTION, + now); } else if (sp->deadline <= deadline) { - VTAILQ_REMOVE(&vwp->sesshead, sp, list); vwp_unpoll(vwp, fd); - // XXX: not yet (void)VTCP_linger(sp->fd, 0); - vwp->func(sp, WAITER_TIMEOUT, now); + WAIT_handle(vwp->waiter, sp, WAITER_TIMEOUT, + now); } } if (v2 && vwp->pollfd[vwp->pipes[0]].revents) { @@ -186,7 +183,7 @@ vwp_main(void *priv) for (j = 0; j * sizeof ss[0] < i; j++) { CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwp->sesshead, ss[j], list); + VTAILQ_INSERT_TAIL(&vwp->waiter->sesshead, ss[j], list); vwp_poll(vwp, ss[j]->fd); } } @@ -207,7 +204,7 @@ vwp_poll_init(waiter_handle_f *func, volatile double *tmo) AN(vwp); INIT_OBJ(vwp->waiter, WAITER_MAGIC); - VTAILQ_INIT(&vwp->sesshead); + VTAILQ_INIT(&vwp->waiter->sesshead); AZ(pipe(vwp->pipes)); vwp->func = func; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index ab764c2..0e89509 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -57,7 +57,6 @@ struct vws { volatile double *tmo; pthread_t ports_thread; int dport; - VTAILQ_HEAD(,waited) sesshead; }; static inline void @@ -82,7 +81,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { if(ev->portev_source == PORT_SOURCE_USER) { CAST_OBJ_NOTNULL(sp, ev->portev_user, WAITED_MAGIC); assert(sp->fd >= 0); - VTAILQ_INSERT_TAIL(&vws->sesshead, sp, list); + VTAILQ_INSERT_TAIL(&vws->waiter->sesshead, sp, list); vws_add(vws, sp->fd, sp); } else { assert(ev->portev_source == PORT_SOURCE_FD); @@ -90,8 +89,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { assert(sp->fd >= 0); if(ev->portev_events & POLLERR) { vws_del(vws, sp->fd); - VTAILQ_REMOVE(&vws->sesshead, sp, list); - vws->func(sp, WAITER_REMCLOSE, now); + WAIT_handle(vws->waiter, sp, WAITER_REMCLOSE, now); return; } @@ -109,10 +107,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { * threadID=129476&tstart=0 */ vws_del(vws, sp->fd); - VTAILQ_REMOVE(&vws->sesshead, sp, list); - - /* also handle errors */ - vws->func(sp, WAITER_ACTION, now); + WAIT_handle(vws->waiter, sp, WAITER_ACTION, now); } return; } @@ -206,17 +201,14 @@ vws_thread(void *priv) */ for (;;) { - sp = VTAILQ_FIRST(&vws->sesshead); + sp = VTAILQ_FIRST(&vws->waiter->sesshead); if (sp == NULL) break; if (sp->deadline > deadline) { break; } - VTAILQ_REMOVE(&vws->sesshead, sp, list); - if(sp->fd != -1) { - vws_del(vws, sp->fd); - } - vws->func(sp, WAITER_TIMEOUT, now); + vws_del(vws, sp->fd); + WAIT_handle(vws->waiter, sp, WAITER_TIMEOUT, now); } /* @@ -272,7 +264,7 @@ vws_init(waiter_handle_f *func, volatile double *tmo) vws->func = func; vws->tmo = tmo; - VTAILQ_INIT(&vws->sesshead); + VTAILQ_INIT(&vws->waiter->sesshead); AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); return (vws->waiter); } diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index b397bba..9b90f1c 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -35,6 +35,11 @@ struct waiter { unsigned magic; #define WAITER_MAGIC 0x17c399db const struct waiter_impl *impl; + waiter_handle_f * func; + + volatile double *tmo; + VTAILQ_HEAD(,waited) sesshead; + void *priv; int pfd; }; @@ -48,6 +53,9 @@ struct waiter_impl { waiter_pass_f *pass; }; +/* cache_waiter.c */ +void WAIT_handle(struct waiter *, struct waited *, enum wait_event, double now); + /* mgt_waiter.c */ extern struct waiter_impl const * waiter; From phk at FreeBSD.org Wed Jan 14 10:33:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 11:33:14 +0100 Subject: [master] 3dc7838 Start generalizing the pipe-passing stuff for waiters Message-ID: commit 3dc7838f6fa944233e8a3e101839fed21f5b0335 Author: Poul-Henning Kamp Date: Wed Jan 14 10:32:57 2015 +0000 Start generalizing the pipe-passing stuff for waiters diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 5f22f38..78e901c 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -37,9 +37,13 @@ #include "cache/cache.h" +#include "vfil.h" + #include "waiter/waiter.h" #include "waiter/waiter_priv.h" +#define NEV 8192 + const char * WAIT_GetName(void) { @@ -66,6 +70,22 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) return (w); } +void +WAIT_UsePipe(struct waiter *w) +{ + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + + AN(waiter->inject); + AZ(pipe(w->pipes)); + AZ(VFIL_nonblocking(w->pipes[0])); + AZ(VFIL_nonblocking(w->pipes[1])); + w->pfd = w->pipes[1]; + ALLOC_OBJ(w->pipe_w, WAITED_MAGIC); + w->pipe_w->fd = w->pipes[0]; + w->pipe_w->deadline = 9e99; + waiter->inject(w, w->pipe_w); +} + int WAIT_Enter(const struct waiter *w, struct waited *wp) { @@ -89,9 +109,26 @@ WAIT_Enter(const struct waiter *w, struct waited *wp) void WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) { + struct waited *ss[NEV]; + int i, j; + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + if (wp == w->pipe_w) { + i = read(w->pipes[0], ss, sizeof ss); + if (i == -1 && errno == EAGAIN) + return; + for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { + CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); + assert(ss[j]->fd >= 0); + VTAILQ_INSERT_TAIL(&w->sesshead, ss[j], list); + w->impl->inject(w, ss[j]); + } + AZ(i); + return; + } + VTAILQ_REMOVE(&w->sesshead, wp, list); w->func(wp, ev, now); } diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index d5017a4..c721ab7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -46,7 +46,6 @@ #include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "vtim.h" -#include "vfil.h" #define NKEV 100 @@ -58,7 +57,6 @@ struct vwk { waiter_handle_f *func; volatile double *tmo; pthread_t thread; - int pipes[2]; int kq; struct kevent ki[NKEV]; unsigned nki; @@ -92,26 +90,15 @@ vwk_kq_sess(struct vwk *vwk, struct waited *sp, short arm) /*--------------------------------------------------------------------*/ static void -vwk_pipe_ev(struct vwk *vwk, const struct kevent *kp) +vwk_inject(const struct waiter *w, struct waited *wp) { - int i, j; - struct waited *ss[NKEV]; + struct vwk *vwk; - AN(kp->udata); - assert(kp->udata == vwk->pipes); - j = 0; - i = read(vwk->pipes[0], ss, sizeof ss); - if (i == -1 && errno == EAGAIN) - return; - while (i >= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwk->waiter->sesshead, ss[j], list); - vwk_kq_sess(vwk, ss[j], EV_ADD | EV_ONESHOT); - j++; - i -= sizeof ss[0]; - } - AZ(i); + CAST_OBJ_NOTNULL(vwk, w->priv, VWK_MAGIC); + if (wp == w->pipe_w) + vwk_kq_sess(vwk, wp, EV_ADD); + else + vwk_kq_sess(vwk, wp, EV_ADD | EV_ONESHOT); } /*--------------------------------------------------------------------*/ @@ -122,7 +109,6 @@ vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now) struct waited *sp; AN(kp->udata); - assert(kp->udata != vwk->pipes); CAST_OBJ_NOTNULL(sp, kp->udata, WAITED_MAGIC); if (kp->data > 0) { @@ -153,12 +139,7 @@ vwk_thread(void *priv) vwk->kq = kqueue(); assert(vwk->kq >= 0); - j = 0; - EV_SET(&ke[j], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); - j++; - EV_SET(&ke[j], vwk->pipes[0], EVFILT_READ, EV_ADD, 0, 0, vwk->pipes); - j++; - AZ(kevent(vwk->kq, ke, j, NULL, 0, NULL)); + vwk_kq_flush(vwk); vwk->nki = 0; while (1) { @@ -175,9 +156,6 @@ vwk_thread(void *priv) for (kp = ke, j = 0; j < n; j++, kp++) { if (kp->filter == EVFILT_TIMER) { dotimer = 1; - } else if (kp->filter == EVFILT_READ && - kp->udata == vwk->pipes) { - vwk_pipe_ev(vwk, kp); } else { assert(kp->filter == EVFILT_READ); vwk_sess_ev(vwk, kp, now); @@ -219,17 +197,17 @@ vwk_init(waiter_handle_f *func, volatile double *tmo) AN(vwk); INIT_OBJ(vwk->waiter, WAITER_MAGIC); + VTAILQ_INIT(&vwk->waiter->sesshead); + vwk->waiter->priv = vwk; + + EV_SET(&vwk->ki[vwk->nki], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); + vwk->nki++; + + WAIT_UsePipe(vwk->waiter); vwk->func = func; vwk->tmo = tmo; - VTAILQ_INIT(&vwk->waiter->sesshead); - AZ(pipe(vwk->pipes)); - - AZ(VFIL_nonblocking(vwk->pipes[0])); - AZ(VFIL_nonblocking(vwk->pipes[1])); - vwk->waiter->pfd = vwk->pipes[1]; - AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); return (vwk->waiter); } @@ -239,6 +217,7 @@ vwk_init(waiter_handle_f *func, volatile double *tmo) const struct waiter_impl waiter_kqueue = { .name = "kqueue", .init = vwk_init, + .inject = vwk_inject, }; #endif /* defined(HAVE_KQUEUE) */ diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 9b90f1c..59691f0 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -37,6 +37,9 @@ struct waiter { const struct waiter_impl *impl; waiter_handle_f * func; + int pipes[2]; + struct waited *pipe_w; + volatile double *tmo; VTAILQ_HEAD(,waited) sesshead; @@ -46,15 +49,18 @@ struct waiter { typedef struct waiter* waiter_init_f(waiter_handle_f *, volatile double *); typedef int waiter_pass_f(void *priv, struct waited *); +typedef void waiter_inject_f(const struct waiter *, struct waited *); struct waiter_impl { const char *name; waiter_init_f *init; waiter_pass_f *pass; + waiter_inject_f *inject; }; /* cache_waiter.c */ void WAIT_handle(struct waiter *, struct waited *, enum wait_event, double now); +void WAIT_UsePipe(struct waiter *w); /* mgt_waiter.c */ extern struct waiter_impl const * waiter; From phk at FreeBSD.org Wed Jan 14 11:23:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 12:23:00 +0100 Subject: [master] 65fbdd2 More rearranging the deskchairs in waiters Message-ID: commit 65fbdd20821f38bb87cee1113a7c6f5d79c32b60 Author: Poul-Henning Kamp Date: Wed Jan 14 11:22:44 2015 +0000 More rearranging the deskchairs in waiters diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 78e901c..3db1235 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -62,10 +62,17 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) AN(waiter); AN(waiter->name); AN(waiter->init); - w = waiter->init(func, tmo); + + w = calloc(1, sizeof (struct waiter) + waiter->size); + AN(w); + INIT_OBJ(w, WAITER_MAGIC); + w->priv = (void*)(w + 1); w->impl = waiter; w->func = func; w->tmo = tmo; + VTAILQ_INIT(&w->sesshead); + + waiter->init(w); AN(w->impl->pass || w->pfd > 0); return (w); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index ae0d831..09bbafd 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -55,15 +55,12 @@ struct vwe { unsigned magic; #define VWE_MAGIC 0x6bd73424 - struct waiter waiter[1]; + struct waiter *waiter; pthread_t epoll_thread; pthread_t timer_thread; int epfd; - waiter_handle_f *func; - volatile double *tmo; - int pipes[2]; int timer_pipes[2]; }; @@ -176,7 +173,7 @@ vwe_thread(void *priv) continue; /* check for timeouts */ - deadline = now - *vwe->tmo; + deadline = now - *vwe->waiter->tmo; for (;;) { sp = VTAILQ_FIRST(&vwe->waiter->sesshead); if (sp == NULL) @@ -210,20 +207,16 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ -static struct waiter * __match_proto__(waiter_init_f) -vwe_init(waiter_handle_f *func, volatile double *tmo) +static void __match_proto__(waiter_init_f) +vwe_init(struct waiter *w) { struct vwe *vwe; - AN(func); - AN(tmo); - - ALLOC_OBJ(vwe, VWE_MAGIC); - AN(vwe); - - INIT_OBJ(vwe->waiter, WAITER_MAGIC); + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + vwe = w->priv; + INIT_OBJ(vwe, VWE_MAGIC); + vwe->waiter = w; - VTAILQ_INIT(&vwe->waiter->sesshead); AZ(pipe(vwe->pipes)); AZ(pipe(vwe->timer_pipes)); @@ -231,14 +224,11 @@ vwe_init(waiter_handle_f *func, volatile double *tmo) AZ(VFIL_nonblocking(vwe->pipes[1])); AZ(VFIL_nonblocking(vwe->timer_pipes[0])); - vwe->func = func; - vwe->tmo = tmo; - vwe->waiter->pfd = vwe->pipes[1]; + w->pfd = vwe->pipes[1]; AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); - return(vwe->waiter); } /*--------------------------------------------------------------------*/ @@ -246,6 +236,7 @@ vwe_init(waiter_handle_f *func, volatile double *tmo) const struct waiter_impl waiter_epoll = { .name = "epoll", .init = vwe_init, + .size = sizeof(struct vwe), }; #endif /* defined(HAVE_EPOLL_CTL) */ diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index c721ab7..d7a62c5 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -52,10 +52,8 @@ struct vwk { unsigned magic; #define VWK_MAGIC 0x1cc2acc2 - struct waiter waiter[1]; + struct waiter *waiter; - waiter_handle_f *func; - volatile double *tmo; pthread_t thread; int kq; struct kevent ki[NKEV]; @@ -104,7 +102,7 @@ vwk_inject(const struct waiter *w, struct waited *wp) /*--------------------------------------------------------------------*/ static void -vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now) +vwk_sess_ev(const struct vwk *vwk, const struct kevent *kp, double now) { struct waited *sp; @@ -171,7 +169,7 @@ vwk_thread(void *priv) * would not know we meant "the old fd of this number". */ vwk_kq_flush(vwk); - deadline = now - *vwk->tmo; + deadline = now - *vwk->waiter->tmo; for (;;) { sp = VTAILQ_FIRST(&vwk->waiter->sesshead); if (sp == NULL) @@ -186,30 +184,22 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ -static struct waiter * __match_proto__(waiter_init_f) -vwk_init(waiter_handle_f *func, volatile double *tmo) +static void __match_proto__(waiter_init_f) +vwk_init(struct waiter *w) { struct vwk *vwk; - AN(func); - AN(tmo); - ALLOC_OBJ(vwk, VWK_MAGIC); - AN(vwk); + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + vwk = w->priv; + INIT_OBJ(vwk, VWK_MAGIC); + vwk->waiter = w; - INIT_OBJ(vwk->waiter, WAITER_MAGIC); - VTAILQ_INIT(&vwk->waiter->sesshead); - vwk->waiter->priv = vwk; - EV_SET(&vwk->ki[vwk->nki], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); vwk->nki++; WAIT_UsePipe(vwk->waiter); - vwk->func = func; - vwk->tmo = tmo; - AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); - return (vwk->waiter); } /*--------------------------------------------------------------------*/ @@ -218,6 +208,7 @@ const struct waiter_impl waiter_kqueue = { .name = "kqueue", .init = vwk_init, .inject = vwk_inject, + .size = sizeof(struct vwk), }; #endif /* defined(HAVE_KQUEUE) */ diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index d504d14..ef88736 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -46,10 +46,8 @@ struct vwp { unsigned magic; #define VWP_MAGIC 0x4b2cc735 - struct waiter waiter[1]; + struct waiter *waiter; - waiter_handle_f *func; - volatile double *tmo; int pipes[2]; pthread_t poll_thread; struct pollfd *pollfd; @@ -146,7 +144,7 @@ vwp_main(void *priv) v = poll(vwp->pollfd, vwp->hpoll + 1, 100); assert(v >= 0); now = VTIM_real(); - deadline = now - *vwp->tmo; + deadline = now - *vwp->waiter->tmo; v2 = v; VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->sesshead, list, sp2) { if (v != 0 && v2 == 0) @@ -194,28 +192,23 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ -static struct waiter * __match_proto__(waiter_init_f) -vwp_poll_init(waiter_handle_f *func, volatile double *tmo) +static void __match_proto__(waiter_init_f) +vwp_poll_init(struct waiter *w) { struct vwp *vwp; - AN(func); - ALLOC_OBJ(vwp, VWP_MAGIC); - AN(vwp); - INIT_OBJ(vwp->waiter, WAITER_MAGIC); + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + vwp = w->priv; + INIT_OBJ(vwp, VWP_MAGIC); + vwp->waiter = w; - VTAILQ_INIT(&vwp->waiter->sesshead); AZ(pipe(vwp->pipes)); - vwp->func = func; - vwp->tmo = tmo; - AZ(VFIL_nonblocking(vwp->pipes[1])); vwp->waiter->pfd = vwp->pipes[1]; vwp_pollspace(vwp, 256); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); - return (vwp->waiter); } /*--------------------------------------------------------------------*/ @@ -223,4 +216,5 @@ vwp_poll_init(waiter_handle_f *func, volatile double *tmo) const struct waiter_impl waiter_poll = { .name = "poll", .init = vwp_poll_init, + .size = sizeof(struct vwp), }; diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 0e89509..5b12374 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -51,10 +51,8 @@ struct vws { unsigned magic; #define VWS_MAGIC 0x0b771473 - struct waiter waiter[1]; + struct waiter *waiter; - waiter_handle_f *func; - volatile double *tmo; pthread_t ports_thread; int dport; }; @@ -191,7 +189,7 @@ vws_thread(void *priv) vws_port_ev(vws, ev + ei, now); /* check for timeouts */ - deadline = now - *vws->tmo; + deadline = now - *vws->waiter->tmo; /* * This loop assumes that the oldest sessions are always at the @@ -251,22 +249,17 @@ vws_pass(void *priv, struct waited *sp) /*--------------------------------------------------------------------*/ -static struct waiter * __match_proto__(waiter_init_f) -vws_init(waiter_handle_f *func, volatile double *tmo) +static void __match_proto__(waiter_init_f) +vws_init(struct waiter *w) { struct vws *vws; - AN(func); - AN(tmo); - ALLOC_OBJ(vws, VWS_MAGIC); - AN(vws); - INIT_OBJ(vws->waiter, WAITER_MAGIC); + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + vws = w->priv; + INIT_OBJ(vws, VWS_MAGIC); + vws->waiter = w; - vws->func = func; - vws->tmo = tmo; - VTAILQ_INIT(&vws->waiter->sesshead); AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); - return (vws->waiter); } /*--------------------------------------------------------------------*/ @@ -274,7 +267,8 @@ vws_init(waiter_handle_f *func, volatile double *tmo) const struct waiter_impl waiter_ports = { .name = "ports", .init = vws_init, - .pass = vws_pass + .pass = vws_pass, + .size = sizeof(struct vws), }; #endif /* defined(HAVE_PORT_CREATE) */ diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 59691f0..35a8db6 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -47,7 +47,7 @@ struct waiter { int pfd; }; -typedef struct waiter* waiter_init_f(waiter_handle_f *, volatile double *); +typedef void waiter_init_f(struct waiter *); typedef int waiter_pass_f(void *priv, struct waited *); typedef void waiter_inject_f(const struct waiter *, struct waited *); @@ -56,6 +56,7 @@ struct waiter_impl { waiter_init_f *init; waiter_pass_f *pass; waiter_inject_f *inject; + size_t size; }; /* cache_waiter.c */ From phk at FreeBSD.org Wed Jan 14 11:52:11 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 12:52:11 +0100 Subject: [master] 493f975 Convert waiter_poll to the central pipe code Message-ID: commit 493f9757e7e3d84e92a84fc12c85c833aab45754 Author: Poul-Henning Kamp Date: Wed Jan 14 11:51:57 2015 +0000 Convert waiter_poll to the central pipe code diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 3db1235..f719801 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -90,6 +90,7 @@ WAIT_UsePipe(struct waiter *w) ALLOC_OBJ(w->pipe_w, WAITED_MAGIC); w->pipe_w->fd = w->pipes[0]; w->pipe_w->deadline = 9e99; + VTAILQ_INSERT_HEAD(&w->sesshead, w->pipe_w, list); waiter->inject(w, w->pipe_w); } diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index d7a62c5..0170eb4 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -197,7 +197,7 @@ vwk_init(struct waiter *w) EV_SET(&vwk->ki[vwk->nki], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); vwk->nki++; - WAIT_UsePipe(vwk->waiter); + WAIT_UsePipe(w); AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); } diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ef88736..ddb2107 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -39,16 +39,12 @@ #include "waiter/waiter.h" #include "waiter/waiter_priv.h" #include "vtim.h" -#include "vfil.h" - -#define NEEV 128 struct vwp { unsigned magic; #define VWP_MAGIC 0x4b2cc735 struct waiter *waiter; - int pipes[2]; pthread_t poll_thread; struct pollfd *pollfd; unsigned npoll; @@ -102,6 +98,15 @@ vwp_poll(struct vwp *vwp, int fd) vwp->pollfd[fd].events = POLLIN; } +static void __match_proto__(waiter_inject_f) +vwp_inject(const struct waiter *w, struct waited *wp) +{ + struct vwp *vwp; + + CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); + vwp_poll(vwp, wp->fd); +} + static void vwp_unpoll(struct vwp *vwp, int fd) { @@ -125,27 +130,22 @@ vwp_main(void *priv) { int v, v2; struct vwp *vwp; - struct waited *ss[NEEV], *sp, *sp2; + struct waited *sp, *sp2; double now, deadline; - int i, j, fd; + int fd; CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); THR_SetName("cache-poll"); - vwp_poll(vwp, vwp->pipes[0]); - while (1) { assert(vwp->hpoll < vwp->npoll); while (vwp->hpoll > 0 && vwp->pollfd[vwp->hpoll].fd == -1) vwp->hpoll--; - assert(vwp->pipes[0] <= vwp->hpoll); - assert(vwp->pollfd[vwp->pipes[0]].fd == vwp->pipes[0]); - assert(vwp->pollfd[vwp->pipes[1]].fd == -1); v = poll(vwp->pollfd, vwp->hpoll + 1, 100); assert(v >= 0); + v2 = v; now = VTIM_real(); deadline = now - *vwp->waiter->tmo; - v2 = v; VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->sesshead, list, sp2) { if (v != 0 && v2 == 0) break; @@ -158,7 +158,8 @@ vwp_main(void *priv) if (vwp->pollfd[fd].revents) { v2--; vwp->pollfd[fd].revents = 0; - vwp_unpoll(vwp, fd); + if (sp != vwp->waiter->pipe_w) + vwp_unpoll(vwp, fd); WAIT_handle(vwp->waiter, sp, WAITER_ACTION, now); } else if (sp->deadline <= deadline) { @@ -167,25 +168,6 @@ vwp_main(void *priv) now); } } - if (v2 && vwp->pollfd[vwp->pipes[0]].revents) { - - if (vwp->pollfd[vwp->pipes[0]].revents != POLLIN) - VSL(SLT_Debug, 0, "pipe.revents= 0x%x", - vwp->pollfd[vwp->pipes[0]].revents); - assert(vwp->pollfd[vwp->pipes[0]].revents == POLLIN); - vwp->pollfd[vwp->pipes[0]].revents = 0; - v2--; - i = read(vwp->pipes[0], ss, sizeof ss); - assert(i >= 0); - AZ((unsigned)i % sizeof ss[0]); - for (j = 0; j * sizeof ss[0] < i; j++) { - CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwp->waiter->sesshead, ss[j], list); - vwp_poll(vwp, ss[j]->fd); - } - } - AZ(v2); } NEEDLESS_RETURN(NULL); } @@ -202,12 +184,8 @@ vwp_poll_init(struct waiter *w) INIT_OBJ(vwp, VWP_MAGIC); vwp->waiter = w; - AZ(pipe(vwp->pipes)); - - AZ(VFIL_nonblocking(vwp->pipes[1])); - vwp->waiter->pfd = vwp->pipes[1]; - vwp_pollspace(vwp, 256); + WAIT_UsePipe(w); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); } @@ -216,5 +194,6 @@ vwp_poll_init(struct waiter *w) const struct waiter_impl waiter_poll = { .name = "poll", .init = vwp_poll_init, + .inject = vwp_inject, .size = sizeof(struct vwp), }; From lkarsten at varnish-software.com Wed Jan 14 12:13:02 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 14 Jan 2015 13:13:02 +0100 Subject: [master] 6862bb6 Update copyright statement. Message-ID: commit 6862bb6338181304066f31f8937f31a3859f5cb3 Author: Lasse Karstensen Date: Wed Jan 14 13:11:42 2015 +0100 Update copyright statement. Copyright statement is updated according to the year of the last non-trivial change to the file. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6bbe87d..be6bc54 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index d67ed8f..3dc72ca 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 0f02784..faffadb 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 89e1649..0cda35e 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index bb46761..6f6e2e1 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index a803942..44997f1 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Martin Blix Grydeland diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 962aa9d..9f71aa7 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 71fa530..d204ef0 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8fca585..07801e8 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index fad6a2d..8030fe4 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1762815..bd6c932 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index eff9408..837a95f 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 2e54300..9925ea8 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 028f75c..2099c21 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Dag-Erling Sm?rgrav diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 66da39e..e080eee 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index e401da1..c6ea472 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index e4007c2..fdfe1de 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 9d08437..f3e2519 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 15e1bf4..7e3215f 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 5747b6a..a8c9959 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index ca013c6..15e4b77 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index f719801..ef36346 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishncsa/varnishncsa_options.c b/bin/varnishncsa/varnishncsa_options.c index 91fb2e0..5bd9277 100644 --- a/bin/varnishncsa/varnishncsa_options.c +++ b/bin/varnishncsa/varnishncsa_options.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Martin Blix Grydeland diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 7f00317..63b2e54 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index bea41e2..559e89e 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 25db49a..c397cb7 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2014 Varnish Software AS + * Copyright (c) 2008-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index b8b5ef8..8dd00eb 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -201,4 +201,4 @@ This document is licensed under the same licence as Varnish itself. See LICENCE for details. * Copyright (c) 2006 Verdens Gang AS -* Copyright (c) 2006-2014 Varnish Software AS +* Copyright (c) 2006-2015 Varnish Software AS diff --git a/include/tbl/req_body.h b/include/tbl/req_body.h index d28ada4..be0cd91 100644 --- a/include/tbl/req_body.h +++ b/include/tbl/req_body.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 42c57e2..55e6fa3 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 3f20184..5d8a281 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/include/vrt.h b/include/vrt.h index f9f77ba..bc4a73d 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/include/vsa.h b/include/vsa.h index 5974974..996afde 100644 --- a/include/vsa.h +++ b/include/vsa.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index b543d55..146a212 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index dcfb0cb..1295cc9 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2014 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index e582c0f..ea26bf2 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 #- # Copyright (c) 2006 Verdens Gang AS -# Copyright (c) 2006-2014 Varnish Software AS +# Copyright (c) 2006-2015 Varnish Software AS # All rights reserved. # # Author: Poul-Henning Kamp diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index cafd88d..b5d108c 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -1,5 +1,5 @@ # -# Copyright (c) 2010-2014 Varnish Software AS +# Copyright (c) 2010-2015 Varnish Software AS # All rights reserved. # # Author: Poul-Henning Kamp diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 1a5331b..b6736fb 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012-2014 Varnish Software AS + * Copyright (c) 2012-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 91dfa0d..19a966c 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 25b05dd..77ec45c 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 698e48d..c3def17 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 415a8ad..a0612f3 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index 26668ec..be92545 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 8ebefa4..938d6de 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index e8107ab..9214911 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Varnish Software AS + * Copyright (c) 2013-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index fe8f998..e660b07 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -1,5 +1,5 @@ #- -# Copyright (c) 2013 Varnish Software AS +# Copyright (c) 2013-2014 Varnish Software AS # All rights reserved. # # Author: Poul-Henning Kamp diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index c5d7c45..a93721b 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -1,5 +1,5 @@ #- -# Copyright (c) 2010-2014 Varnish Software AS +# Copyright (c) 2010-2015 Varnish Software AS # All rights reserved. # # Author: Poul-Henning Kamp diff --git a/man/vsc2rst.c b/man/vsc2rst.c index f25d2e1..a9a99fd 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011-2014 Varnish Software AS + * Copyright (c) 2011-2015 Varnish Software AS * All rights reserved. * * Author: Tollef Fog Heen From phk at FreeBSD.org Wed Jan 14 12:25:35 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 13:25:35 +0100 Subject: [master] 1972905 Change epoll waiter to use common pipe code. Message-ID: commit 197290518285b9528fbe2930b04f7b58b4919a36 Author: Poul-Henning Kamp Date: Wed Jan 14 12:24:20 2015 +0000 Change epoll waiter to use common pipe code. Various other cleanups while here. There are a couple of central things I do not understand about how this works, if anybody has epoll(2) clue, please contact me. diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 09bbafd..85026c6 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -61,76 +61,44 @@ struct vwe { pthread_t timer_thread; int epfd; - int pipes[2]; int timer_pipes[2]; }; static void -vwe_modadd(struct vwe *vwe, int fd, void *data, short arm) +vwe_inject(const struct waiter *w, struct waited *wp) { + struct vwe *vwe; - /* XXX: EPOLLET (edge triggered) can cause rather Bad Things to - * XXX: happen: If NEEV+1 threads get stuck in write(), all threads - * XXX: will hang. See #644. - */ - assert(fd >= 0); - assert(data == vwe->pipes || data == vwe->timer_pipes); - struct epoll_event ev = { - EPOLLIN | EPOLLPRI , { data } - }; - AZ(epoll_ctl(vwe->epfd, arm, fd, &ev)); -} - -static void -vwe_cond_modadd(struct vwe *vwe, int fd, void *data) -{ - struct waited *sp = (struct waited *)data; + CAST_OBJ_NOTNULL(vwe, w->priv, VWE_MAGIC); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + assert(wp->fd >= 0); - assert(fd >= 0); - CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); - if (sp->ev.data.ptr) - AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_MOD, fd, &sp->ev)); + if (wp->ev.data.ptr) + AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_MOD, wp->fd, &wp->ev)); else { - sp->ev.data.ptr = data; - sp->ev.events = EPOLLIN | EPOLLPRI | EPOLLONESHOT | EPOLLRDHUP; - AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_ADD, fd, &sp->ev)); + wp->ev.data.ptr = wp; + wp->ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP; + if (wp != w->pipe_w) + wp->ev.events |= EPOLLONESHOT; + AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_ADD, wp->fd, &wp->ev)); } } static void vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) { - struct waited *ss[NEEV], *sp; - int i, j; + struct waited *sp; AN(ep->data.ptr); - if (ep->data.ptr == vwe->pipes) { - if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { - j = 0; - i = read(vwe->pipes[0], ss, sizeof ss); - if (i == -1 && errno == EAGAIN) - return; - while (i >= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&vwe->waiter->sesshead, ss[j], list); - vwe_cond_modadd(vwe, ss[j]->fd, ss[j]); - j++; - i -= sizeof ss[0]; - } - AZ(i); - } - } else { - CAST_OBJ_NOTNULL(sp, ep->data.ptr, WAITED_MAGIC); - if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { - WAIT_handle(vwe->waiter, sp, WAITER_ACTION, now); - } else if (ep->events & EPOLLERR) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); - } else if (ep->events & EPOLLHUP) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); - } else if (ep->events & EPOLLRDHUP) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); - } + CAST_OBJ_NOTNULL(sp, ep->data.ptr, WAITED_MAGIC); + if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { + WAIT_handle(vwe->waiter, sp, WAITER_ACTION, now); + } else if (ep->events & EPOLLERR) { + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); + } else if (ep->events & EPOLLHUP) { + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); + } else if (ep->events & EPOLLRDHUP) { + WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } } @@ -140,7 +108,7 @@ static void * vwe_thread(void *priv) { struct epoll_event ev[NEEV], *ep; - struct waited *sp; + struct waited *sp, *sp2; char junk; double now, deadline; int dotimer, i, n; @@ -150,12 +118,6 @@ vwe_thread(void *priv) THR_SetName("cache-epoll"); - vwe->epfd = epoll_create(1); - assert(vwe->epfd >= 0); - - vwe_modadd(vwe, vwe->pipes[0], vwe->pipes, EPOLL_CTL_ADD); - vwe_modadd(vwe, vwe->timer_pipes[0], vwe->timer_pipes, EPOLL_CTL_ADD); - while (1) { dotimer = 0; n = epoll_wait(vwe->epfd, ev, NEEV, -1); @@ -174,13 +136,10 @@ vwe_thread(void *priv) /* check for timeouts */ deadline = now - *vwe->waiter->tmo; - for (;;) { - sp = VTAILQ_FIRST(&vwe->waiter->sesshead); - if (sp == NULL) - break; - if (sp->deadline > deadline) - break; - WAIT_handle(vwe->waiter, sp, WAITER_TIMEOUT, now); + VTAILQ_FOREACH_SAFE(sp, &vwe->waiter->sesshead, list, sp2) { + if (sp->deadline < deadline) + WAIT_handle(vwe->waiter, sp, + WAITER_TIMEOUT, now); } } return (NULL); @@ -211,24 +170,27 @@ static void __match_proto__(waiter_init_f) vwe_init(struct waiter *w) { struct vwe *vwe; + struct epoll_event ev; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); vwe = w->priv; INIT_OBJ(vwe, VWE_MAGIC); vwe->waiter = w; - AZ(pipe(vwe->pipes)); - AZ(pipe(vwe->timer_pipes)); + vwe->epfd = epoll_create(1); + assert(vwe->epfd >= 0); - AZ(VFIL_nonblocking(vwe->pipes[0])); - AZ(VFIL_nonblocking(vwe->pipes[1])); - AZ(VFIL_nonblocking(vwe->timer_pipes[0])); + WAIT_UsePipe(w); - w->pfd = vwe->pipes[1]; + AZ(pipe(vwe->timer_pipes)); + AZ(VFIL_nonblocking(vwe->timer_pipes[0])); + ev.data.ptr = vwe->timer_pipes; + ev.events = EPOLLIN | EPOLLPRI; + AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_ADD, vwe->timer_pipes[0], &ev)); + AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); - AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); } /*--------------------------------------------------------------------*/ @@ -236,6 +198,7 @@ vwe_init(struct waiter *w) const struct waiter_impl waiter_epoll = { .name = "epoll", .init = vwe_init, + .inject = vwe_inject, .size = sizeof(struct vwe), }; From lkarsten at varnish-software.com Wed Jan 14 12:26:25 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 14 Jan 2015 13:26:25 +0100 Subject: [master] 2670d13 Forgotten copyrights in the last commit. Message-ID: commit 2670d132337d2cec92da9ae568758279a4492277 Author: Lasse Karstensen Date: Wed Jan 14 13:26:03 2015 +0100 Forgotten copyrights in the last commit. diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index 6757d90..8f4c038 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014 Varnish Software AS + * Copyright (c) 2014-2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 284c661..290db22 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 Varnish Software AS + * Copyright (c) 2006-2012 Varnish Software AS * All rights reserved. * * Author: Dag-Erling Sm?rgrav From lkarsten at varnish-software.com Wed Jan 14 12:38:22 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 14 Jan 2015 13:38:22 +0100 Subject: [master] fcea2a9 Forgotten meta copyright update. Message-ID: commit fcea2a99292d09e71a9b1b54f8b44b927c92a278 Author: Lasse Karstensen Date: Wed Jan 14 13:35:35 2015 +0100 Forgotten meta copyright update. Spotted by fgs. Also req_flags.h was originally made in 2015, not 2014. diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index 8f4c038..0571006 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2014-2015 Varnish Software AS + * Copyright (c) 2015 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 290db22..6171165 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2012 Varnish Software AS + * Copyright (c) 2006-2015 Varnish Software AS * All rights reserved. * * Author: Dag-Erling Sm?rgrav @@ -44,5 +44,5 @@ VCS_Message(const char *progname) { fprintf(stderr, "%s (%s)\n", progname, VCS_version); fprintf(stderr, "Copyright (c) 2006 Verdens Gang AS\n"); - fprintf(stderr, "Copyright (c) 2006-2014 Varnish Software AS\n"); + fprintf(stderr, "Copyright (c) 2006-2015 Varnish Software AS\n"); } From phk at FreeBSD.org Wed Jan 14 12:58:38 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 14 Jan 2015 13:58:38 +0100 Subject: [master] 1481db2 Fix oversight Message-ID: commit 1481db22dd8d62c91e430cc9887f0383cd9e05a5 Author: Poul-Henning Kamp Date: Wed Jan 14 12:58:10 2015 +0000 Fix oversight diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 5b12374..9bd110a 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -214,7 +214,7 @@ vws_thread(void *priv) */ if (sp) { - double tmo = (sp->deadline + *vws->tmo) - now; + double tmo = (sp->deadline + *vws->waiter->tmo) - now; if (tmo < min_t) { timeout = &min_ts; From phk at FreeBSD.org Thu Jan 15 10:29:02 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 11:29:02 +0100 Subject: [master] 1dc9a5c Move eviction to the common pipe implementation Message-ID: commit 1dc9a5cef5aae77bc377788fa8c66272303d11db Author: Poul-Henning Kamp Date: Thu Jan 15 10:27:27 2015 +0000 Move eviction to the common pipe implementation diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index ef36346..c5fed78 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -105,6 +105,7 @@ WAIT_Enter(const struct waiter *w, struct waited *wp) if (w->impl->pass != NULL) return (w->impl->pass(w->priv, wp)); + assert(w->pfd >= 0); written = write(w->pfd, &wp, sizeof wp); @@ -136,6 +137,8 @@ WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) AZ(i); return; } + if (w->impl->evict != NULL) + w->impl->evict(w, wp); VTAILQ_REMOVE(&w->sesshead, wp, list); w->func(wp, ev, now); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index ddb2107..44beabc 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -79,14 +79,18 @@ vwp_pollspace(struct vwp *vwp, unsigned fd) /*--------------------------------------------------------------------*/ -static void -vwp_poll(struct vwp *vwp, int fd) +static void __match_proto__(waiter_inject_f) +vwp_inject(const struct waiter *w, struct waited *wp) { + struct vwp *vwp; + int fd; + CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + fd = wp->fd; assert(fd >= 0); vwp_pollspace(vwp, (unsigned)fd); assert(fd < vwp->npoll); - if (vwp->hpoll < fd) vwp->hpoll = fd; @@ -98,19 +102,15 @@ vwp_poll(struct vwp *vwp, int fd) vwp->pollfd[fd].events = POLLIN; } -static void __match_proto__(waiter_inject_f) -vwp_inject(const struct waiter *w, struct waited *wp) +static void __match_proto__(waiter_evict_f) +vwp_evict(const struct waiter *w, struct waited *wp) { struct vwp *vwp; + int fd; CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); - vwp_poll(vwp, wp->fd); -} - -static void -vwp_unpoll(struct vwp *vwp, int fd) -{ - + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + fd = wp->fd; assert(fd >= 0); assert(fd < vwp->npoll); vwp_pollspace(vwp, (unsigned)fd); @@ -158,12 +158,9 @@ vwp_main(void *priv) if (vwp->pollfd[fd].revents) { v2--; vwp->pollfd[fd].revents = 0; - if (sp != vwp->waiter->pipe_w) - vwp_unpoll(vwp, fd); WAIT_handle(vwp->waiter, sp, WAITER_ACTION, now); } else if (sp->deadline <= deadline) { - vwp_unpoll(vwp, fd); WAIT_handle(vwp->waiter, sp, WAITER_TIMEOUT, now); } @@ -195,5 +192,6 @@ const struct waiter_impl waiter_poll = { .name = "poll", .init = vwp_poll_init, .inject = vwp_inject, + .evict = vwp_evict, .size = sizeof(struct vwp), }; diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 54c3c34..b9f8960 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -40,7 +40,7 @@ static const struct waiter_impl *const waiter_impls[] = { #if defined(HAVE_KQUEUE) - &waiter_kqueue, + // &waiter_kqueue, #endif #if defined(HAVE_EPOLL_CTL) &waiter_epoll, diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 35a8db6..a277327 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -50,12 +50,14 @@ struct waiter { typedef void waiter_init_f(struct waiter *); typedef int waiter_pass_f(void *priv, struct waited *); typedef void waiter_inject_f(const struct waiter *, struct waited *); +typedef void waiter_evict_f(const struct waiter *, struct waited *); struct waiter_impl { const char *name; waiter_init_f *init; waiter_pass_f *pass; waiter_inject_f *inject; + waiter_evict_f *evict; size_t size; }; From phk at FreeBSD.org Thu Jan 15 10:29:02 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 11:29:02 +0100 Subject: [master] 2b72a16 Undo test-hack Message-ID: commit 2b72a16ec486ef1934086c3cea24deaf3c4bc7c3 Author: Poul-Henning Kamp Date: Thu Jan 15 10:28:49 2015 +0000 Undo test-hack diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index b9f8960..54c3c34 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -40,7 +40,7 @@ static const struct waiter_impl *const waiter_impls[] = { #if defined(HAVE_KQUEUE) - // &waiter_kqueue, + &waiter_kqueue, #endif #if defined(HAVE_EPOLL_CTL) &waiter_epoll, From phk at FreeBSD.org Thu Jan 15 10:35:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 11:35:15 +0100 Subject: [master] 1520837 Systematic rename to make things consistent Message-ID: commit 1520837fde2789d7c0cdd1067d46f52a4e2a24a1 Author: Poul-Henning Kamp Date: Thu Jan 15 10:35:00 2015 +0000 Systematic rename to make things consistent diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 2099c21..85a0c45 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -539,7 +539,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, VSB_printf(pan_vsp, "version = %s\n", VCS_version); VSB_printf(pan_vsp, "ident = %s,%s\n", - VSB_data(vident) + 1, WAIT_GetName()); + VSB_data(vident) + 1, Wait_GetName()); pan_backtrace(); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 0089282..814005a 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -296,7 +296,7 @@ SES_Wait(struct sess *sp) sp->waited.fd = sp->fd; sp->waited.ptr = sp; sp->waited.deadline = sp->t_idle; - if (WAIT_Enter(pp->http1_waiter, &sp->waited)) { + if (Wait_Enter(pp->http1_waiter, &sp->waited)) { VSC_C_main->sess_pipe_overflow++; SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); } @@ -467,7 +467,7 @@ SES_NewPool(struct pool *wp, unsigned pool_no) bprintf(nb, "sess%u", pool_no); pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &cache_param->workspace_session); - pp->http1_waiter = WAIT_Init(ses_handle, &cache_param->timeout_idle); + pp->http1_waiter = Wait_New(ses_handle, &cache_param->timeout_idle); return (pp); } diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 699fc79..f989307 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -574,7 +574,7 @@ tweak_waiter(struct vsb *vsb, const struct parspec *par, const char *arg) /* XXX should have tweak_generic_string */ (void)par; - return (WAIT_tweak_waiter(vsb, arg)); + return (Wait_Argument(vsb, arg)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index c5fed78..4b8fd6e 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -45,7 +45,7 @@ #define NEV 8192 const char * -WAIT_GetName(void) +Wait_GetName(void) { if (waiter != NULL) @@ -55,7 +55,7 @@ WAIT_GetName(void) } struct waiter * -WAIT_Init(waiter_handle_f *func, volatile double *tmo) +Wait_New(waiter_handle_f *func, volatile double *tmo) { struct waiter *w; @@ -70,7 +70,7 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) w->impl = waiter; w->func = func; w->tmo = tmo; - VTAILQ_INIT(&w->sesshead); + VTAILQ_INIT(&w->waithead); waiter->init(w); AN(w->impl->pass || w->pfd > 0); @@ -78,7 +78,7 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo) } void -WAIT_UsePipe(struct waiter *w) +Wait_UsePipe(struct waiter *w) { CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); @@ -90,12 +90,12 @@ WAIT_UsePipe(struct waiter *w) ALLOC_OBJ(w->pipe_w, WAITED_MAGIC); w->pipe_w->fd = w->pipes[0]; w->pipe_w->deadline = 9e99; - VTAILQ_INSERT_HEAD(&w->sesshead, w->pipe_w, list); + VTAILQ_INSERT_HEAD(&w->waithead, w->pipe_w, list); waiter->inject(w, w->pipe_w); } int -WAIT_Enter(const struct waiter *w, struct waited *wp) +Wait_Enter(const struct waiter *w, struct waited *wp) { ssize_t written; @@ -116,7 +116,7 @@ WAIT_Enter(const struct waiter *w, struct waited *wp) } void -WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) +Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) { struct waited *ss[NEV]; int i, j; @@ -131,7 +131,7 @@ WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&w->sesshead, ss[j], list); + VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); w->impl->inject(w, ss[j]); } AZ(i); @@ -140,6 +140,6 @@ WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) if (w->impl->evict != NULL) w->impl->evict(w, wp); - VTAILQ_REMOVE(&w->sesshead, wp, list); + VTAILQ_REMOVE(&w->waithead, wp, list); w->func(wp, ev, now); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 85026c6..a281f6b 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -92,13 +92,13 @@ vwe_eev(struct vwe *vwe, const struct epoll_event *ep, double now) AN(ep->data.ptr); CAST_OBJ_NOTNULL(sp, ep->data.ptr, WAITED_MAGIC); if (ep->events & EPOLLIN || ep->events & EPOLLPRI) { - WAIT_handle(vwe->waiter, sp, WAITER_ACTION, now); + Wait_Handle(vwe->waiter, sp, WAITER_ACTION, now); } else if (ep->events & EPOLLERR) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); + Wait_Handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLHUP) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); + Wait_Handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } else if (ep->events & EPOLLRDHUP) { - WAIT_handle(vwe->waiter, sp, WAITER_REMCLOSE, now); + Wait_Handle(vwe->waiter, sp, WAITER_REMCLOSE, now); } } @@ -136,9 +136,9 @@ vwe_thread(void *priv) /* check for timeouts */ deadline = now - *vwe->waiter->tmo; - VTAILQ_FOREACH_SAFE(sp, &vwe->waiter->sesshead, list, sp2) { + VTAILQ_FOREACH_SAFE(sp, &vwe->waiter->waithead, list, sp2) { if (sp->deadline < deadline) - WAIT_handle(vwe->waiter, sp, + Wait_Handle(vwe->waiter, sp, WAITER_TIMEOUT, now); } } @@ -180,7 +180,7 @@ vwe_init(struct waiter *w) vwe->epfd = epoll_create(1); assert(vwe->epfd >= 0); - WAIT_UsePipe(w); + Wait_UsePipe(w); AZ(pipe(vwe->timer_pipes)); AZ(VFIL_nonblocking(vwe->timer_pipes[0])); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 0170eb4..422dabe 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -110,10 +110,10 @@ vwk_sess_ev(const struct vwk *vwk, const struct kevent *kp, double now) CAST_OBJ_NOTNULL(sp, kp->udata, WAITED_MAGIC); if (kp->data > 0) { - WAIT_handle(vwk->waiter, sp, WAITER_ACTION, now); + Wait_Handle(vwk->waiter, sp, WAITER_ACTION, now); return; } else if (kp->flags & EV_EOF) { - WAIT_handle(vwk->waiter, sp, WAITER_REMCLOSE, now); + Wait_Handle(vwk->waiter, sp, WAITER_REMCLOSE, now); return; } else { WRONG("unknown kqueue state"); @@ -171,12 +171,12 @@ vwk_thread(void *priv) vwk_kq_flush(vwk); deadline = now - *vwk->waiter->tmo; for (;;) { - sp = VTAILQ_FIRST(&vwk->waiter->sesshead); + sp = VTAILQ_FIRST(&vwk->waiter->waithead); if (sp == NULL) break; if (sp->deadline > deadline) break; - WAIT_handle(vwk->waiter, sp, WAITER_TIMEOUT, now); + Wait_Handle(vwk->waiter, sp, WAITER_TIMEOUT, now); } } NEEDLESS_RETURN(NULL); @@ -197,7 +197,7 @@ vwk_init(struct waiter *w) EV_SET(&vwk->ki[vwk->nki], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); vwk->nki++; - WAIT_UsePipe(w); + Wait_UsePipe(w); AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); } diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 44beabc..dfaac80 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -146,7 +146,7 @@ vwp_main(void *priv) v2 = v; now = VTIM_real(); deadline = now - *vwp->waiter->tmo; - VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->sesshead, list, sp2) { + VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->waithead, list, sp2) { if (v != 0 && v2 == 0) break; CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); @@ -158,10 +158,10 @@ vwp_main(void *priv) if (vwp->pollfd[fd].revents) { v2--; vwp->pollfd[fd].revents = 0; - WAIT_handle(vwp->waiter, sp, WAITER_ACTION, + Wait_Handle(vwp->waiter, sp, WAITER_ACTION, now); } else if (sp->deadline <= deadline) { - WAIT_handle(vwp->waiter, sp, WAITER_TIMEOUT, + Wait_Handle(vwp->waiter, sp, WAITER_TIMEOUT, now); } } @@ -182,7 +182,7 @@ vwp_poll_init(struct waiter *w) vwp->waiter = w; vwp_pollspace(vwp, 256); - WAIT_UsePipe(w); + Wait_UsePipe(w); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); } diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 9bd110a..76dad22 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -79,7 +79,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { if(ev->portev_source == PORT_SOURCE_USER) { CAST_OBJ_NOTNULL(sp, ev->portev_user, WAITED_MAGIC); assert(sp->fd >= 0); - VTAILQ_INSERT_TAIL(&vws->waiter->sesshead, sp, list); + VTAILQ_INSERT_TAIL(&vws->waiter->waithead, sp, list); vws_add(vws, sp->fd, sp); } else { assert(ev->portev_source == PORT_SOURCE_FD); @@ -87,7 +87,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { assert(sp->fd >= 0); if(ev->portev_events & POLLERR) { vws_del(vws, sp->fd); - WAIT_handle(vws->waiter, sp, WAITER_REMCLOSE, now); + Wait_Handle(vws->waiter, sp, WAITER_REMCLOSE, now); return; } @@ -105,7 +105,7 @@ vws_port_ev(struct vws *vws, port_event_t *ev, double now) { * threadID=129476&tstart=0 */ vws_del(vws, sp->fd); - WAIT_handle(vws->waiter, sp, WAITER_ACTION, now); + Wait_Handle(vws->waiter, sp, WAITER_ACTION, now); } return; } @@ -199,14 +199,14 @@ vws_thread(void *priv) */ for (;;) { - sp = VTAILQ_FIRST(&vws->waiter->sesshead); + sp = VTAILQ_FIRST(&vws->waiter->waithead); if (sp == NULL) break; if (sp->deadline > deadline) { break; } vws_del(vws, sp->fd); - WAIT_handle(vws->waiter, sp, WAITER_TIMEOUT, now); + Wait_Handle(vws->waiter, sp, WAITER_TIMEOUT, now); } /* diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 54c3c34..18e370c 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -55,7 +55,7 @@ static const struct waiter_impl *const waiter_impls[] = { struct waiter_impl const *waiter; int -WAIT_tweak_waiter(struct vsb *vsb, const char *arg) +Wait_Argument(struct vsb *vsb, const char *arg) { int i; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index be9791d..4c41001 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -56,9 +56,9 @@ enum wait_event { typedef void waiter_handle_f(struct waited *, enum wait_event, double now); /* cache_waiter.c */ -int WAIT_Enter(const struct waiter *, struct waited *); -struct waiter *WAIT_Init(waiter_handle_f *, volatile double *timeout); -const char *WAIT_GetName(void); +int Wait_Enter(const struct waiter *, struct waited *); +struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout); +const char *Wait_GetName(void); /* mgt_waiter.c */ -int WAIT_tweak_waiter(struct vsb *vsb, const char *arg); +int Wait_Argument(struct vsb *vsb, const char *arg); diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index a277327..336328d 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -41,7 +41,7 @@ struct waiter { struct waited *pipe_w; volatile double *tmo; - VTAILQ_HEAD(,waited) sesshead; + VTAILQ_HEAD(,waited) waithead; void *priv; int pfd; @@ -62,8 +62,8 @@ struct waiter_impl { }; /* cache_waiter.c */ -void WAIT_handle(struct waiter *, struct waited *, enum wait_event, double now); -void WAIT_UsePipe(struct waiter *w); +void Wait_Handle(struct waiter *, struct waited *, enum wait_event, double now); +void Wait_UsePipe(struct waiter *w); /* mgt_waiter.c */ extern struct waiter_impl const * waiter; From phk at FreeBSD.org Thu Jan 15 11:47:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 12:47:28 +0100 Subject: [master] b9d8796 Centralise the timer/poker function of pipe-based waiters, so that we can avoid thundering-herd/resonance phenomena when we have multiple waiters. Message-ID: commit b9d87969b5955d21713d437cec22af547b7663b1 Author: Poul-Henning Kamp Date: Thu Jan 15 11:46:18 2015 +0000 Centralise the timer/poker function of pipe-based waiters, so that we can avoid thundering-herd/resonance phenomena when we have multiple waiters. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index be6bc54..fed05d1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -397,7 +397,7 @@ struct waited { VTAILQ_ENTRY(waited) list; int fd; void *ptr; - double deadline; + double idle; #if defined(HAVE_EPOLL_CTL) struct epoll_event ev; #endif diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index cfce5cc..bc55e99 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -39,6 +39,7 @@ #include "vcli_priv.h" #include "vrnd.h" +#include "waiter/waiter.h" #include "hash/hash_slinger.h" @@ -214,6 +215,8 @@ child_main(void) CLI_Init(); VFP_Init(); + Wait_Init(); + VCL_Init(); HTTP_Init(); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 814005a..822c0a2 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -295,7 +295,7 @@ SES_Wait(struct sess *sp) sp->waited.magic = WAITED_MAGIC; sp->waited.fd = sp->fd; sp->waited.ptr = sp; - sp->waited.deadline = sp->t_idle; + sp->waited.idle = sp->t_idle; if (Wait_Enter(pp->http1_waiter, &sp->waited)) { VSC_C_main->sess_pipe_overflow++; SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 4b8fd6e..6d88566 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -38,12 +38,53 @@ #include "cache/cache.h" #include "vfil.h" +#include "vtim.h" #include "waiter/waiter.h" #include "waiter/waiter_priv.h" #define NEV 8192 +static VTAILQ_HEAD(, waiter) waiters = VTAILQ_HEAD_INITIALIZER(waiters); +static int nwaiters; +static struct lock wait_mtx; +static pthread_t wait_thr; + +static void * +wait_poker_thread(void *arg) +{ + struct waiter *w; + struct waited *wp; + double now; + + (void)arg; + THR_SetName("Waiter timer"); + while (1) { + /* Avoid thundering herds and resonances */ + (void)usleep(990013/nwaiters); + + now = VTIM_real(); + + Lck_Lock(&wait_mtx); + w = VTAILQ_FIRST(&waiters); + VTAILQ_REMOVE(&waiters, w, list); + VTAILQ_INSERT_TAIL(&waiters, w, list); + assert(w->pipes[1] >= 0); + + wp = VTAILQ_FIRST(&w->waithead); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + if (wp == w->pipe_w) { + VTAILQ_REMOVE(&w->waithead, wp, list); + VTAILQ_INSERT_TAIL(&w->waithead, wp, list); + wp = VTAILQ_FIRST(&w->waithead); + } + if (wp->idle + *w->tmo < now) + (void)write(w->pipes[1], &w->pipe_w, sizeof w->pipe_w); + Lck_Unlock(&wait_mtx); + } + NEEDLESS_RETURN(NULL); +} + const char * Wait_GetName(void) { @@ -70,10 +111,21 @@ Wait_New(waiter_handle_f *func, volatile double *tmo) w->impl = waiter; w->func = func; w->tmo = tmo; + w->pipes[0] = w->pipes[1] = -1; VTAILQ_INIT(&w->waithead); waiter->init(w); - AN(w->impl->pass || w->pfd > 0); + AN(w->impl->pass || w->pipes[1] >= 0); + + if (w->pipes[1] >= 0 && VTAILQ_EMPTY(&waiters)) { + /* Start timer poker thread */ + AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL)); + } + + Lck_Lock(&wait_mtx); + VTAILQ_INSERT_TAIL(&waiters, w, list); + nwaiters++; + Lck_Unlock(&wait_mtx); return (w); } @@ -86,10 +138,9 @@ Wait_UsePipe(struct waiter *w) AZ(pipe(w->pipes)); AZ(VFIL_nonblocking(w->pipes[0])); AZ(VFIL_nonblocking(w->pipes[1])); - w->pfd = w->pipes[1]; ALLOC_OBJ(w->pipe_w, WAITED_MAGIC); w->pipe_w->fd = w->pipes[0]; - w->pipe_w->deadline = 9e99; + w->pipe_w->idle = 9e99; VTAILQ_INSERT_HEAD(&w->waithead, w->pipe_w, list); waiter->inject(w, w->pipe_w); } @@ -106,9 +157,9 @@ Wait_Enter(const struct waiter *w, struct waited *wp) if (w->impl->pass != NULL) return (w->impl->pass(w->priv, wp)); - assert(w->pfd >= 0); + assert(w->pipes[1] > 0); - written = write(w->pfd, &wp, sizeof wp); + written = write(w->pipes[1], &wp, sizeof wp); if (written != sizeof wp && (errno == EAGAIN || errno == EWOULDBLOCK)) return (-1); assert (written == sizeof wp); @@ -118,28 +169,55 @@ Wait_Enter(const struct waiter *w, struct waited *wp) void Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) { - struct waited *ss[NEV]; - int i, j; + struct waited *ss[NEV], *wp2; + int i, j, dotimer = 0; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - if (wp == w->pipe_w) { - i = read(w->pipes[0], ss, sizeof ss); - if (i == -1 && errno == EAGAIN) - return; - for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); - w->impl->inject(w, ss[j]); + if (wp != w->pipe_w) { + if (w->impl->evict != NULL) + w->impl->evict(w, wp); + + VTAILQ_REMOVE(&w->waithead, wp, list); + w->func(wp, ev, now); + return; + } + + i = read(w->pipes[0], ss, sizeof ss); + if (i == -1 && errno == EAGAIN) + return; + + for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { + CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); + if (ss[j] == w->pipe_w) { + dotimer = 1; + continue; } - AZ(i); + assert(ss[j]->fd >= 0); + VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); + w->impl->inject(w, ss[j]); + } + AZ(i); + + if (!dotimer) return; + + VTAILQ_FOREACH_SAFE(wp, &w->waithead, list, wp2) { + if (wp == w->pipe_w) + continue; + if (wp->idle + *w->tmo > now) + break; + if (w->impl->evict != NULL) + w->impl->evict(w, wp); + VTAILQ_REMOVE(&w->waithead, wp, list); + w->func(wp, WAITER_TIMEOUT, now); } - if (w->impl->evict != NULL) - w->impl->evict(w, wp); +} + +void +Wait_Init(void) +{ - VTAILQ_REMOVE(&w->waithead, wp, list); - w->func(wp, ev, now); + Lck_New(&wait_mtx, lck_misc); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index a281f6b..8f63c78 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -110,7 +110,7 @@ vwe_thread(void *priv) struct epoll_event ev[NEEV], *ep; struct waited *sp, *sp2; char junk; - double now, deadline; + double now, idle; int dotimer, i, n; struct vwe *vwe; @@ -135,9 +135,9 @@ vwe_thread(void *priv) continue; /* check for timeouts */ - deadline = now - *vwe->waiter->tmo; + idle = now - *vwe->waiter->tmo; VTAILQ_FOREACH_SAFE(sp, &vwe->waiter->waithead, list, sp2) { - if (sp->deadline < deadline) + if (sp->idle < idle) Wait_Handle(vwe->waiter, sp, WAITER_TIMEOUT, now); } diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 422dabe..8609048 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -127,9 +127,8 @@ vwk_thread(void *priv) { struct vwk *vwk; struct kevent ke[NKEV], *kp; - int j, n, dotimer; - double now, deadline; - struct waited *sp; + int j, n; + double now; CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); THR_SetName("cache-kqueue"); @@ -141,42 +140,17 @@ vwk_thread(void *priv) vwk->nki = 0; while (1) { - dotimer = 0; n = kevent(vwk->kq, vwk->ki, vwk->nki, ke, NKEV, NULL); - now = VTIM_real(); assert(n <= NKEV); if (n == 0) { /* This happens on OSX in m00011.vtc */ - dotimer = 1; (void)usleep(10000); } vwk->nki = 0; + now = VTIM_real(); for (kp = ke, j = 0; j < n; j++, kp++) { - if (kp->filter == EVFILT_TIMER) { - dotimer = 1; - } else { - assert(kp->filter == EVFILT_READ); - vwk_sess_ev(vwk, kp, now); - } - } - if (!dotimer) - continue; - /* - * Make sure we have no pending changes for the fd's - * we are about to close, in case the accept(2) in the - * other thread creates new fd's betwen our close and - * the kevent(2) at the top of this loop, the kernel - * would not know we meant "the old fd of this number". - */ - vwk_kq_flush(vwk); - deadline = now - *vwk->waiter->tmo; - for (;;) { - sp = VTAILQ_FIRST(&vwk->waiter->waithead); - if (sp == NULL) - break; - if (sp->deadline > deadline) - break; - Wait_Handle(vwk->waiter, sp, WAITER_TIMEOUT, now); + assert(kp->filter == EVFILT_READ); + vwk_sess_ev(vwk, kp, now); } } NEEDLESS_RETURN(NULL); @@ -194,9 +168,6 @@ vwk_init(struct waiter *w) INIT_OBJ(vwk, VWK_MAGIC); vwk->waiter = w; - EV_SET(&vwk->ki[vwk->nki], 0, EVFILT_TIMER, EV_ADD, 0, 100, NULL); - vwk->nki++; - Wait_UsePipe(w); AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index dfaac80..48c3cd7 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -131,7 +131,7 @@ vwp_main(void *priv) int v, v2; struct vwp *vwp; struct waited *sp, *sp2; - double now, deadline; + double now, idle; int fd; CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); @@ -141,11 +141,11 @@ vwp_main(void *priv) assert(vwp->hpoll < vwp->npoll); while (vwp->hpoll > 0 && vwp->pollfd[vwp->hpoll].fd == -1) vwp->hpoll--; - v = poll(vwp->pollfd, vwp->hpoll + 1, 100); + v = poll(vwp->pollfd, vwp->hpoll + 1, -1); assert(v >= 0); v2 = v; now = VTIM_real(); - deadline = now - *vwp->waiter->tmo; + idle = now - *vwp->waiter->tmo; VTAILQ_FOREACH_SAFE(sp, &vwp->waiter->waithead, list, sp2) { if (v != 0 && v2 == 0) break; @@ -160,7 +160,7 @@ vwp_main(void *priv) vwp->pollfd[fd].revents = 0; Wait_Handle(vwp->waiter, sp, WAITER_ACTION, now); - } else if (sp->deadline <= deadline) { + } else if (sp->idle <= idle) { Wait_Handle(vwp->waiter, sp, WAITER_TIMEOUT, now); } diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 76dad22..158a624 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -154,7 +154,7 @@ vws_thread(void *priv) port_event_t ev[MAX_EVENTS]; u_int nevents; int ei, ret; - double now, deadline; + double now, idle; /* * XXX Do we want to scale this up dynamically to increase @@ -189,7 +189,7 @@ vws_thread(void *priv) vws_port_ev(vws, ev + ei, now); /* check for timeouts */ - deadline = now - *vws->waiter->tmo; + idle = now - *vws->waiter->tmo; /* * This loop assumes that the oldest sessions are always at the @@ -202,7 +202,7 @@ vws_thread(void *priv) sp = VTAILQ_FIRST(&vws->waiter->waithead); if (sp == NULL) break; - if (sp->deadline > deadline) { + if (sp->idle > idle) { break; } vws_del(vws, sp->fd); @@ -214,7 +214,7 @@ vws_thread(void *priv) */ if (sp) { - double tmo = (sp->deadline + *vws->waiter->tmo) - now; + double tmo = (sp->idle + *vws->waiter->tmo) - now; if (tmo < min_t) { timeout = &min_ts; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 4c41001..ee4b6bc 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -59,6 +59,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now); int Wait_Enter(const struct waiter *, struct waited *); struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout); const char *Wait_GetName(void); +void Wait_Init(void); /* mgt_waiter.c */ int Wait_Argument(struct vsb *vsb, const char *arg); diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 336328d..ba0d0e5 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -35,6 +35,8 @@ struct waiter { unsigned magic; #define WAITER_MAGIC 0x17c399db const struct waiter_impl *impl; + VTAILQ_ENTRY(waiter) list; + waiter_handle_f * func; int pipes[2]; @@ -44,7 +46,6 @@ struct waiter { VTAILQ_HEAD(,waited) waithead; void *priv; - int pfd; }; typedef void waiter_init_f(struct waiter *); diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 1a01782..e4b4914 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -54,4 +54,5 @@ LOCK(busyobj) LOCK(mempool) LOCK(vxid) LOCK(pipestat) +LOCK(misc) /*lint -restore */ From phk at FreeBSD.org Thu Jan 15 12:20:07 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 13:20:07 +0100 Subject: [master] 197bc2a Cache the next idle value rather than frob the waited list. Message-ID: commit 197bc2a25c4b59dcd002743db91e67c01f0ab624 Author: Poul-Henning Kamp Date: Thu Jan 15 12:19:51 2015 +0000 Cache the next idle value rather than frob the waited list. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 6d88566..8390b72 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -54,7 +54,6 @@ static void * wait_poker_thread(void *arg) { struct waiter *w; - struct waited *wp; double now; (void)arg; @@ -71,14 +70,7 @@ wait_poker_thread(void *arg) VTAILQ_INSERT_TAIL(&waiters, w, list); assert(w->pipes[1] >= 0); - wp = VTAILQ_FIRST(&w->waithead); - CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - if (wp == w->pipe_w) { - VTAILQ_REMOVE(&w->waithead, wp, list); - VTAILQ_INSERT_TAIL(&w->waithead, wp, list); - wp = VTAILQ_FIRST(&w->waithead); - } - if (wp->idle + *w->tmo < now) + if (w->next_idle + *w->tmo < now) (void)write(w->pipes[1], &w->pipe_w, sizeof w->pipe_w); Lck_Unlock(&wait_mtx); } @@ -166,6 +158,22 @@ Wait_Enter(const struct waiter *w, struct waited *wp) return (0); } +static void +wait_updidle(struct waiter *w) +{ + struct waited *wp; + + wp = VTAILQ_FIRST(&w->waithead); + if (wp == NULL) + return; + if (wp == w->pipe_w) { + VTAILQ_REMOVE(&w->waithead, wp, list); + VTAILQ_INSERT_TAIL(&w->waithead, wp, list); + wp = VTAILQ_FIRST(&w->waithead); + } + w->next_idle = wp->idle; +} + void Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) { @@ -181,6 +189,7 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) VTAILQ_REMOVE(&w->waithead, wp, list); w->func(wp, ev, now); + wait_updidle(w); return; } @@ -213,6 +222,7 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) VTAILQ_REMOVE(&w->waithead, wp, list); w->func(wp, WAITER_TIMEOUT, now); } + wait_updidle(w); } void diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index ba0d0e5..14b5e6f 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -41,6 +41,7 @@ struct waiter { int pipes[2]; struct waited *pipe_w; + double next_idle; volatile double *tmo; VTAILQ_HEAD(,waited) waithead; From phk at FreeBSD.org Thu Jan 15 14:32:09 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 15:32:09 +0100 Subject: [master] 6493630 Give the pipe-waited structure a regular timestamp, and recycle it as appropriate. Message-ID: commit 64936302a94423d854403f475d80486c99349514 Author: Poul-Henning Kamp Date: Thu Jan 15 14:31:39 2015 +0000 Give the pipe-waited structure a regular timestamp, and recycle it as appropriate. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 8390b72..88b61c2 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -132,7 +132,7 @@ Wait_UsePipe(struct waiter *w) AZ(VFIL_nonblocking(w->pipes[1])); ALLOC_OBJ(w->pipe_w, WAITED_MAGIC); w->pipe_w->fd = w->pipes[0]; - w->pipe_w->idle = 9e99; + w->pipe_w->idle = 0; VTAILQ_INSERT_HEAD(&w->waithead, w->pipe_w, list); waiter->inject(w, w->pipe_w); } @@ -159,7 +159,7 @@ Wait_Enter(const struct waiter *w, struct waited *wp) } static void -wait_updidle(struct waiter *w) +wait_updidle(struct waiter *w, double now) { struct waited *wp; @@ -169,6 +169,7 @@ wait_updidle(struct waiter *w) if (wp == w->pipe_w) { VTAILQ_REMOVE(&w->waithead, wp, list); VTAILQ_INSERT_TAIL(&w->waithead, wp, list); + wp->idle = now; wp = VTAILQ_FIRST(&w->waithead); } w->next_idle = wp->idle; @@ -189,10 +190,14 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) VTAILQ_REMOVE(&w->waithead, wp, list); w->func(wp, ev, now); - wait_updidle(w); + wait_updidle(w, now); return; } + VTAILQ_REMOVE(&w->waithead, wp, list); + wp->idle = now; + VTAILQ_INSERT_TAIL(&w->waithead, wp, list); + i = read(w->pipes[0], ss, sizeof ss); if (i == -1 && errno == EAGAIN) return; @@ -222,7 +227,7 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) VTAILQ_REMOVE(&w->waithead, wp, list); w->func(wp, WAITER_TIMEOUT, now); } - wait_updidle(w); + wait_updidle(w, now); } void From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] f38f446 Document -v param in vcl.show Message-ID: commit f38f4460e5b058b82d880cea97c83871b0f321df Author: Federico G. Schwindt Date: Wed Oct 8 17:10:35 2014 +0100 Document -v param in vcl.show diff --git a/include/vcli.h b/include/vcli.h index f6b75da..4a18c82 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -97,7 +97,7 @@ #define CLI_VCL_SHOW \ "vcl.show", \ - "vcl.show ", \ + "vcl.show [-v] ", \ "\tDisplay the source code for the specified configuration.", \ 1, 2 From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] 79f4c29 Document how comments work in VCL. Message-ID: commit 79f4c2931fdc210de812d9e73a5c1a69d4f973cf Author: Lasse Karstensen Date: Wed Oct 8 17:21:27 2014 +0200 Document how comments work in VCL. This was mentioned in the user guide, but not in the man page itself. Pointed out by: Brett Fitzgerald diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 90ac019..a621e4f 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -166,6 +166,21 @@ Example:: std.log("foo"); } +Comments +-------- + +Single lines of VCL can be commented out using // or #. Multi-line blocks can +be commented out with \/\* block \/\*. + +Example:: + + sub vcl_recv { + // Single line of out-commented VCL. + # Another way of commenting out a single line. + /* + Multi-line block of commented-out VCL. + */ + } Backend definition From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] b338ff8 Spelling Message-ID: commit b338ff80d9bcde2bc9b34051003a55c19a180ce3 Author: Federico G. Schwindt Date: Thu Oct 9 13:01:55 2014 +0100 Spelling diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 845fbcb..9c04907 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -38,7 +38,7 @@ * 'c' - Counter, never decreases. * 'g' - Gauge, goes up and down * 'i' - Integer (deprecated, use 'g') - * e - Explantion: Short explanation of field (for screen use) + * e - Explanation: Short explanation of field (for screen use) * d - Description: Long explanation of field (for doc use) * * Please describe Gauge variables as "Number of..." to indicate that @@ -73,7 +73,7 @@ VSC_F(uptime, uint64_t, 0, 'a', info, VSC_F(sess_conn, uint64_t, 1, 'c', info, "Sessions accepted", - "Count of sessions succesfully accepted" + "Count of sessions successfully accepted" ) VSC_F(sess_drop, uint64_t, 1, 'c', info, @@ -85,7 +85,7 @@ VSC_F(sess_fail, uint64_t, 1, 'c', info, "Session accept failures", "Count of failures to accept TCP connection." " Either the client changed its mind, or the kernel ran out of" - " some resource like filedescriptors." + " some resource like file descriptors." ) VSC_F(sess_pipe_overflow, uint64_t, 1, 'c', info, @@ -108,7 +108,7 @@ VSC_F(client_req_411, uint64_t, 1, 'a', info, VSC_F(client_req_413, uint64_t, 1, 'a', info, "Client requests received, subject to 413 errors", - "413 means that HTTP headers execeeded length or count limits." + "413 means that HTTP headers exceeded length or count limits." ) VSC_F(client_req_417, uint64_t, 1, 'a', info, @@ -397,7 +397,7 @@ VSC_F(s_resp_hdrbytes, uint64_t, 1, 'a', info, "Total response header bytes transmitted" ) VSC_F(s_resp_bodybytes, uint64_t, 1, 'a', info, - "Reponse body bytes", + "Response body bytes", "Total response body bytes transmitted" ) VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'a', info, From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] 0077964 document bereq.uncacheable and beresp.uncacheable Message-ID: commit 00779649cb758f0cbfad3c509f1a1ffe43df31fc Author: Nils Goroll Date: Thu Oct 9 17:00:10 2014 +0200 document bereq.uncacheable and beresp.uncacheable diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 9af3420..44c0c55 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -360,6 +360,16 @@ sp_variables = [ 'BOOL', ( 'backend', ), ( 'backend', ), """ + Indicates whether the object requested from the backend is + going to be uncacheable - either because the request was an + explicit pass from the client side or a hit on an uncacheable + ("hit for pass") object. + + Setting this variable in vcl_backend_fetch makes the object + uncacheable. + + Clearing the variable has no effect and will log the warning + "Ignoring attempt to reset bereq.uncacheable". """ ), ('bereq.connect_timeout', @@ -461,6 +471,13 @@ sp_variables = [ 'BOOL', ( 'backend_response', 'backend_error'), ( 'backend_response', 'backend_error'), """ + Inherited from bereq.uncacheable, see there. + + Setting this variable makes the object uncacheable, which may + get stored as a hit-for-pass object in the cache. + + Clearing the variable has no effect and will log the warning + "Ignoring attempt to reset beresp.uncacheable". """ ), ('beresp.ttl', From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] d68e896 document keep Message-ID: commit d68e89668dcaa9c7d41d82c52909747e3dd74c42 Author: Nils Goroll Date: Thu Oct 9 17:07:08 2014 +0200 document keep diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 44c0c55..bf94c69 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -499,6 +499,13 @@ sp_variables = [ 'DURATION', ( 'backend_response', 'backend_error'), ( 'backend_response', 'backend_error'), """ + Set to a period to enable conditional backend requests. + + The keep time is cache lifetime in addition to the ttl. + + Objects with ttl expired but with keep time left may be used + to issue conditional (If-Modified-Since / If-None-Match) + requests to the backend to refresh them. """ ), ('beresp.backend.name', From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] b105356 document some more object variables Message-ID: commit b10535627b3c3780cf20ec3fb25d2b7fe5773b04 Author: Nils Goroll Date: Thu Oct 9 17:24:54 2014 +0200 document some more object variables diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index bf94c69..5ba1405 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -581,19 +581,21 @@ sp_variables = [ 'DURATION', ( 'hit', ), ( ), """ - The object's grace period in seconds. + The object's remaining grace period in seconds. """ ), ('obj.keep', 'DURATION', ( 'hit', ), ( ), """ + The object's remaining keep period in seconds. """ ), ('obj.uncacheable', 'BOOL', ( 'hit', ), ( ), """ + Whether the object is uncacheable (aka hit-for-pass) """ ), ('resp', From lkarsten at varnish-software.com Thu Jan 15 15:35:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:39 +0100 Subject: [4.0] 74cae57 make bereq.uncacheable read-only outside backend_fetch Message-ID: commit 74cae57337794b51b53f358fdf893bd54d181b65 Author: Nils Goroll Date: Thu Oct 9 17:28:20 2014 +0200 make bereq.uncacheable read-only outside backend_fetch Writing to bereq.uncacheable in backend_response and backend_error would only make sense in the context of a retry. In most real world cases, writing to be*resp*.uncacheable would be intended in backend_response and backend_error. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 5ba1405..10ab8d3 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -359,7 +359,7 @@ sp_variables = [ ('bereq.uncacheable', 'BOOL', ( 'backend', ), - ( 'backend', ), """ + ( 'backend_fetch', ), """ Indicates whether the object requested from the backend is going to be uncacheable - either because the request was an explicit pass from the client side or a hit on an uncacheable From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 8e7e7fb Include the Varnish version on panic Message-ID: commit 8e7e7fb22384a469ed343d9390914b4a43c6e55e Author: Federico G. Schwindt Date: Thu Oct 9 19:21:56 2014 +0100 Include the Varnish version on panic diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 575d049..c179736 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -468,6 +468,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (q != NULL) VSB_printf(pan_vsp, "thread = (%s)\n", q); + VSB_printf(pan_vsp, "version = %s\n", VCS_version); VSB_printf(pan_vsp, "ident = %s,%s\n", VSB_data(vident) + 1, WAIT_GetName()); From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 836c461 vcl_pass might return fetch, not pass Message-ID: commit 836c4611c99b8e0a637ed008187d15c1e2e0a7a5 Author: Federico G. Schwindt Date: Thu Oct 9 22:42:45 2014 +0100 vcl_pass might return fetch, not pass Spotted by: coredump diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 9c9c690..276265c 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -73,7 +73,7 @@ of the following keywords: synth(status code, reason) Return the specified status code to the client and abandon the request. - pass + fetch Proceed with pass mode. restart From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] a0a757c Skip the argument names when writing the prototypes Message-ID: commit a0a757c0b23760dec0f5d5e0b427cc8d76364efe Author: Federico G. Schwindt Date: Fri Oct 10 00:13:26 2014 +0100 Skip the argument names when writing the prototypes diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2861b40..f437c22 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -366,8 +366,6 @@ class Func(object): for a in self.al: s += p + ctypes[a.typ] p = ", " - if a.nam != None: - s += " " + a.nam s += ");" return s From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] e51095a document vcl_synth Message-ID: commit e51095aaf3c23e62a0e2ea33cb3ecb09c3cd38ce Author: Per Buer Date: Fri Oct 10 09:02:53 2014 +0200 document vcl_synth diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 276265c..48b19c9 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -229,6 +229,23 @@ with one of the following keywords: the number of retries is higher than *max_retries* Varnish emits a guru meditation error. +vcl_synth +~~~~~~~~~ + +Called to deliver a synthetic object. A synthetic object is generated +in VCL, not fetched from the backend. It is typically contructed using +the synthetic() function. + + +The subroutine may terminate with calling ``return()`` with one of the +following keywords: + + deliver + Deliver the object. If the object has a positive TTL then the + object is also stored in cache. + + restart + Restart processing the object. vcl_init ~~~~~~~~ From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 399c592 typo Message-ID: commit 399c592dc1a0fca099308c097b6d5a34f3d8e4b5 Author: Poul-Henning Kamp Date: Mon Oct 13 07:56:31 2014 +0000 typo diff --git a/doc/sphinx/phk/dough.rst b/doc/sphinx/phk/dough.rst index 3e71fe6..65b53f8 100644 --- a/doc/sphinx/phk/dough.rst +++ b/doc/sphinx/phk/dough.rst @@ -42,7 +42,7 @@ But in 2004 crowd-funding was not yet "in", and I had to figure out how to do it myself. My parents brought me up to think that finances is a private matter -but I concluded that the only way you could ask strangers to trow +but I concluded that the only way you could ask strangers to throw money at you, would be to run an open book, where they could see what happened to them, so I did open books. From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] a87c23f Update forgotten varnishlog example to 4.0 syntax. Message-ID: commit a87c23f3bd71a71c8542ca38bec95e8db02769d8 Author: Dag Haavi Finstad Date: Mon Oct 13 13:55:59 2014 +0200 Update forgotten varnishlog example to 4.0 syntax. Fixes: #1610 diff --git a/doc/sphinx/users-guide/troubleshooting.rst b/doc/sphinx/users-guide/troubleshooting.rst index d05b9d6..4be7543 100644 --- a/doc/sphinx/users-guide/troubleshooting.rst +++ b/doc/sphinx/users-guide/troubleshooting.rst @@ -106,16 +106,17 @@ give you a clue. Since `varnishlog` logs a lot of data it might be hard to track the entries down. You can set `varnishlog` to log all your 503 errors by issuing the following command:: - $ varnishlog -c -m TxStatus:503 + $ varnishlog -q 'RespStatus == 503' -g request If the error happened just a short time ago the transaction might still be in the shared memory log segment. To get `varnishlog` to process the whole shared memory log just add the '-d' parameter:: - $ varnishlog -d -c -m TxStatus:503 + $ varnishlog -d -q 'RespStatus == 503' -g request -Please see the `varnishlog` man page for elaborations on further -filtering capabilities and explanation of the various options. +Please see the `vsl-query` and `varnishlog` man pages for elaborations +on further filtering capabilities and explanation of the various +options. Varnish doesn't cache From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] e9326e4 Remove description lint. Message-ID: commit e9326e4a09cf9697a9fd2ccc90ac4ddea13f2f96 Author: Lasse Karstensen Date: Mon Oct 13 13:52:44 2014 +0200 Remove description lint. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 9c04907..a6dc1aa 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -117,7 +117,7 @@ VSC_F(client_req_417, uint64_t, 1, 'a', info, ) VSC_F(client_req, uint64_t, 1, 'a', info, - "Good Client requests received", + "Good client requests received", "" ) @@ -588,7 +588,7 @@ VSC_F(n_purges, uint64_t, 0, 'i', info, "" ) VSC_F(n_obj_purged, uint64_t, 0, 'i', info, - "number of purged objects", + "Number of purged objects", "" ) From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] ebc440d Improve counter descriptions. Message-ID: commit ebc440dd409a11e79c3604f60ca6f64438f8d9e7 Author: Lasse Karstensen Date: Mon Oct 13 13:53:23 2014 +0200 Improve counter descriptions. Make the help text for the VSC counters a bit more explanatory. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index a6dc1aa..c169e61 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -317,41 +317,41 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', info, /*---------------------------------------------------------------------*/ VSC_F(n_object, uint64_t, 1, 'i', info, - "N struct object", + "Number of object structs made", "" ) VSC_F(n_vampireobject, uint64_t, 1, 'i', diag, - "N unresurrected objects", + "Number of unresurrected objects", "" ) VSC_F(n_objectcore, uint64_t, 1, 'i', info, - "N struct objectcore", + "Number of objectcore structs made", "" ) VSC_F(n_objecthead, uint64_t, 1, 'i', info, - "N struct objecthead", + "Number of objecthead structs made", "" ) VSC_F(n_waitinglist, uint64_t, 1, 'i', debug, - "N struct waitinglist", + "Number of waitinglist structs made", "" ) VSC_F(n_backend, uint64_t, 0, 'i', info, - "N backends", + "Number of backends", "" ) VSC_F(n_expired, uint64_t, 0, 'i', info, - "N expired objects", + "Number of expired objects", "" ) VSC_F(n_lru_nuked, uint64_t, 0, 'i', info, - "N LRU nuked objects", + "Number of LRU nuked objects", "" ) VSC_F(n_lru_moved, uint64_t, 0, 'i', diag, - "N LRU moved objects", + "Number of LRU moved objects", "" ) @@ -361,27 +361,27 @@ VSC_F(losthdr, uint64_t, 0, 'a', info, ) VSC_F(s_sess, uint64_t, 1, 'a', info, - "Total Sessions", + "Total sessions seen", "" ) VSC_F(s_req, uint64_t, 1, 'a', info, - "Total Requests", + "Total requests seen", "" ) VSC_F(s_pipe, uint64_t, 1, 'a', info, - "Total pipe", + "Total pipe sessions seen", "" ) VSC_F(s_pass, uint64_t, 1, 'a', info, - "Total pass", + "Total pass-ed requests seen", "" ) VSC_F(s_fetch, uint64_t, 1, 'a', info, - "Total fetch", + "Total backend fetches initiated", "" ) VSC_F(s_synth, uint64_t, 1, 'a', info, - "Total synth", + "Total synthethic responses made", "" ) VSC_F(s_req_hdrbytes, uint64_t, 1, 'a', info, @@ -488,15 +488,15 @@ VSC_F(backend_req, uint64_t, 0, 'a', info, /*--------------------------------------------------------------------*/ VSC_F(n_vcl, uint64_t, 0, 'a', info, - "N vcl total", + "Number of loaded VCLs in total", "" ) VSC_F(n_vcl_avail, uint64_t, 0, 'a', diag, - "N vcl available", + "Number of VCLs available", "" ) VSC_F(n_vcl_discard, uint64_t, 0, 'a', diag, - "N vcl discarded", + "Number of discarded VCLs", "" ) @@ -584,7 +584,7 @@ VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', diag, /*--------------------------------------------------------------------*/ VSC_F(n_purges, uint64_t, 0, 'i', info, - "Number of purge operations", + "Number of purge operations executed", "" ) VSC_F(n_obj_purged, uint64_t, 0, 'i', info, From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 34305d8 whitespace ocd before further editing Message-ID: commit 34305d822d891c811cd541b4c668c4be76d5bcd0 Author: Nils Goroll Date: Mon Oct 13 12:58:42 2014 +0200 whitespace ocd before further editing diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 48b19c9..e7a7e83 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -1,4 +1,3 @@ - .. _vcl-built-in-subs: .. XXX:This document needs substantional review. @@ -17,7 +16,7 @@ serve the request, how to do it, and, if applicable, which backend to use. It is also used to modify the request, something you'll probably find -yourself doing frequently. +yourself doing frequently. The `vcl_recv` subroutine may terminate with calling ``return()`` on one of the following keywords: @@ -37,7 +36,7 @@ of the following keywords: caching. Passes the control over to vcl_hash. purge - Purge the object and it's variants. Control passes through + Purge the object and it's variants. Control passes through vcl_hash to vcl_purge. vcl_pipe @@ -85,9 +84,10 @@ of the following keywords: vcl_hit ~~~~~~~ -Called when a cache lookup is successful. +Called when a cache lookup is successful. -The `vcl_hit` subroutine may terminate with calling ``return()`` with one of the following keywords: +The `vcl_hit` subroutine may terminate with calling ``return()`` +with one of the following keywords: restart @@ -216,7 +216,7 @@ The `vcl_backend_response` subroutine may terminate with calling vcl_backend_error ~~~~~~~~~~~~~~~~~ -This subroutine is called if we fail the backend fetch. +This subroutine is called if we fail the backend fetch. The `vcl_backend_error` subroutine may terminate with calling ``return()`` with one of the following keywords: @@ -240,7 +240,7 @@ the synthetic() function. The subroutine may terminate with calling ``return()`` with one of the following keywords: - deliver + deliver Deliver the object. If the object has a positive TTL then the object is also stored in cache. From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] a6c25df move the label to the right place Message-ID: commit a6c25df2d6fcb688ced73021efd414245951230a Author: Nils Goroll Date: Mon Oct 13 13:59:58 2014 +0200 move the label to the right place diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index e7a7e83..32f8fbd 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -1,7 +1,7 @@ -.. _vcl-built-in-subs: .. XXX:This document needs substantional review. +.. _vcl-built-in-subs: Built in subroutines -------------------- From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 40127a9 Remove more varnishsizes references Message-ID: commit 40127a990c3a24e9783d1de1c516398128324980 Author: Federico G. Schwindt Date: Thu Oct 16 23:30:05 2014 +0100 Remove more varnishsizes references diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 32458a6..b59beb5 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -15,7 +15,6 @@ The Varnish Reference Manual varnishlog.rst varnishncsa.rst varnishreplay.rst - varnishsizes.rst varnishstat.rst varnishtest.rst varnishtop.rst diff --git a/doc/sphinx/reference/varnishsizes.rst b/doc/sphinx/reference/varnishsizes.rst deleted file mode 100644 index af2e05b..0000000 --- a/doc/sphinx/reference/varnishsizes.rst +++ /dev/null @@ -1,86 +0,0 @@ -============ -varnishsizes -============ - -------------------------------------- -Varnish object size request histogram -------------------------------------- - - -SYNOPSIS -======== - -varnishsizes [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-m tag:regex ...] - [-n varnish_name] [-r file] [-V] [-w delay] [-X regex] [-x tag] - -DESCRIPTION -=========== - -The varnishsizes utility reads varnishd(1) shared memory logs and presents -a continuously updated histogram showing the distribution of the last N -requests by their processing. The value of N and the vertical scale are -displayed in the top left corner. The horizontal scale is a logarithmic -representation of bytes. Hits are marked with a pipe character -("|"), and misses are marked with a hash character ("#"). - -The following options are available: - --b Include log entries which result from communication with a backend server. - If neither -b nor -c is specified, varnishsizes acts as if they both were. - --C Ignore case when matching regular expressions. - --c Include log entries which result from communication with a client. - If neither -b nor -c is specified, varnishsizes acts as if they both were. - --d Process old log entries on startup. Normally, varnishsizes will only - process entries which are written to the log after it starts. - --I regex Include log entries which match the specified regular expression. - If neither -I nor -i is specified, all log entries are included. - --i tag Include log entries with the specified tag. If neither -I nor -i - is specified, all log entries are included. - --m tag:regex only list record where tag matches regex. Multiple -m - options are AND-ed together. - --n Specifies the name of the varnishd instance to get logs from. - If -n is not specified, the host name is used. - --r file Read log entries from file instead of shared memory. - --V Display the version number and exit. - --w delay Wait at least delay seconds between each update. The default is 1. - file instead of displaying them. The file will be overwritten - unless the -a option was specified. - --X regex Exclude log entries which match the specified regular expression. - --x tag Exclude log entries with the specified tag. - -SEE ALSO -======== - -* varnishd(1) -* varnishlog(1) -* varnishncsa(1) -* varnishstat(1) -* varnishtop(1) - -HISTORY -======= - -The varnishsizes utility was developed by Kristian Lyngst?l based on -varnishhist. This manual page was written by Kristian Lyngst?l, -Dag-Erling Sm?rgrav and Per Buer. - - -COPYRIGHT -========= - -This document is licensed under the same licence as Varnish -itself. See LICENCE for details. - -* Copyright (c) 2010 Varnish Software AS From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 897ea66 Docfix: Make SLT_TTL format match with reality. Message-ID: commit 897ea66b2f6be1cf151ed6621fc458ec63c0ef29 Author: Dag Haavi Finstad Date: Fri Oct 17 14:14:32 2014 +0200 Docfix: Make SLT_TTL format match with reality. diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 18b93f8..6b8c4fa 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -197,12 +197,12 @@ SLTM(TTL, 0, "TTL set on object", "A TTL record is emitted whenever the ttl, grace or keep" " values for an object is set.\n\n" "The format is::\n\n" - "\t%s %d %d %d %d %d [ %d %u %u ]\n" - "\t| | | | | | | | |\n" - "\t| | | | | | | | +- Max-Age from Cache-Control header\n" - "\t| | | | | | | +---- Expires header\n" - "\t| | | | | | +------- Date header\n" - "\t| | | | | +------------ Age (incl Age: header value)\n" + "\t%s %d %d %d %d [ %d %d %u %u ]\n" + "\t| | | | | | | | |\n" + "\t| | | | | | | | +- Max-Age from Cache-Control header\n" + "\t| | | | | | | +---- Expires header\n" + "\t| | | | | | +------- Date header\n" + "\t| | | | | +---------- Age (incl Age: header value)\n" "\t| | | | +--------------- Reference time for TTL\n" "\t| | | +------------------ Keep\n" "\t| | +--------------------- Grace\n" From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] af3a0d9 Update examples Message-ID: commit af3a0d9fd2f2eaf16096c0388d517667d8094f6e Author: Federico G. Schwindt Date: Sat Oct 18 12:05:35 2014 +0100 Update examples diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 6b8c4fa..0cb0612 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -211,12 +211,8 @@ SLTM(TTL, 0, "TTL set on object", "\n" "The last four fields are only present in \"RFC\" headers.\n\n" "Examples::\n\n" - "\tRFC 19 -1 -1 1312966109 4 0 0 23\n" - "\tVCL 10 -1 -1 1312966109 4\n" - "\tVCL 7 -1 -1 1312966111 6\n" - "\tVCL 7 120 -1 1312966111 6\n" - "\tVCL 7 120 3600 1312966111 6\n" - "\tVCL 12 120 3600 1312966113 8\n" + "\tRFC 60 -1 -1 1312966109 1312966109 1312966109 0 60\n" + "\tVCL 120 10 0 1312966111\n" "\n" ) From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 795bc31 Fix the leaking req on failure to put a waiting-list session back in play in a way that does not lead to panics. Message-ID: commit 795bc31f168ae64a30d1e61d01bd4e69f0016092 Author: Poul-Henning Kamp Date: Mon Oct 20 12:21:31 2014 +0000 Fix the leaking req on failure to put a waiting-list session back in play in a way that does not lead to panics. Spotted by: Martin Fixes #1607 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 0a94a3d..47f346f 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -535,13 +535,8 @@ hsh_rush(struct dstat *ds, struct objhead *oh) AZ(req->wrk); VTAILQ_REMOVE(&wl->list, req, w_list); DSL(DBG_WAITINGLIST, req->vsl->wid, "off waiting list"); - if (SES_ScheduleReq(req)) { - /* - * We could not schedule the session, put it back. - */ - VTAILQ_INSERT_HEAD(&wl->list, req, w_list); + if (SES_ScheduleReq(req)) break; - } } if (VTAILQ_EMPTY(&wl->list)) { oh->waitinglist = NULL; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 7291a98..4ba15b6 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -237,6 +237,7 @@ SES_ScheduleReq(struct req *req) if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) { AN (req->vcl); VCL_Rel(&req->vcl); + SES_ReleaseReq(req); SES_Delete(sp, SC_OVERLOAD, NAN); return (1); } From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] f7b3ef7 Report error in STV_FileSize on empty file and no size specified Message-ID: commit f7b3ef748d670ec33fca9aaf264e13539c2ea1ff Author: Martin Blix Grydeland Date: Tue Oct 7 12:44:37 2014 +0200 Report error in STV_FileSize on empty file and no size specified diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index a86d57e..fe3514b 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -196,6 +196,9 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) * use its existing size. */ l = st.st_size; + } else if (size == NULL || *size == '\0') { + ARGV_ERR("(%s) no size specified\n", + ctx); } else { AN(size); q = VNUM_2bytes(size, &l, fssize); From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 551e0de Bail out with arg error if specifying a size larger than the file system size Message-ID: commit 551e0de9e89a83b6b465fc8800dfc9b47217a9dc Author: Martin Blix Grydeland Date: Mon Oct 6 15:33:34 2014 +0200 Bail out with arg error if specifying a size larger than the file system size This is to spot obvious typos diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index fe3514b..ace90af 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -209,6 +209,10 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) if (l < 1024*1024) ARGV_ERR("(%s) size \"%s\": too small, " "did you forget to specify M or G?\n", ctx, size); + + if (l > fssize) + ARGV_ERR("(%s) size \"%s\": larger than file system\n", + ctx, size); } /* From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] d0227a5 Remove default size from -sfile Message-ID: commit d0227a5a7ab77d28fb6827e442aa18a79a09e472 Author: Martin Blix Grydeland Date: Tue Oct 7 14:46:34 2014 +0200 Remove default size from -sfile diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 876e444..da67ef3 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -108,7 +108,6 @@ smf_initfile(struct smf_sc *sc, const char *size) /* XXX: force block allocation here or in open ? */ } -static const char default_size[] = "100M"; static const char default_filename[] = "."; static void @@ -122,7 +121,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av) AZ(av[ac]); fn = default_filename; - size = default_size; + size = NULL; page_size = getpagesize(); if (ac > 3) @@ -139,7 +138,6 @@ smf_init(struct stevedore *parent, int ac, char * const *av) } AN(fn); - AN(size); ALLOC_OBJ(sc, SMF_SC_MAGIC); XXXAN(sc); From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] f4327a5 Fix varnishd usage line order Message-ID: commit f4327a583ff8ee5aa72fd2a80d1798dda1be151f Author: Martin Blix Grydeland Date: Tue Oct 7 15:48:33 2014 +0200 Fix varnishd usage line order diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 28b4823..cb0896d 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -174,9 +174,9 @@ usage(void) fprintf(stderr, FMT, "", " -s file [default: use /tmp]"); fprintf(stderr, FMT, "", " -s file,"); fprintf(stderr, FMT, "", " -s file,,"); - fprintf(stderr, FMT, "", " -s persist{experimenta}"); fprintf(stderr, FMT, "", " -s file,,,"); + fprintf(stderr, FMT, "", " -s persist{experimenta}"); fprintf(stderr, FMT, "-S secret-file", "Secret file for CLI authentication"); fprintf(stderr, FMT, "-T address:port", From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 55154c9 Fix varnishd usage output typo Message-ID: commit 55154c9c8ad4519362ff778df461833562c20f4a Author: Martin Blix Grydeland Date: Tue Oct 7 15:49:13 2014 +0200 Fix varnishd usage output typo diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index cb0896d..ae90fe0 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -176,7 +176,7 @@ usage(void) fprintf(stderr, FMT, "", " -s file,,"); fprintf(stderr, FMT, "", " -s file,,,"); - fprintf(stderr, FMT, "", " -s persist{experimenta}"); + fprintf(stderr, FMT, "", " -s persist{experimental}"); fprintf(stderr, FMT, "-S secret-file", "Secret file for CLI authentication"); fprintf(stderr, FMT, "-T address:port", From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] a80a788 Permit uppercase letters in vmod.vcc identifiers. Message-ID: commit a80a788a92fab6ea6825174f4a1b3a3b653bba48 Author: Dag Haavi Finstad Date: Tue Oct 21 13:35:41 2014 +0200 Permit uppercase letters in vmod.vcc identifiers. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index f437c22..d2d9dc2 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -104,7 +104,7 @@ def lwrap(s, w=72): ####################################################################### def is_c_name(s): - return None != re.match("^[a-z][a-z0-9_]*$", s) + return None != re.match("^[a-zA-Z][a-zA-Z0-9_]*$", s) class ParseError(Exception): From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 6deca86 Avoid assertion failure in VCC if the first symbol encountered in VCL is not an ID Message-ID: commit 6deca8631c33d3075e123f1ce742286af42ffbf1 Author: Nils Goroll Date: Mon Oct 27 21:01:55 2014 +0100 Avoid assertion failure in VCC if the first symbol encountered in VCL is not an ID Trivial test VCL: C{ }C; vcl 4.0; diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index dab1131..2b52846 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -338,7 +338,7 @@ vcc_Parse(struct vcc *tl) { struct toplev *tp; - if (!vcc_IdIs(tl->t, "vcl")) { + if (tl->t->tok != ID || !vcc_IdIs(tl->t, "vcl")) { VSB_printf(tl->sb, "VCL version declaration missing\n" "Update your VCL to Version 4 syntax, and add\n" From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 8c7e938 Prefer exact matches in varnishadm backend.set_health. Message-ID: commit 8c7e93833db8aa898db74878bb076c1ca093bf33 Author: Dag Haavi Finstad Date: Tue Oct 28 13:34:06 2014 +0100 Prefer exact matches in varnishadm backend.set_health. Fixes: #1349 diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index dbe07c1..5cf077e 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -288,7 +288,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) const char *port_b = NULL; ssize_t port_l = 0; int found = 0; - int i; + int i, j; name_b = matcher; if (matcher != NULL) { @@ -342,22 +342,33 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) } } } - VTAILQ_FOREACH(b, &backends, list) { - CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); - if (port_b != NULL && strncmp(b->port, port_b, port_l) != 0) - continue; - if (name_b != NULL && strncmp(b->vcl_name, name_b, name_l) != 0) - continue; - if (ip_b != NULL && - (b->ipv4_addr == NULL || - strncmp(b->ipv4_addr, ip_b, ip_l)) && - (b->ipv6_addr == NULL || - strncmp(b->ipv6_addr, ip_b, ip_l))) + + for (j = 0; j < 2; ++j) { + if (j == 0 && name_b == NULL) continue; - found++; - i = func(cli, b, priv); - if (i) - return(i); + VTAILQ_FOREACH(b, &backends, list) { + CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); + if (port_b != NULL && + strncmp(b->port, port_b, port_l) != 0) + continue; + if (name_b != NULL && + strncmp(b->vcl_name, name_b, name_l) != 0) + continue; + if (j == 0 && b->vcl_name[name_l] != '\0') + continue; + if (ip_b != NULL && + (b->ipv4_addr == NULL || + strncmp(b->ipv4_addr, ip_b, ip_l)) && + (b->ipv6_addr == NULL || + strncmp(b->ipv6_addr, ip_b, ip_l))) + continue; + found++; + i = func(cli, b, priv); + if (i) + return(i); + if (j == 0) + return (1); + } } return (found); } diff --git a/bin/varnishtest/tests/r01349.vtc b/bin/varnishtest/tests/r01349.vtc new file mode 100644 index 0000000..78c64ba --- /dev/null +++ b/bin/varnishtest/tests/r01349.vtc @@ -0,0 +1,66 @@ +varnishtest "Exact matching for varnishadm backend.set_health" + +server s1 -repeat 2 { + rxreq + txresp -hdr "Backend: b1" +} -start + +server s2 -repeat 2 { + rxreq + txresp -hdr "Backend: b" +} -start + +varnish v1 -vcl { + backend b1 { + .host = "${s1_addr}"; + .port = "${s1_port}"; + } + + backend b { + .host = "${s2_addr}"; + .port = "${s2_port}"; + } + + sub vcl_recv { + return(pass); + } + + sub vcl_backend_fetch { + if (bereq.http.backend == "b1") { + set bereq.backend = b1; + } + else { + set bereq.backend = b; + } + } + +} -start + +varnish v1 -cliok "backend.list b" + +client c1 { + txreq -hdr "Backend: b1" + rxresp + expect resp.status == 200 + expect resp.http.backend == "b1" + + txreq -hdr "Backend: b" + rxresp + expect resp.status == 200 + expect resp.http.backend == "b" +} -run + +varnish v1 -cliok "backend.set_health b sick" + +client c1 { + txreq -hdr "Backend: b1" + rxresp + expect resp.status == 200 + expect resp.http.backend == "b1" + + txreq -hdr "Backend: b" + rxresp + expect resp.status == 503 +} -run + +varnish v1 -clierr 106 "backend.set_health b(1.2.3.4:) healthy" From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 5514c5d Document current behavior of backend.set_health Message-ID: commit 5514c5d4128b2326abf36c77861ee402f5874caa Author: Dag Haavi Finstad Date: Tue Oct 28 14:05:57 2014 +0100 Document current behavior of backend.set_health diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 2e17c2e..ca2fc8c 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -132,7 +132,11 @@ backend.list List all backends backend.set_health matcher state - Set health status on a backend + Set health status on a backend. The matcher expression can be a + backend name or a parenthesized "(IP:port)" expression, or both. All + fields are optional. If no exact matching backend is found, partial + matching will be attempted based on the provided name, IP and port + fields. ban [&& ]... All objects where the all the conditions match will be marked obsolete. From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] e249de5 Be consistent in formatting headlines. Message-ID: commit e249de54dac82705d0e9a1c7cc25e12ac077c7a7 Author: Lasse Karstensen Date: Wed Oct 29 10:34:22 2014 +0100 Be consistent in formatting headlines. diff --git a/doc/changes.rst b/doc/changes.rst index 846f975..13d22fa 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -7,6 +7,7 @@ New since 4.0.2-rc1: - [varnishlog] -k argument is back. (exit after n records) - [varnishadm] vcl.show is now listed in help. + ============================================ Changes from 4.0.1 to 4.0.2-rc1 (2014-09-23) ============================================ @@ -193,7 +194,6 @@ Bugs fixed .. _1519: https://www.varnish-cache.org/trac/ticket/1519 - ============================================== Changes from 4.0.0 beta1 to 4.0.0 (2014-04-10) ============================================== @@ -278,7 +278,6 @@ Bugs fixed .. _1405: https://www.varnish-cache.org/trac/ticket/1405 - =================================== Changes from 4.0.0 TP1 to 4.0.0 TP2 =================================== @@ -346,6 +345,7 @@ varnishd .. _bug #1376: http://varnish-cache.org/trac/ticket/1376 + ================================ Changes from 3.0.4 to 3.0.5 rc 1 ================================ @@ -383,6 +383,7 @@ varnishadm .. _bug #1314: http://varnish-cache.org/trac/ticket/1314 + ================================ Changes from 3.0.4 rc 1 to 3.0.4 ================================ @@ -399,6 +400,7 @@ varnishd .. _bug #1285: http://varnish-cache.org/trac/ticket/1285 .. _bug #1312: http://varnish-cache.org/trac/ticket/1312 + ================================ Changes from 3.0.3 to 3.0.4 rc 1 ================================ @@ -457,6 +459,7 @@ Other least on i386. - Make libvarnish prefer exact hits when looking for VSL tags. + =========================== Changes from 3.0.2 to 3.0.3 =========================== @@ -573,6 +576,7 @@ Other .. _bug #1003: http://varnish-cache.org/trac/ticket/1003 + ================================ Changes from 3.0.2 rc 1 to 3.0.2 ================================ @@ -603,6 +607,7 @@ Other - Some Solaris portability updates. + ================================ Changes from 3.0.1 to 3.0.2 rc 1 ================================ @@ -664,6 +669,7 @@ Other - Some Solaris portability updates. + ================================ Changes from 3.0.1 rc 1 to 3.0.1 ================================ @@ -695,6 +701,7 @@ Other - Documentation updates + ================================ Changes from 3.0.0 to 3.0.1 rc 1 ================================ @@ -771,6 +778,7 @@ Other .. _bug #961: http://varnish-cache.org/trac/ticket/961 + ================================ Changes from 3.0 beta 2 to 3.0.0 ================================ @@ -798,6 +806,7 @@ varnishadm .. _bug #935: http://varnish-cache.org/trac/ticket/935 + ===================================== Changes from 3.0 beta 1 to 3.0 beta 2 ===================================== @@ -849,6 +858,7 @@ VMODs - The std module now has proper documentation, including a manual page + ================================ Changes from 2.1.5 to 3.0 beta 1 ================================ @@ -1092,6 +1102,7 @@ Other - The documentation has been improved all over and should now be in much better shape than before + =========================== Changes from 2.1.4 to 2.1.5 =========================== @@ -1166,6 +1177,7 @@ varnishtest - Remove no longer existing -L option. + =========================== Changes from 2.1.3 to 2.1.4 =========================== @@ -1315,6 +1327,7 @@ libvarnishapi - The -X parameter didn't work correctly. This has been fixed. + =========================== Changes from 2.1.1 to 2.1.2 =========================== @@ -1327,6 +1340,7 @@ varnishd by default 128k. Browsers would do the right thing due to Content-Length, but some load balancers would get very confused. + =========================== Changes from 2.1.1 to 2.1.1 =========================== @@ -1558,6 +1572,7 @@ varnishadm - varnishadm now knows how to respond to the secret from a secured varnishd + =========================== Changes from 2.0.5 to 2.0.6 =========================== @@ -1587,6 +1602,7 @@ varnishd - Document the -C option to varnishd. + =========================== Changes from 2.0.4 to 2.0.5 =========================== @@ -1684,6 +1700,7 @@ varnishtop - varnishtop previously did not print the name of the tag, which made it very hard to understand. We now print out the tag name. + =========================== Changes from 2.0.3 to 2.0.4 =========================== @@ -1741,6 +1758,7 @@ varnishtest - Make it possible to send NULL bytes through the testing framework. + =========================== Changes from 2.0.2 to 2.0.3 =========================== @@ -1875,6 +1893,7 @@ varnishreplay - varnishreplay did not work correctly on Linux, due to a too small stack. This has now been fixed. + =========================== Changes from 2.0.1 to 2.0.2 =========================== @@ -1909,6 +1928,7 @@ Red Hat spec file - A typo in the spec file made the .rpm file names wrong. + ========================= Changes from 1.1.2 to 2.0 ========================= @@ -2028,6 +2048,7 @@ Build system - The C compiler invocation is decided by the configure script and can now be overridden by passing VCC\_CC when running configure. + =========================== Changes from 1.1.1 to 1.1.2 =========================== @@ -2131,6 +2152,7 @@ Build system the default state directory would be garbage and a state directory would have to be specified manually with -n. This has been corrected. + ========================= Changes from 1.1 to 1.1.1 ========================= @@ -2215,6 +2237,7 @@ Build system dynamic rather than static. This simplifies the build process and resolves an issue with the Mac OS X linker. + ========================= Changes from 1.0.4 to 1.1 ========================= @@ -2375,6 +2398,7 @@ varnishtop actually works. In addition, the name of the Varnish instance being watched is displayed in the upper right corner in curses mode. + =========================== Changes from 1.0.3 to 1.0.4 =========================== From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 3c22180 Copy over additions to changes.rst from 3.0 branch. Message-ID: commit 3c221801fba4242a35252672049326402b5bc07d Author: Lasse Karstensen Date: Wed Oct 29 10:33:20 2014 +0100 Copy over additions to changes.rst from 3.0 branch. diff --git a/doc/changes.rst b/doc/changes.rst index 13d22fa..4c6807f 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -333,6 +333,40 @@ Open issues .. _1268: https://www.varnish-cache.org/trac/ticket/1268 +=========================================== +Changes from 3.0.6rc1 to 3.0.6 (2014-10-16) +=========================================== + +- Minor changes to documentation. +- [varnishadm] Add termcap workaround for libedit. Bug 1514_. + +.. _1531: http://varnish-cache.org/trac/ticket/1531 + + +=========================================== +Changes from 3.0.5 to 3.0.6rc1 (2014-06-24) +=========================================== + +- Document storage..* VCL variables. Bug 1514_. +- Fix memory alignment panic when http_max_hdr is not a multiple of 4. Bug 1327_. +- Avoid negative ReqEnd timestamps with ESI. Bug 1297_. +- %D format for varnishncsa is now an integer (as documented) +- Fix compile errors with clang. +- Clear objectcore flags earlier in ban lurker to avoid spinning thread. Bug 1470_. +- Patch embedded jemalloc to avoid segfault. Bug 1448_. +- Allow backend names to start with if, include or else. Bug 1439_. +- Stop handling gzip after gzip body end. Bug 1086_. +- Document %D and %T for varnishncsa. + +.. _1514: http://varnish-cache.org/trac/ticket/1514 +.. _1327: http://varnish-cache.org/trac/ticket/1327 +.. _1297: http://varnish-cache.org/trac/ticket/1297 +.. _1470: http://varnish-cache.org/trac/ticket/1470 +.. _1448: http://varnish-cache.org/trac/ticket/1448 +.. _1439: http://varnish-cache.org/trac/ticket/1439 +.. _1086: http://varnish-cache.org/trac/ticket/1086 + + ================================ Changes from 3.0.5 rc 1 to 3.0.5 ================================ From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 029f801 Add release dates. Message-ID: commit 029f80179049516c5df102ea79861d55af9f3b21 Author: Lasse Karstensen Date: Wed Oct 29 10:41:26 2014 +0100 Add release dates. Source data from file time on repo.varnish-cache.org. diff --git a/doc/changes.rst b/doc/changes.rst index 4c6807f..a603870 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -220,9 +220,9 @@ Bugs fixed .. _1467: https://www.varnish-cache.org/trac/ticket/1467 -===================================== -Changes from 4.0.0 TP2 to 4.0.0 beta1 -===================================== +================================================== +Changes from 4.0.0 TP2 to 4.0.0 beta1 (2014-03-27) +================================================== New since TP2: @@ -278,9 +278,9 @@ Bugs fixed .. _1405: https://www.varnish-cache.org/trac/ticket/1405 -=================================== -Changes from 4.0.0 TP1 to 4.0.0 TP2 -=================================== +================================================ +Changes from 4.0.0 TP1 to 4.0.0 TP2 (2014-01-23) +================================================ New since from 4.0.0 TP1 ------------------------ @@ -367,9 +367,9 @@ Changes from 3.0.5 to 3.0.6rc1 (2014-06-24) .. _1086: http://varnish-cache.org/trac/ticket/1086 -================================ -Changes from 3.0.5 rc 1 to 3.0.5 -================================ +============================================= +Changes from 3.0.5 rc 1 to 3.0.5 (2013-12-02) +============================================= varnishd -------- @@ -418,9 +418,9 @@ varnishadm .. _bug #1314: http://varnish-cache.org/trac/ticket/1314 -================================ -Changes from 3.0.4 rc 1 to 3.0.4 -================================ +============================================= +Changes from 3.0.4 rc 1 to 3.0.4 (2013-06-14) +============================================= varnishd -------- @@ -494,9 +494,9 @@ Other - Make libvarnish prefer exact hits when looking for VSL tags. -=========================== -Changes from 3.0.2 to 3.0.3 -=========================== +======================================== +Changes from 3.0.2 to 3.0.3 (2012-08-20) +======================================== Varnishd -------- @@ -611,9 +611,9 @@ Other .. _bug #1003: http://varnish-cache.org/trac/ticket/1003 -================================ -Changes from 3.0.2 rc 1 to 3.0.2 -================================ +============================================= +Changes from 3.0.2 rc 1 to 3.0.2 (2011-10-26) +============================================= Varnishd -------- @@ -642,9 +642,9 @@ Other - Some Solaris portability updates. -================================ -Changes from 3.0.1 to 3.0.2 rc 1 -================================ +============================================= +Changes from 3.0.1 to 3.0.2 rc 1 (2011-10-06) +============================================= Varnishd -------- @@ -704,9 +704,9 @@ Other - Some Solaris portability updates. -================================ -Changes from 3.0.1 rc 1 to 3.0.1 -================================ +============================================= +Changes from 3.0.1 rc 1 to 3.0.1 (2011-08-30) +============================================= Varnishd -------- @@ -736,9 +736,9 @@ Other - Documentation updates -================================ -Changes from 3.0.0 to 3.0.1 rc 1 -================================ +============================================= +Changes from 3.0.0 to 3.0.1 rc 1 (2011-08-24) +============================================= Varnishd -------- @@ -813,9 +813,9 @@ Other .. _bug #961: http://varnish-cache.org/trac/ticket/961 -================================ -Changes from 3.0 beta 2 to 3.0.0 -================================ +============================================= +Changes from 3.0 beta 2 to 3.0.0 (2011-06-16) +============================================= Varnishd -------- @@ -1137,9 +1137,9 @@ Other much better shape than before -=========================== -Changes from 2.1.4 to 2.1.5 -=========================== +======================================== +Changes from 2.1.4 to 2.1.5 (2011-01-25) +======================================== varnishd -------- From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 8dafc1c Use correct bug number. Message-ID: commit 8dafc1cbd459adbd6b647ed20eb00b6d1be7ceed Author: Lasse Karstensen Date: Wed Oct 29 14:11:23 2014 +0100 Use correct bug number. Found by: Geoff diff --git a/doc/changes.rst b/doc/changes.rst index a603870..fd4db1f 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -338,7 +338,7 @@ Changes from 3.0.6rc1 to 3.0.6 (2014-10-16) =========================================== - Minor changes to documentation. -- [varnishadm] Add termcap workaround for libedit. Bug 1514_. +- [varnishadm] Add termcap workaround for libedit. Bug 1531_. .. _1531: http://varnish-cache.org/trac/ticket/1531 From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 28b0e61 Remove duplicate target name. Message-ID: commit 28b0e6141d06c64f7da635bd3d545b792bf4f0c9 Author: Lasse Karstensen Date: Thu Oct 30 11:36:02 2014 +0100 Remove duplicate target name. diff --git a/doc/changes.rst b/doc/changes.rst index fd4db1f..a8ab383 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -340,8 +340,6 @@ Changes from 3.0.6rc1 to 3.0.6 (2014-10-16) - Minor changes to documentation. - [varnishadm] Add termcap workaround for libedit. Bug 1531_. -.. _1531: http://varnish-cache.org/trac/ticket/1531 - =========================================== Changes from 3.0.5 to 3.0.6rc1 (2014-06-24) From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] fef3fb4 Drop duplicate ref Message-ID: commit fef3fb4df590c5ecd07ad8be47dead0f9431c6c2 Author: Tollef Fog Heen Date: Thu Oct 30 14:24:44 2014 +0100 Drop duplicate ref diff --git a/doc/changes.rst b/doc/changes.rst index a8ab383..c638014 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -189,7 +189,6 @@ Bugs fixed .. _1501: https://www.varnish-cache.org/trac/ticket/1501 .. _1495: https://www.varnish-cache.org/trac/ticket/1495 .. _1510: https://www.varnish-cache.org/trac/ticket/1510 -.. _1514: https://www.varnish-cache.org/trac/ticket/1514 .. _1518: https://www.varnish-cache.org/trac/ticket/1518 .. _1519: https://www.varnish-cache.org/trac/ticket/1519 From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] 9557bcf Fix typo Message-ID: commit 9557bcffb2c20b1cbf939dcb1ad57d9338d663af Author: Federico G. Schwindt Date: Mon Nov 3 10:52:05 2014 +0000 Fix typo Submitted by: Muhammad Adeel via github diff --git a/doc/sphinx/phk/persistent.rst b/doc/sphinx/phk/persistent.rst index 33af07c..6c1d29c 100644 --- a/doc/sphinx/phk/persistent.rst +++ b/doc/sphinx/phk/persistent.rst @@ -41,7 +41,7 @@ all the banned objects. With persistent storage, we not only have to store the still live bans with the cached objects, and keep the two painfully in sync, so the bans gets revived with the objects, we also have to worry -about missing bans duing the downtime, since those might ban objects +about missing bans during the downtime, since those might ban objects we will recover on startup. Ouch: Straight into database/filesystem consistency territory. From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 728620a Unit has changed as well Message-ID: commit 728620a0265c71681948391207d74e83ec895408 Author: Federico G. Schwindt Date: Tue Nov 4 16:03:05 2014 +0000 Unit has changed as well diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index cb36b08..e4dc5d5 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -198,7 +198,8 @@ Changes to existing parameters session_linger ~~~~~~~~~~~~~~ -`session_linger` has been renamed to `timeout_linger`. +`session_linger` has been renamed to `timeout_linger` and it is in +seconds now (previously was milliseconds). sess_timeout ~~~~~~~~~~~~ From lkarsten at varnish-software.com Thu Jan 15 15:35:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:40 +0100 Subject: [4.0] ea4ab11 This should be plural. Message-ID: commit ea4ab11a044fe2ae94148d82eb9a3d12cf0d5f2b Author: Lasse Karstensen Date: Tue Nov 4 16:38:43 2014 +0100 This should be plural. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 62aff53..78c72d5 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -194,7 +194,7 @@ struct parspec mgt_parspec[] = { "5", "seconds" }, { "timeout_req", tweak_timeout, &mgt_param.timeout_req, "0", NULL, - "Max time to receive clients request header, measured" + "Max time to receive clients request headers, measured" " from first non-white-space character to double CRNL.", 0, "2", "seconds" }, From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] eaa05ac Use units consistently Message-ID: commit eaa05ac038c59afc357c8969868de63ab620d814 Author: Federico G. Schwindt Date: Tue Nov 4 16:33:03 2014 +0000 Use units consistently diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 78c72d5..d5e2c02 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -342,7 +342,7 @@ struct parspec mgt_parspec[] = { "VCL can override this default value for each backend and " "backend request.", 0, - "3.5", "s" }, + "3.5", "seconds" }, { "first_byte_timeout", tweak_timeout, &mgt_param.first_byte_timeout, "0", NULL, @@ -353,7 +353,7 @@ struct parspec mgt_parspec[] = { "VCL can override this default value for each backend and " "backend request. This parameter does not apply to pipe.", 0, - "60", "s" }, + "60", "seconds" }, { "between_bytes_timeout", tweak_timeout, &mgt_param.between_bytes_timeout, "0", NULL, @@ -364,7 +364,7 @@ struct parspec mgt_parspec[] = { "VCL can override this default value for each backend request " "and backend request. This parameter does not apply to pipe.", 0, - "60", "s" }, + "60", "seconds" }, { "acceptor_sleep_max", tweak_timeout, &mgt_param.acceptor_sleep_max, "0", "10", @@ -373,7 +373,7 @@ struct parspec mgt_parspec[] = { "This parameter limits how long it can sleep between " "attempts to accept new connections.", EXPERIMENTAL, - "0.050", "s" }, + "0.050", "seconds" }, { "acceptor_sleep_incr", tweak_timeout, &mgt_param.acceptor_sleep_incr, "0", "1", @@ -382,7 +382,7 @@ struct parspec mgt_parspec[] = { "This parameter control how much longer we sleep, each time " "we fail to accept a new connection.", EXPERIMENTAL, - "0.001", "s" }, + "0.001", "seconds" }, { "acceptor_sleep_decay", tweak_double, &mgt_param.acceptor_sleep_decay, "0", "1", @@ -397,7 +397,7 @@ struct parspec mgt_parspec[] = { "How much clockskew we are willing to accept between the " "backend and our own clock.", 0, - "10", "s" }, + "10", "seconds" }, { "prefer_ipv6", tweak_bool, &mgt_param.prefer_ipv6, NULL, NULL, "Prefer IPv6 address when connecting to backends which " @@ -454,7 +454,7 @@ struct parspec mgt_parspec[] = { " lookup. This parameter prevents the ban-lurker from" " kicking in, until the rush is over.", 0, - "60", "s" }, + "60", "seconds" }, { "ban_lurker_sleep", tweak_timeout, &mgt_param.ban_lurker_sleep, "0", NULL, @@ -464,7 +464,7 @@ struct parspec mgt_parspec[] = { " before looking for new work to do.\n" "A value of zero disables the ban lurker.", 0, - "0.01", "s" }, + "0.01", "seconds" }, { "ban_lurker_batch", tweak_uint, &mgt_param.ban_lurker_batch, "1", NULL, @@ -521,14 +521,14 @@ struct parspec mgt_parspec[] = { "Objects created with (ttl+grace+keep) shorter than this" " are always put in transient storage.", 0, - "10.0", "s" }, + "10", "seconds" }, { "critbit_cooloff", tweak_timeout, &mgt_param.critbit_cooloff, "60", "254", "How long time the critbit hasher keeps deleted objheads " "on the cooloff list.", WIZARD, - "180.0", "s" }, + "180", "seconds" }, { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, NULL, NULL, "Install a signal handler which tries to dump debug " From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 60689ed More changes from varnish 3 and some specific to master Message-ID: commit 60689ed4b171530caa5ee2afa3b873b27ff61880 Author: Federico G. Schwindt Date: Tue Nov 4 16:52:30 2014 +0000 More changes from varnish 3 and some specific to master diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index e4dc5d5..2ee8ae7 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -67,7 +67,7 @@ vcl_error is now vcl_backend_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To make a distinction between internally generated errors and -VCL synthetic responses, `vcl_backend_error` will be called when +VCL synthetic responses, `vcl_backend_error` will be called when varnish encounters an error when trying to fetch an object. error() is now synth() @@ -145,14 +145,7 @@ The `purge;` keyword has been retired. obj is now read-only ~~~~~~~~~~~~~~~~~~~~ -`obj` is now read-only. `obj.hits`, if enabled in VCL, now counts per -objecthead, not per object. `obj.last_use` has been retired. - -Note that obj.hits may not be reset in some cases where bans are in use. See -bug 1492_ for details. - -.. _1492: https://www.varnish-cache.org/trac/ticket/1492 - +`obj` is now read-only. `obj.last_use` has been retired. Some return values have been replaced ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -218,6 +211,14 @@ If you are using a lot of VMODs, you may need to increase either `workspace_backend` and `workspace_client` based on where your VMOD is doing its work. +thread_pool_purge_delay +~~~~~~~~~~~~~~~~~~~~~~~ +`thread_pool_purge_delay` has been renamed to `thread_pool_destroy_delay` +and it is in seconds now (previously was milliseconds). + +thread_pool_add_delay and thread_pool_fail_delay +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +They are in seconds now (previously were milliseconds). New parameters since 3.0 ======================== From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 05376e6 Use parameter instead of param. Message-ID: commit 05376e6fa24647256e9b1b1e2dbd49d793ed1277 Author: Lasse Karstensen Date: Wed Nov 5 10:52:24 2014 +0100 Use parameter instead of param. In the long description we have sufficient room to use the full word. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index c169e61..1ed0972 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -248,21 +248,22 @@ VSC_F(fetch_failed, uint64_t, 1, 'c', info, VSC_F(pools, uint64_t, 0, 'g', info, "Number of thread pools", - "Number of thread pools. See also param wthread_pools." + "Number of thread pools. See also parameter thread_pools." " NB: Presently pools cannot be removed once created." ) VSC_F(threads, uint64_t, 0, 'g', info, "Total number of threads", "Number of threads in all pools." - " See also params thread_pools, thread_pool_min & thread_pool_max." + " See also parameters thread_pools, thread_pool_min and" + " thread_pool_max." ) VSC_F(threads_limited, uint64_t, 0, 'c', info, "Threads hit max", "Number of times more threads were needed, but limit was reached" " in a thread pool." - " See also param thread_pool_max." + " See also parameter thread_pool_max." ) VSC_F(threads_created, uint64_t, 0, 'c', info, @@ -279,14 +280,14 @@ VSC_F(threads_failed, uint64_t, 0, 'c', info, "Thread creation failed", "Number of times creating a thread failed." " See VSL::Debug for diagnostics." - " See also param thread_fail_delay." + " See also parameter thread_fail_delay." ) VSC_F(thread_queue_len, uint64_t, 0, 'g', info, "Length of session queue", "Length of session queue waiting for threads." " NB: Only updates once per second." - " See also param queue_max." + " See also parameter queue_max." ) VSC_F(busy_sleep, uint64_t, 1, 'c', info, @@ -304,14 +305,13 @@ VSC_F(busy_wakeup, uint64_t, 1, 'c', info, VSC_F(sess_queued, uint64_t, 0, 'c', info, "Sessions queued for thread", "Number of times session was queued waiting for a thread." - " See also param queue_max." + " See also parameter queue_max." ) VSC_F(sess_dropped, uint64_t, 0, 'c', info, "Sessions dropped for thread", "Number of times session was dropped because the queue were too" - " long already." - " See also param queue_max." + " long already. See also parameter queue_max." ) /*---------------------------------------------------------------------*/ From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 6a7e22f Improve the long description of counters. Message-ID: commit 6a7e22fabd07791b3b20ad75027e2b4e53cdb79f Author: Lasse Karstensen Date: Wed Nov 5 11:03:41 2014 +0100 Improve the long description of counters. The varnish-counters man page looked so sad for the counters without long descriptions. Not there yet, but a step on the way. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 1ed0972..f93a86f 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -63,7 +63,7 @@ VSC_F(uptime, uint64_t, 0, 'a', info, "Child process uptime", - "" + "How long the child process has been running." ) @@ -118,7 +118,7 @@ VSC_F(client_req_417, uint64_t, 1, 'a', info, VSC_F(client_req, uint64_t, 1, 'a', info, "Good client requests received", - "" + "The count of parseable client requests seen." ) /*---------------------------------------------------------------------*/ @@ -150,7 +150,8 @@ VSC_F(cache_miss, uint64_t, 1, 'a', info, VSC_F(backend_conn, uint64_t, 0, 'a', info, "Backend conn. success", - "" + "How many backend connections have successfully been" + " established." ) VSC_F(backend_unhealthy, uint64_t, 0, 'a', info, @@ -292,7 +293,7 @@ VSC_F(thread_queue_len, uint64_t, 0, 'g', info, VSC_F(busy_sleep, uint64_t, 1, 'c', info, "Number of requests sent to sleep on busy objhdr", - "Number of requests sent to sleep without a worker threads because" + "Number of requests sent to sleep without a worker thread because" " they found a busy object." ) @@ -317,42 +318,44 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', info, /*---------------------------------------------------------------------*/ VSC_F(n_object, uint64_t, 1, 'i', info, - "Number of object structs made", - "" + "object structs made", + "Number of object structs made" ) VSC_F(n_vampireobject, uint64_t, 1, 'i', diag, - "Number of unresurrected objects", - "" + "unresurrected objects", + "Number of unresurrected objects" ) VSC_F(n_objectcore, uint64_t, 1, 'i', info, - "Number of objectcore structs made", - "" + "objectcore structs made", + "Number of objectcore structs made" ) VSC_F(n_objecthead, uint64_t, 1, 'i', info, - "Number of objecthead structs made", - "" + "objecthead structs made", + "Number of objecthead structs made" ) VSC_F(n_waitinglist, uint64_t, 1, 'i', debug, - "Number of waitinglist structs made", - "" + "waitinglist structs made", + "Number of waitinglist structs made" ) VSC_F(n_backend, uint64_t, 0, 'i', info, "Number of backends", - "" + "Number of backends known to us." ) VSC_F(n_expired, uint64_t, 0, 'i', info, "Number of expired objects", - "" + "Number of objects that expired from cache" + " because of old age." ) VSC_F(n_lru_nuked, uint64_t, 0, 'i', info, "Number of LRU nuked objects", - "" + "How many objects have been forcefully evicted" + " from storage to make room for a new object." ) VSC_F(n_lru_moved, uint64_t, 0, 'i', diag, "Number of LRU moved objects", - "" + "Number of move operations done on the LRU list." ) VSC_F(losthdr, uint64_t, 0, 'a', info, From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 817e534 GC, Kristian says is no longer needed Message-ID: commit 817e534323c582bd3e61ec7348ae634aa9cbeee5 Author: Federico G. Schwindt Date: Wed Nov 5 13:02:00 2014 +0000 GC, Kristian says is no longer needed diff --git a/bin/varnishtest/Makefile.kristian b/bin/varnishtest/Makefile.kristian deleted file mode 100644 index 04b9f8a..0000000 --- a/bin/varnishtest/Makefile.kristian +++ /dev/null @@ -1,35 +0,0 @@ -# Usage: make -f Makefile.kristian -j20 (for 20 parallel jobs) - -SHELL = /bin/sh - -# Complete all tests even if one fails -MAKEFLAGS = -k - -objs=$(addsuffix .done,$(basename $(notdir $(wildcard tests/*vtc)))) - -check: $(objs) - @echo "===================" - @echo "All tests succeeded" - @echo "===================" - -# Capture output of varnishtest for a specific test. Only output it if the -# test failed. -# -# XXX: 'echo' in dash (often used as /bin/sh) does not support -E and -# always interpret \n's(as in a \ and a n, not a real line break), -# thus the /bin/echo -E crud to avoid double line breaks on -# "body | \n". -# -# XXX: Even if this doesn't create a real file, it's not a phony target per -# se, as it has to fire every time you run 'make check'. -%.done: tests/%.vtc - @if output=$$(./varnishtest $< 2>&1 ); then\ - echo "$< OK";\ - else\ - ret=$$?;\ - /bin/echo -E 1>&2 "$$output";\ - echo 1>&2 $< "FAILED ($$ret)\n";\ - exit $$ret;\ - fi; - -.PHONY: check From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 153e2cd Plural Message-ID: commit 153e2cd843b3360bc3b616661436f3ffdfb63af3 Author: Federico G. Schwindt Date: Wed Nov 5 13:05:59 2014 +0000 Plural diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index f43f019..96d61bd 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -143,7 +143,7 @@ struct parspec WRK_parspec[] = { "\n" "This controls the decay of thread pools when idle(-ish).\n" "\n" - "Minimum is 0.01 second.", + "Minimum is 0.01 seconds.", EXPERIMENTAL | DELAYED_EFFECT, "1", "seconds" }, { "thread_pool_add_delay", From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 91d144e Consistent use of name, mention parameter. Message-ID: commit 91d144e32a41f73113b7b9ec72d5a44f6d8a1f37 Author: Lasse Karstensen Date: Fri Nov 7 14:30:08 2014 +0100 Consistent use of name, mention parameter. diff --git a/doc/sphinx/users-guide/vcl-inline-c.rst b/doc/sphinx/users-guide/vcl-inline-c.rst index 5cc0ead..e0d0998 100644 --- a/doc/sphinx/users-guide/vcl-inline-c.rst +++ b/doc/sphinx/users-guide/vcl-inline-c.rst @@ -1,16 +1,16 @@ -Using In-line C to extend Varnish +Using inline C to extend Varnish --------------------------------- (Here there be dragons. Big and mean ones.) -You can use *in-line C* to extend Varnish. Please note that you can +You can use *inline C* to extend Varnish. Please note that you can seriously mess up Varnish this way. The C code runs within the Varnish Cache process so if your code generates a segfault the cache will crash. -One of the first uses of In-line C was logging to `syslog`.:: +One of the first uses of inline C was logging to `syslog`.:: # The include statements must be outside the subroutines. C{ @@ -22,3 +22,7 @@ One of the first uses of In-line C was logging to `syslog`.:: syslog(LOG_INFO, "Something happened at VCL line XX."); }C } + +To use inline C you need to enable it with the ``vcc_allow_inline_c`` +parameter. + From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 39349f4 Spelling Message-ID: commit 39349f4fe91a39bba329658b2a31196abddd26c8 Author: Federico G. Schwindt Date: Sun Nov 9 18:49:48 2014 +0000 Spelling diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index d5e2c02..7be8bc6 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -107,7 +107,7 @@ struct parspec mgt_parspec[] = { { "workspace_thread", tweak_bytes_u, &mgt_param.workspace_thread, "256", "8192", - "Bytes of auxillary workspace per thread.\n" + "Bytes of auxiliary workspace per thread.\n" "This workspace is used for certain temporary data structures" " during the operation of a worker thread.\n" "One use is for the io-vectors for writing requests and" @@ -144,7 +144,7 @@ struct parspec mgt_parspec[] = { { "http_resp_size", tweak_bytes_u, &mgt_param.http_resp_size, "256", NULL, - "Maximum number of bytes of HTTP backend resonse we will deal " + "Maximum number of bytes of HTTP backend response we will deal " "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" "The memory for the request is allocated from the worker " @@ -283,7 +283,7 @@ struct parspec mgt_parspec[] = { tweak_bytes_u, &mgt_param.cli_limit, "128", "99999999", "Maximum size of CLI response. If the response exceeds" - " this limit, the reponse code will be 201 instead of" + " this limit, the response code will be 201 instead of" " 200 and the last line will indicate the truncation.", 0, "48k", "bytes" }, @@ -389,7 +389,7 @@ struct parspec mgt_parspec[] = { "If we run out of resources, such as file descriptors or " "worker threads, the acceptor will sleep between accepts.\n" "This parameter (multiplicatively) reduce the sleep duration " - "for each succesfull accept. (ie: 0.9 = reduce by 10%)", + "for each successful accept. (ie: 0.9 = reduce by 10%)", EXPERIMENTAL, "0.900", "" }, { "clock_skew", tweak_uint, &mgt_param.clock_skew, @@ -416,7 +416,7 @@ struct parspec mgt_parspec[] = { "100000", "sessions" }, { "timeout_linger", tweak_timeout, &mgt_param.timeout_linger, "0", NULL, - "How long time the workerthread lingers on an idle session " + "How long the worker thread lingers on an idle session " "before handing it over to the waiter.\n" "When sessions are reused, as much as half of all reuses " "happen within the first 100 msec of the previous request " @@ -433,7 +433,7 @@ struct parspec mgt_parspec[] = { WAITER_DEFAULT, NULL }, { "ban_dups", tweak_bool, &mgt_param.ban_dups, NULL, NULL, - "Elimited older identical bans when new bans are created." + "Eliminate older identical bans when new bans are created." " This test is CPU intensive and scales with the number and" " complexity of active (non-Gone) bans. If identical bans" " are frequent, the amount of CPU needed to actually test " @@ -525,7 +525,7 @@ struct parspec mgt_parspec[] = { { "critbit_cooloff", tweak_timeout, &mgt_param.critbit_cooloff, "60", "254", - "How long time the critbit hasher keeps deleted objheads " + "How long the critbit hasher keeps deleted objheads " "on the cooloff list.", WIZARD, "180", "seconds" }, From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 0672a5e Use n + hist_buckets as hit flag in varnishhist bucket history Message-ID: commit 0672a5e56bffc2b22fc5e4c1e4bdc1f14a249718 Author: Martin Blix Grydeland Date: Mon Nov 10 15:22:06 2014 +0100 Use n + hist_buckets as hit flag in varnishhist bucket history Because -0 == +0, the use of negative numbers as a distinction between hits and misses in the recorded bucket history fails when there are entries of index 0. Fixes: #1623 diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index d01595c..c364ad3 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -193,7 +193,8 @@ static int /*__match_proto__ (VSLQ_dispatch_f)*/ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) { - int i, j, tag, skip, match, hit; + int i, tag, skip, match, hit; + unsigned u; double value; struct VSL_transaction *tr; @@ -259,13 +260,15 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], /* phase out old data */ if (nhist == HIST_N) { - j = rr_hist[next_hist]; - if (j < 0) { - assert(bucket_miss[-j] > 0); - bucket_miss[-j]--; + u = rr_hist[next_hist]; + if (u >= hist_buckets) { + u -= hist_buckets; + assert(u < hist_buckets); + assert(bucket_hit[u] > 0); + bucket_hit[u]--; } else { - assert(bucket_hit[j] > 0); - bucket_hit[j]--; + assert(bucket_miss[u] > 0); + bucket_miss[u]--; } } else { ++nhist; @@ -274,10 +277,10 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], /* phase in new data */ if (hit) { bucket_hit[i]++; - rr_hist[next_hist] = i; + rr_hist[next_hist] = i + hist_buckets; } else { bucket_miss[i]++; - rr_hist[next_hist] = -i; + rr_hist[next_hist] = i; } if (++next_hist == HIST_N) { next_hist = 0; From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 1588b75 Make obj.uncacheable available in vcl_deliver Message-ID: commit 1588b755323e13a1566d2a9ef085ae0efba3effb Author: Federico G. Schwindt Date: Mon Nov 10 11:43:32 2014 +0000 Make obj.uncacheable available in vcl_deliver With this is possible to find out whether the request was a pass (or hit-for-pass) in a single place. diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index 2ac4b9d..c473a21 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -22,6 +22,7 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend { set resp.http.esi = req.esi; set resp.http.be = req.backend_hint; set resp.http.c_id = client.identity; + if (obj.uncacheable) { } } sub vcl_backend_response { @@ -41,7 +42,6 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend { sub vcl_hit { if (obj.proto) { } if (obj.reason) { } - if (obj.uncacheable) { } if (obj.keep > 1m) { } if (obj.grace < 3m) { return (deliver); diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 10ab8d3..4a7bdde 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -593,9 +593,9 @@ sp_variables = [ ), ('obj.uncacheable', 'BOOL', - ( 'hit', ), + ( 'deliver', ), ( ), """ - Whether the object is uncacheable (aka hit-for-pass) + Whether the object is uncacheable (pass or hit-for-pass). """ ), ('resp', From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 60a4f5d Turn bereq.uncacheable read-only Message-ID: commit 60a4f5d5ae07120ed3d0bacfb19b7a8e51a202f4 Author: Federico G. Schwindt Date: Mon Nov 10 11:41:12 2014 +0000 Turn bereq.uncacheable read-only This had the same effect as writing to beresp.uncacheble. Conflicts: bin/varnishd/cache/cache_vrt_var.c diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 47897e1..7cfe163 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -173,20 +173,6 @@ VRT_r_beresp_##field(const struct vrt_ctx *ctx) \ /*--------------------------------------------------------------------*/ -void -VRT_l_bereq_uncacheable(const struct vrt_ctx *ctx, unsigned a) -{ - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - - if (ctx->bo->do_pass && !a) { - VSLb(ctx->vsl, SLT_VCL_Error, - "Ignoring attempt to reset bereq.uncacheable"); - } else if (a) { - ctx->bo->do_pass = 1; - } -} - unsigned VRT_r_bereq_uncacheable(const struct vrt_ctx *ctx) { diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index c473a21..ffd622b 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -52,7 +52,6 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend { } sub vcl_backend_fetch { - set bereq.uncacheable = false; if (bereq.between_bytes_timeout < 10s) { set bereq.http.quick = "please"; } diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 4a7bdde..f9e1836 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -359,17 +359,10 @@ sp_variables = [ ('bereq.uncacheable', 'BOOL', ( 'backend', ), - ( 'backend_fetch', ), """ - Indicates whether the object requested from the backend is - going to be uncacheable - either because the request was an - explicit pass from the client side or a hit on an uncacheable - ("hit for pass") object. - - Setting this variable in vcl_backend_fetch makes the object - uncacheable. - - Clearing the variable has no effect and will log the warning - "Ignoring attempt to reset bereq.uncacheable". + ( ), """ + Indicates whether this request is uncacheable due + to a pass in the client side or a hit on an existing + uncacheable object (aka hit-for-pass). """ ), ('bereq.connect_timeout', From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 223351d Doc applies to both backend.list and backend.set_health Message-ID: commit 223351da4045a283aafec1664a5c43bce5b10f9f Author: Federico G. Schwindt Date: Tue Nov 11 23:10:35 2014 +0000 Doc applies to both backend.list and backend.set_health Move explanation to its own section. Also mention the state options. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index ca2fc8c..7f419ff 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -128,15 +128,12 @@ panic.clear storage.list List storage devices -backend.list - List all backends +backend.list [] + List backends. -backend.set_health matcher state - Set health status on a backend. The matcher expression can be a - backend name or a parenthesized "(IP:port)" expression, or both. All - fields are optional. If no exact matching backend is found, partial - matching will be attempted based on the provided name, IP and port - fields. +backend.set_health + Set health status on the backends. + State is any of auto, healthy or sick values. ban [&& ]... All objects where the all the conditions match will be marked obsolete. @@ -144,6 +141,13 @@ ban [&& ]... ban.list List the active bans. +Backend Expression +------------------ + +A backend expression can be a backend name or a combination of backend +name, IP address and port in "name(IP address:port)" format. All fields +are optional. If no exact matching backend is found, partial matching +will be attempted based on the provided name, IP address and port fields. Ban Expressions --------------- From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] b9255f9 Update description Message-ID: commit b9255f9701ab0523338ed2f675f306139d460d33 Author: Federico G. Schwindt Date: Tue Nov 11 23:13:36 2014 +0000 Update description Minor cosmetic changes while here. Discussed with Dag on Frankfurt. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 5cf077e..f83e05d 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -287,8 +287,8 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) ssize_t ip_l = 0; const char *port_b = NULL; ssize_t port_l = 0; - int found = 0; - int i, j; + int all, found = 0; + int i; name_b = matcher; if (matcher != NULL) { @@ -343,8 +343,8 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) } } - for (j = 0; j < 2; ++j) { - if (j == 0 && name_b == NULL) + for (all = 0; all < 2 && found == 0; all++) { + if (all == 0 && name_b == NULL) continue; VTAILQ_FOREACH(b, &backends, list) { CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); @@ -354,7 +354,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) if (name_b != NULL && strncmp(b->vcl_name, name_b, name_l) != 0) continue; - if (j == 0 && b->vcl_name[name_l] != '\0') + if (all == 0 && b->vcl_name[name_l] != '\0') continue; if (ip_b != NULL && (b->ipv4_addr == NULL || @@ -365,9 +365,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv) found++; i = func(cli, b, priv); if (i) - return(i); - if (j == 0) - return (1); + return (i); } } return (found); @@ -472,11 +470,12 @@ cli_backend_set_health(struct cli *cli, const char * const *av, void *priv) /*---------------------------------------------------------------------*/ static struct cli_proto backend_cmds[] = { - { "backend.list", "backend.list", - "\tList all backends\n", + { "backend.list", "backend.list []", + "\tList backends.", 0, 1, "", cli_backend_list }, - { "backend.set_health", "backend.set_health matcher state", - "\tSet health status on a backend\n", + { "backend.set_health", + "backend.set_health ", + "\tSet health status on the backends.", 2, 2, "", cli_backend_set_health }, { NULL } }; From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 4aa8219 White space nit Message-ID: commit 4aa82195885fa8ed42632c82d596696a32f0289f Author: Federico G. Schwindt Date: Tue Nov 11 23:17:20 2014 +0000 White space nit diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index f83e05d..b7f6a8d 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -255,11 +255,11 @@ vbe_str2adminhealth(const char *wstate) { if (strcasecmp(wstate, "healthy") == 0) - return(ah_healthy); + return (ah_healthy); if (strcasecmp(wstate, "sick") == 0) - return(ah_sick); + return (ah_sick); if (strcmp(wstate, "auto") == 0) - return(ah_probe); + return (ah_probe); return (ah_invalid); } From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 00c133a Fix example Message-ID: commit 00c133a9b3be1a5b3a0efc486d08b45e58c1e515 Author: Federico G. Schwindt Date: Wed Nov 12 17:01:06 2014 +0000 Fix example backslash is used for escaping in varnish-cli, so escape the backslash to actually pass "\.png$". diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 70fb415..43df304 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -73,7 +73,7 @@ Support for bans is built into Varnish and available in the CLI interface. To ban every png object belonging on example.com, issue the following command:: - ban req.http.host == "example.com" && req.url ~ "\.png$" + ban req.http.host == "example.com" && req.url ~ "\\.png$" Quite powerful, really. From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] cb275cc Add changes list for future 4.0.3. Message-ID: commit cb275cc0944f7ada9a7ec3d07aa0927481da208d Author: Lasse Karstensen Date: Fri Nov 14 15:00:36 2014 +0100 Add changes list for future 4.0.3. diff --git a/configure.ac b/configure.ac index fe379b4..f6690a5 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2014 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.0.2], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.0.3-beta1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index c638014..ab1043b 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,3 +1,29 @@ +============================================== +Changes from 4.0.2 to 4.0.3-beta1 (2014-11-14) +============================================== + + +Changes since 4.0.2: + +- A lot of minor documentation fixes. +- bereq.uncacheable is now read-only. +- obj.uncacheable is now readable in vcl_deliver. +- [varnishadm] Prefer exact matches for backend.set_healthy. Bug 1349_. +- Hard-coded -sfile default size is removed. +- Truncate duplicate Content- +- [packaging] EL6 packages are once again built with -O2. + +Bugs fixed +---------- + +* 1623_ - Fix varnishhist -d segfault. +* 1607_ - Don't leak reqs on failure to revive from waitinglist. +* 1610_ - Update forgotten varnishlog example to 4.0 syntax. +* 1596_ - Delay HSH_Complete() until the storage sanity functions has finished. +* 1506_ - Keep Content-Length from backend if we can. +* 1602_ - Fix a cornercase related to empty pass objects. + + ============================================ Changes from 4.0.2-rc1 to 4.0.2 (2014-10-08) ============================================ From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 982d27c Add std.cache_req_body to call VRT_CacheReqBody from VCL Message-ID: commit 982d27cc44fbf4cdcb666dbc2ec265910a321fbe Author: Nils Goroll Date: Fri Sep 19 11:40:22 2014 +0200 Add std.cache_req_body to call VRT_CacheReqBody from VCL Initial patch by Meng Zhnag - jammy.linux at gmail.com Conflicts: lib/libvmod_std/vmod_std.c diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc index 0344d02..ef568ea 100644 --- a/bin/varnishtest/tests/c00055.vtc +++ b/bin/varnishtest/tests/c00055.vtc @@ -11,8 +11,10 @@ server s1 { } -start varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { + import ${vmod_std}; + sub vcl_recv { - C{ VRT_CacheReqBody(ctx, 1000); }C + std.cache_req_body(1KB); return (pass); } sub vcl_deliver { diff --git a/bin/varnishtest/tests/c00067.vtc b/bin/varnishtest/tests/c00067.vtc index d6d4c02..3c77433 100644 --- a/bin/varnishtest/tests/c00067.vtc +++ b/bin/varnishtest/tests/c00067.vtc @@ -31,8 +31,10 @@ client c1 { delay .2 varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { + import ${vmod_std}; + sub vcl_recv { - C{ VRT_CacheReqBody(ctx, 1000); }C + std.cache_req_body(1000B); } } diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index b15a603..ad832d1 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -198,6 +198,14 @@ Description Example set req.url = std.querysort(req.url); +$Function VOID cache_req_body(BYTES) + +Description + Cache the req.body if it is smaller than the given size +Example + std.cache_req_body(1KB); + + This will cache the req.body if its size is smaller than 1KB. $Function STRING strstr(STRING, STRING) diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index fd2bbbc..241196b 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -231,7 +231,6 @@ vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label) } } - VCL_STRING __match_proto__(td_std_strstr) vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr) { @@ -242,3 +241,12 @@ vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr) else return(strstr(mstr, msubstr)); } + +VCL_VOID __match_proto__(td_std_cache_req_body) +vmod_cache_req_body(const struct vrt_ctx *ctx, VCL_BYTES size) +{ + int result; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + result = VRT_CacheReqBody(ctx, size); + VSLb(ctx->vsl, SLT_Debug,"VRT_CacheReqBody[size: %zu] result: %d", (size_t)size, result); +} From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 088d708 More canonical debug format for vmod_cache_req_body as suggested by fgs Message-ID: commit 088d70861c57078772b06a29cac3f4acb90a36d9 Author: Nils Goroll Date: Fri Sep 19 12:43:54 2014 +0200 More canonical debug format for vmod_cache_req_body as suggested by fgs diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 241196b..ea2a41d 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -248,5 +248,5 @@ vmod_cache_req_body(const struct vrt_ctx *ctx, VCL_BYTES size) int result; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); result = VRT_CacheReqBody(ctx, size); - VSLb(ctx->vsl, SLT_Debug,"VRT_CacheReqBody[size: %zu] result: %d", (size_t)size, result); + VSLb(ctx->vsl, SLT_Debug,"VRT_CacheReqBody(%zu): %d", (size_t)size, result); } From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 6b28848 minor polish Message-ID: commit 6b2884838d875cf189b10b27cbdcad0e9bfc5732 Author: Poul-Henning Kamp Date: Wed Oct 8 09:16:52 2014 +0000 minor polish diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index ad832d1..79d12f1 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -201,11 +201,15 @@ Example $Function VOID cache_req_body(BYTES) Description - Cache the req.body if it is smaller than the given size + Cache the req.body if it is smaller than the given size Example - std.cache_req_body(1KB); + std.cache_req_body(1KB); - This will cache the req.body if its size is smaller than 1KB. + This will cache the req.body if its size is smaller than 1KB. + + Caching the req.body makes it possible to retry pass + operations (POST, PUT). + $Function STRING strstr(STRING, STRING) From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 01b4e4a Move obj.hits to struct objcore. This gives us a separate hits counter per object, in line with the functionality as it was in Varnish 3.0. Message-ID: commit 01b4e4a4d3a674f76fc0c38c1dd8e7485999cff6 Author: Dag Haavi Finstad Date: Mon Oct 27 14:31:08 2014 +0100 Move obj.hits to struct objcore. This gives us a separate hits counter per object, in line with the functionality as it was in Varnish 3.0. Conflicts: bin/varnishd/cache/cache_vrt_var.c diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 04debc8..6aca502 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -425,6 +425,7 @@ struct objcore { struct objhead *objhead; struct busyobj *busyobj; double timer_when; + long hits; uint16_t flags; #define OC_F_BUSY (1<<1) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 47f346f..59e6d94 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -435,8 +435,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 1); assert(oc->objhead == oh); oc->refcnt++; - if (oh->hits < LONG_MAX) - oh->hits++; + if (oc->hits < LONG_MAX) + oc->hits++; Lck_Unlock(&oh->mtx); assert(HSH_DerefObjHead(&wrk->stats, &oh)); *ocp = oc; @@ -464,8 +464,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, AZ(req->hash_ignore_busy); retval = HSH_EXP; } - if (oh->hits < LONG_MAX) - oh->hits++; + if (exp_oc->hits < LONG_MAX) + exp_oc->hits++; Lck_Unlock(&oh->mtx); if (retval == HSH_EXP) assert(HSH_DerefObjHead(&wrk->stats, &oh)); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 7cfe163..a5f0bde 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -581,8 +581,7 @@ VRT_r_obj_hits(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->obj->objcore, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->obj->objcore->objhead, OBJHEAD_MAGIC); - return (ctx->req->obj->objcore->objhead->hits); + return (ctx->req->obj->objcore->hits); } unsigned diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 3c6f815..0afdb93 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -95,8 +95,6 @@ struct objhead { uint8_t digest[DIGEST_LEN]; struct waitinglist *waitinglist; - long hits; - /*---------------------------------------------------- * The fields below are for the sole private use of * the hash implementation(s). diff --git a/bin/varnishtest/tests/v00039.vtc b/bin/varnishtest/tests/v00039.vtc index 90bc865..029e114 100644 --- a/bin/varnishtest/tests/v00039.vtc +++ b/bin/varnishtest/tests/v00039.vtc @@ -31,19 +31,19 @@ client c1 { expect resp.bodylen == 6 expect resp.http.hits == 1 - # This is a miss on different vary -> hits still == 1 + # This is a miss on different vary -> hits == 0 txreq -url "/" -hdr "Bar: 2" rxresp expect resp.status == 200 expect resp.bodylen == 4 - expect resp.http.hits == 1 + expect resp.http.hits == 0 - # This is a hit -> hits == 2 + # This is a hit -> hits == 1 txreq -url "/" -hdr "Bar: 2" rxresp expect resp.status == 200 expect resp.bodylen == 4 - expect resp.http.hits == 2 + expect resp.http.hits == 1 } -run diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index f9e1836..372ef1c 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -548,13 +548,9 @@ sp_variables = [ 'INT', ( 'hit', 'deliver',), ( ), """ - The count of cache-hits on this hash-key since it was - last instantiated. This counts cache-hits across all - Vary:-ants on this hash-key. - The counter will only be reset to zero if/when all objects - with this hash-key have disappeared from cache. - NB: obj.hits == 0 does *not* indicate a cache miss. - """ + The count of cache-hits on this object. A value of 0 indicates a + cache miss. + """ ), ('obj.http.', 'HEADER', From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] efdd025 Fix lookbehind handling in regsuball Message-ID: commit efdd025439d5914fb256ae2b2576a36c0be424a7 Author: Federico G. Schwindt Date: Tue Oct 14 01:41:57 2014 +0100 Fix lookbehind handling in regsuball Do not advance the subject but use the ovector information as offset, pcre might need to peek back when handling lookbehinds. Original patch from MegaMaddin via github. Fixes: #1557 diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index d0ecb78..fd6353a 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -92,6 +92,7 @@ VRT_regsub(const struct vrt_ctx *ctx, int all, const char *str, void *re, const char *s; unsigned u, x; int options = 0; + int offset = 0; size_t len; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -120,7 +121,7 @@ VRT_regsub(const struct vrt_ctx *ctx, int all, const char *str, void *re, do { /* Copy prefix to match */ - Tadd(&res, str, ovector[0]); + Tadd(&res, str + offset, ovector[0] - offset); for (s = sub ; *s != '\0'; s++ ) { if (*s != '\\' || s[1] == '\0') { if (res.b < res.e) @@ -138,13 +139,12 @@ VRT_regsub(const struct vrt_ctx *ctx, int all, const char *str, void *re, *res.b++ = *s; } } - str += ovector[1]; - len -= ovector[1]; + offset = ovector[1]; if (!all) break; memset(&ovector, 0, sizeof(ovector)); options |= VRE_NOTEMPTY; - i = VRE_exec(t, str, len, 0, options, ovector, 30, + i = VRE_exec(t, str, len, offset, options, ovector, 30, &cache_param->vre_limits); if (i < VRE_ERROR_NOMATCH ) { WS_Release(ctx->ws, 0); @@ -155,7 +155,7 @@ VRT_regsub(const struct vrt_ctx *ctx, int all, const char *str, void *re, } while (i != VRE_ERROR_NOMATCH); /* Copy suffix to match */ - Tadd(&res, str, len+1); + Tadd(&res, str + offset, len - offset + 1); if (res.b >= res.e) { WS_Release(ctx->ws, 0); return (str); diff --git a/bin/varnishtest/tests/r01557.vtc b/bin/varnishtest/tests/r01557.vtc new file mode 100644 index 0000000..8ada32f --- /dev/null +++ b/bin/varnishtest/tests/r01557.vtc @@ -0,0 +1,19 @@ +varnishtest "Test case for #1557" + +server s1 { + rxreq + expect req.url == "/?foobar=2" + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.url = regsuball(req.url, + "(?<=[&\?])(foo|bar)=[^&]+(?:&|$)", ""); + } +} -start + +client c1 { + txreq -url "/?foo=0&bar=1&foobar=2" + rxresp +} -run From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 9f5a153 Get the name token out of the way prior to looking for a ', ' or ')'. Message-ID: commit 9f5a153feb3bc6a90a77d8148ea35682d0aa8fa5 Author: Dag Haavi Finstad Date: Tue Sep 23 11:21:42 2014 +0200 Get the name token out of the way prior to looking for a ',' or ')'. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index d2d9dc2..bf386f3 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -645,8 +645,8 @@ def parse_func(tl, rt_type=None, pobj=None): t = tl.get_token() if is_c_name(t.str): al[-1].nam = t.str - t = None - elif t.str == ",": + t = tl.get_token() + if t.str == ",": t = None elif t.str == ")": break From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] 802f2ff Polish Message-ID: commit 802f2ff5fc061fc8b446f3b3a2ca79cdaeb84e7f Author: Federico G. Schwindt Date: Fri Oct 10 01:01:27 2014 +0100 Polish Improve consistency, add argument names and rewording. Conflicts: lib/libvmod_std/vmod.vcc diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 79d12f1..a88382f 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -41,25 +41,25 @@ which all have the form:: These functions attempt to convert STRING to the TYPE, and if that fails, they return the second argument, which must have the given TYPE. -$Function STRING toupper(STRING_LIST) +$Function STRING toupper(STRING_LIST s) Description - Converts the string *s* to upper case. + Converts the string *s* to uppercase. Example set beresp.http.x-scream = std.toupper("yes!"); -$Function STRING tolower(STRING_LIST) +$Function STRING tolower(STRING_LIST s) Description - Converts the string *s* to lower case. + Converts the string *s* to lowercase. Example set beresp.http.x-nice = std.tolower("VerY"); -$Function VOID set_ip_tos(INT) +$Function VOID set_ip_tos(INT tos) Description - Sets the Type-of-Service flag for the current session. Please - note that the TOS flag is not removed by the end of the + Sets the IP type-of-service (TOS) field for the current session to *tos*. + Please note that the TOS field is not removed by the end of the request so probably want to set it on every request should you utilize it. Example @@ -67,24 +67,24 @@ Example | std.set_ip_tos(0x0); | } -$Function REAL random(REAL, REAL) +$Function REAL random(REAL lo, REAL hi) Description - Returns a random REAL number between *a* and *b*. + Returns a random real number between *lo* and *hi*. Example set beresp.http.x-random-number = std.random(1, 100); -$Function VOID log(STRING_LIST) +$Function VOID log(STRING_LIST s) Description - Logs *string* to the shared memory log, using VSL tag *SLT_VCL_Log*. + Logs the string *s* to the shared memory log, using VSL tag *SLT_VCL_Log*. Example std.log("Something fishy is going on with the vhost " + req.host); -$Function VOID syslog(INT, STRING_LIST) +$Function VOID syslog(INT priority, STRING_LIST s) Description - Logs *string* to syslog marked with *priority*. See your + Logs the string *s* to syslog marked with *priority*. See your system's syslog.h file for the legal values of *priority*. Example std.syslog(8 + 1, "Something is wrong"); @@ -99,132 +99,133 @@ Description Example set beresp.http.x-served-by = std.fileread("/etc/hostname"); -$Function VOID collect(HEADER) +$Function VOID collect(HEADER hdr) Description - Collapses the header, joining the headers into one. + Collapses the header *hdr*, joining them into one. Example std.collect(req.http.cookie); + This will collapse several Cookie: headers into one, long cookie header. -$Function DURATION duration(STRING, DURATION) +$Function DURATION duration(STRING s, DURATION fallback) Description Converts the string *s* to seconds. *s* must be quantified with ms (milliseconds), s (seconds), m (minutes), h (hours), - d (days), w (weeks) or y (years) units. If *s* fails to parse, + d (days), w (weeks) or y (years) units. If conversion fails, *fallback* will be returned. Example set beresp.ttl = std.duration("1w", 3600s); -$Function INT integer(STRING, INT) +$Function INT integer(STRING s, INT fallback) Description - Converts the string *s* to an integer. If *s* fails to parse, + Converts the string *s* to an integer. If conversion fails, *fallback* will be returned. Example - if (std.integer(beresp.http.x-foo, 0) > 5) { ... } + | if (std.integer(beresp.http.x-foo, 0) > 5) { + | ... + | } -$Function IP ip(STRING, IP) +$Function IP ip(STRING s, IP fallback) Description - Converts string *s* to the first IP number returned by + Converts the string *s* to the first IP number returned by the system library function getaddrinfo(3). If conversion fails, *fallback* will be returned. Example - if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { ... } + | if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { + | ... + | } -$Function REAL real(STRING, REAL) +$Function REAL real(STRING s, REAL fallback) Description - Converts the string *s* to a real. If *s* fails to parse, + Converts the string *s* to a real. If conversion fails, *fallback* will be returned. Example set req.http.x-real = std.real(req.http.x-foo, 0.0); -$Function TIME real2time(REAL) +$Function TIME real2time(REAL r) Description Converts the real *r* to a time. Example set req.http.x-time = std.real2time(1140618699.00); -$Function INT time2integer(TIME) +$Function INT time2integer(TIME t) Description Converts the time *t* to a integer. Example set req.http.x-int = std.time2integer(now); -$Function REAL time2real(TIME) +$Function REAL time2real(TIME t) Description Converts the time *t* to a real. Example set req.http.x-real = std.time2real(now); -$Function BOOL healthy(BACKEND) +$Function BOOL healthy(BACKEND be) Description - Returns true if the backend is healthy. + Returns `true` if the backend *be* is healthy. -$Function INT port(IP) +$Function INT port(IP ip) Description - Returns the port number of an IP address. + Returns the port number of the IP address *ip*. -$Function VOID rollback(HTTP) +$Function VOID rollback(HTTP h) Description - Restore *h* HTTP headers to their original state. + Restores the *h* HTTP headers to their original state. Example std.rollback(bereq); -$Function VOID timestamp(STRING) +$Function VOID timestamp(STRING s) Description - Introduces a timestamp in the log with the current time. Uses - the argument as the timespamp label. This is useful to time - the execution of lengthy VCL procedures, and makes the - timestamps inserted automatically by Varnish more accurate. + Introduces a timestamp in the log with the current time, using + the string *s* as the label. This is useful to time the execution + of lengthy VCL procedures, and makes the timestamps inserted + automatically by Varnish more accurate. Example std.timestamp("curl-request"); $Function STRING querysort(STRING) Description - Sorts the querystring for cache normalization purposes. + Sorts the query string for cache normalization purposes. Example set req.url = std.querysort(req.url); -$Function VOID cache_req_body(BYTES) +$Function VOID cache_req_body(BYTES size) Description - Cache the req.body if it is smaller than the given size + Cache the req.body if it is smaller than *size*. + + Caching the req.body makes it possible to retry pass + operations (POST, PUT). Example std.cache_req_body(1KB); This will cache the req.body if its size is smaller than 1KB. - Caching the req.body makes it possible to retry pass - operations (POST, PUT). - - -$Function STRING strstr(STRING, STRING) +$Function STRING strstr(STRING s1, STRING s2) Description - Returns the substring if the second string is a substring of the first - string. Note that the comparison is case sensitive. You can - use the tolower function on both strings if you want case - insensitivity. - - If there is no match a NULL pointer is returned which would - evaluate to false in an if-test. + Returns the first occurrence of the string *s2* in the string + *s1*, or an empty string if not found. + Note that the comparison is case sensitive. Example - if (std.strstr(req.url, req.http.x-restrict)) - + | if (std.strstr(req.url, req.http.x-restrict)) { + | ... + | } SEE ALSO From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] a710884 Remove the 80% file system free space check Message-ID: commit a710884ba3076c45be2f092983a19176dde908a8 Author: Martin Blix Grydeland Date: Mon Oct 6 15:14:37 2014 +0200 Remove the 80% file system free space check This check never worked as intended for several reasons: - Didn't take the existing file size into account, causing it to succeed on first startup but fail on next - Sparse files were not handled, and can't be handled as we don't know where in the file a hole could be and whether truncation actually would change the number of blocks used at all Fixes: #1343 diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index ace90af..1cd890c 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -230,11 +230,6 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) if (i) fprintf(stderr, "WARNING: (%s) file size reduced" " to %ju due to system \"off_t\" limitations\n", ctx, l); - else if (l - st.st_size > fssize) { - l = fssize * 80 / 100; - fprintf(stderr, "WARNING: (%s) file size reduced" - " to %ju (80%% of available disk space)\n", ctx, l); - } if (sizeof(void *) == 4 && l > INT32_MAX) { /*lint !e506 !e774 !e845 */ fprintf(stderr, From lkarsten at varnish-software.com Thu Jan 15 15:35:41 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:41 +0100 Subject: [4.0] ed6fda4 Don't allow relative sizes for stevedore file size Message-ID: commit ed6fda4e96b6204b3a0de6c922c2e05a3484fd41 Author: Martin Blix Grydeland Date: Mon Oct 6 15:36:19 2014 +0200 Don't allow relative sizes for stevedore file size diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 1cd890c..9ce647f 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -201,7 +201,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) ctx); } else { AN(size); - q = VNUM_2bytes(size, &l, fssize); + q = VNUM_2bytes(size, &l, 0); if (q != NULL) ARGV_ERR("(%s) size \"%s\": %s\n", ctx, size, q); From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 9e622f9 Test the return value more closely Message-ID: commit 9e622f988b6e8aadcd8059b91bcbdfd9101333e3 Author: Federico G. Schwindt Date: Tue Oct 21 23:08:02 2014 +0100 Test the return value more closely Conflicts: bin/varnishtest/tests/m00018.vtc diff --git a/bin/varnishtest/tests/m00018.vtc b/bin/varnishtest/tests/m00018.vtc index b51ed18..35000ce 100644 --- a/bin/varnishtest/tests/m00018.vtc +++ b/bin/varnishtest/tests/m00018.vtc @@ -1,34 +1,24 @@ -varnishtest "Test substring matching in std" +varnishtest "Test std.substr" -server s1 { - rxreq - txresp - - rxreq - txresp +server s1 -repeat 2 { + rxreq + txresp } -start varnish v1 -vcl+backend { import ${vmod_std}; sub vcl_deliver { - if (std.strstr(req.url, "foo")) { - set resp.http.sub = "found"; - } else { - set resp.http.sub = "not found"; - } - + set resp.http.sub = std.strstr(req.url, "b"); } } -start client c1 { txreq -url "/foobar" rxresp - expect resp.http.sub == "found" - + expect resp.http.sub == "bar" txreq -url "/quux" rxresp - expect resp.http.sub == "not found" + expect resp.http.sub == "" } -run - From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 7109f80 Remove dead code and extra newlines Message-ID: commit 7109f80fb10376cc67ceac3bc7e38767d4eb6851 Author: Federico G. Schwindt Date: Tue Oct 21 23:10:39 2014 +0100 Remove dead code and extra newlines Conflicts: bin/varnishtest/tests/v00026.vtc diff --git a/bin/varnishtest/tests/m00009.vtc b/bin/varnishtest/tests/m00009.vtc index 7fbeec1..3313395 100644 --- a/bin/varnishtest/tests/m00009.vtc +++ b/bin/varnishtest/tests/m00009.vtc @@ -11,7 +11,6 @@ server s2 { txresp -body "22" } -start - server s3 { rxreq txresp -body "333" diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc index 2b52238..28d6552 100644 --- a/bin/varnishtest/tests/v00026.vtc +++ b/bin/varnishtest/tests/v00026.vtc @@ -42,10 +42,8 @@ varnish v1 -vcl+backend { set bereq.backend = h1.backend(bereq.url); } } - } -start - client c1 { txreq -url /1 rxresp @@ -70,6 +68,4 @@ client c1 { txreq -url /nohdr rxresp expect resp.http.foo == "8" - - } -run diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc index 2a7009c..01db68f 100644 --- a/bin/varnishtest/tests/v00036.vtc +++ b/bin/varnishtest/tests/v00036.vtc @@ -31,7 +31,6 @@ varnish v1 -vcl+backend { sub vcl_backend_fetch { set bereq.backend = fb1.backend(); } - } -start varnish v1 -cliok "backend.set_health s1 sick" From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 2f97e7d Test case for #1627 Message-ID: commit 2f97e7d5dfb987f9c7a84707986b2faeb0ac7923 Author: Federico G. Schwindt Date: Sat Nov 15 10:14:06 2014 +0000 Test case for #1627 diff --git a/bin/varnishtest/tests/r01627.vtc b/bin/varnishtest/tests/r01627.vtc new file mode 100644 index 0000000..ee1bc28 --- /dev/null +++ b/bin/varnishtest/tests/r01627.vtc @@ -0,0 +1,20 @@ +varnishtest "#1627, wrong CL for gzipped+streamed content with HTTP/1.0 client" + +server s1 { + rxreq + txresp -body "Testing" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_stream = true; + set beresp.do_gzip = true; + } +} -start + +client c1 { + txreq -proto "HTTP/1.0" -hdr "Accept-Encoding: gzip" + rxresp + gunzip + expect resp.bodylen == 7 +} -run From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 785458f Add info about X-F-F Message-ID: commit 785458ff2e6f57f13ff7a3938fe4994b6115dcb1 Author: Andreas Plesner Date: Tue Nov 18 08:50:43 2014 +0100 Add info about X-F-F diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index 2ee8ae7..0e5b800 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -185,6 +185,14 @@ The `remove` keyword is gone Replaced by `unset`. +X-Forwarded-For is now set before vcl_recv +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In many cases, people unintentionally removed X-Forwarded-For when +implementing their own vcl_recv. Therefore it has been moved to before +vcl_recv, so if you don't want an IP added to it, you should remove it +in vcl_recv. + Changes to existing parameters ============================== From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] db1185d Restore the default SIGSEGV handler during pan_ic Message-ID: commit db1185dc3ee1adee6deb0b2b65bdb9b615395504 Author: Nils Goroll Date: Mon Dec 1 09:28:54 2014 +0100 Restore the default SIGSEGV handler during pan_ic Leaving it enabled could hide panics. Fixes #1639 diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index c179736..67ba4cf 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -37,6 +37,7 @@ #include #include +#include #include "cache.h" #include "common/heritage.h" @@ -429,10 +430,21 @@ pan_ic(const char *func, const char *file, int line, const char *cond, const char *q; struct req *req; struct busyobj *bo; + struct sigaction sa; AZ(pthread_mutex_lock(&panicstr_mtx)); /* Won't be released, we're going to die anyway */ + + /* + * should we trigger a SIGSEGV while handling a panic, our sigsegv + * handler would hide the panic, so we need to reset the handler to + * default + */ + memset(&sa, 0, sizeof sa); + sa.sa_handler = SIG_DFL; + (void)sigaction(SIGSEGV, &sa, NULL); + switch(kind) { case VAS_WRONG: VSB_printf(pan_vsp, From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 83da2ec Ensure bo is set should we panic in VBO_DerefBusyObj Message-ID: commit 83da2ecfdc28078033baf36e7127d34177ce58fb Author: Federico G. Schwindt Date: Mon Nov 17 12:46:25 2014 +0000 Ensure bo is set should we panic in VBO_DerefBusyObj diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d24bfff..9277e5c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -932,6 +932,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, } } VSLb_ts_req(req, "Fetch", W_TIM_real(wrk)); - THR_SetBusyobj(NULL); VBO_DerefBusyObj(wrk, &bo); + THR_SetBusyobj(NULL); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 073e9fb..9c60b0f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -628,6 +628,7 @@ cnt_pipe(struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); http_Teardown(bo->bereq); VBO_DerefBusyObj(wrk, &bo); + THR_SetBusyobj(NULL); return (REQ_FSM_DONE); } From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] d53f18d Export the VRT runtime version. Message-ID: commit d53f18df38f55318320469ba0366771a3a071c6b Author: Lasse Karstensen Date: Thu Nov 27 16:58:57 2014 +0100 Export the VRT runtime version. The vmod packages need this to know if they are installable or not for this Varnish version. diff --git a/redhat/find-provides b/redhat/find-provides index 8c7dce5..81d6c9e 100755 --- a/redhat/find-provides +++ b/redhat/find-provides @@ -12,4 +12,10 @@ fi cd $(dirname $0)/.. -printf '#include "vmod_abi.h"\nVMOD_ABI_Version' | cpp - -Iinclude | sed '/^#/D;s/"//g;s/\([A-Z]\)/\L\1/g;s/[^a-z0-9.]/-/g;s/varnish/varnishabi/' +printf '#include "vmod_abi.h"\nVMOD_ABI_Version\n' \ + | cpp - -Iinclude \ + | sed -e '/"Varnish/!d' -e 's/.*\ \(.*\)\"$/varnishabi-strict-\1/' + +printf '#include "vrt.h"\nvarnishabi- VRT_MAJOR_VERSION . VRT_MINOR_VERSION\n' \ + | cpp - -Iinclude \ + | sed -e '/^varnishabi-/!d' -e 's/U//g' -e 's/ //g' From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 304f203 Rework example Message-ID: commit 304f203b316ef2fa7a71bb6e37b93ca72ec7e276 Author: Federico G. Schwindt Date: Thu Nov 27 16:59:05 2014 +0000 Rework example Fixes #1636 diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index 231e27b..db0165f 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -343,8 +343,8 @@ To achieve a high hitrate whilst using Vary is there therefore crucial to normalize the headers the backends varies on. Remember, just a difference in casing can force different cache entries. -The following VCL code will normalize the 'Accept-Language' headers, -to one of either "en", "de" or "fr":: +The following VCL code will normalize the 'Accept-Language' header to +either "en", "de" or "fr", in this order of precedence:: if (req.http.Accept-Language) { if (req.http.Accept-Language ~ "en") { @@ -360,9 +360,6 @@ to one of either "en", "de" or "fr":: } } -The code sets the 'Accept-Encoding' header from the client to either -gzip, deflate with a preference for gzip. - Vary parse errors ~~~~~~~~~~~~~~~~~ From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] fc0eaa7 Extract gitref using same method as debs. Message-ID: commit fc0eaa7bbbc0608bc7c7bde4cd9657de61d56765 Author: Lasse Karstensen Date: Thu Nov 27 19:03:53 2014 +0100 Extract gitref using same method as debs. diff --git a/redhat/find-provides b/redhat/find-provides index 81d6c9e..2545e99 100755 --- a/redhat/find-provides +++ b/redhat/find-provides @@ -12,9 +12,8 @@ fi cd $(dirname $0)/.. -printf '#include "vmod_abi.h"\nVMOD_ABI_Version\n' \ - | cpp - -Iinclude \ - | sed -e '/"Varnish/!d' -e 's/.*\ \(.*\)\"$/varnishabi-strict-\1/' +printf '#include "vcs_version.h"\nVCS_Version\n' \ + | cpp - -Iinclude | sed -e '/^"/!d' -e 's/\"//g' -e 's/^/varnishabi-strict-/' printf '#include "vrt.h"\nvarnishabi- VRT_MAJOR_VERSION . VRT_MINOR_VERSION\n' \ | cpp - -Iinclude \ From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] c84d1f8 Reduce fetch_chunksize to 16k as agreed on VDD14Q4. Message-ID: commit c84d1f886671fd98317890b5a41bd60f0837206f Author: Federico G. Schwindt Date: Fri Nov 28 14:20:39 2014 +0000 Reduce fetch_chunksize to 16k as agreed on VDD14Q4. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 7be8bc6..345a94a 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -242,7 +242,7 @@ struct parspec mgt_parspec[] = { "Internal limits in the storage_file module makes increases " "above 128kb a dubious idea.", EXPERIMENTAL, - "128k", "bytes" }, + "16k", "bytes" }, { "fetch_maxchunksize", tweak_bytes, &mgt_param.fetch_maxchunksize, "65536", NULL, From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 7ca03c7 Sort options Message-ID: commit 7ca03c73e28e1bdf6237cce04634a45efa5726ba Author: Federico G. Schwindt Date: Sat Nov 29 14:00:25 2014 +0000 Sort options diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index fae84a4..55b30c7 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -59,8 +59,8 @@ VUT_OPT_D VUT_OPT_g VUT_OPT_h VSL_OPT_i -VUT_OPT_k VSL_OPT_I +VUT_OPT_k VSL_OPT_L VUT_OPT_n VUT_OPT_N From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 8f1981e Update examples Message-ID: commit 8f1981ef581dfaba0d750401477fa51e417d43ec Author: Federico G. Schwindt Date: Sat Nov 29 14:31:28 2014 +0000 Update examples diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index db0165f..be76f2b 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -24,10 +24,9 @@ Tool: varnishtop ~~~~~~~~~~~~~~~~ You can use varnishtop to identify what URLs are hitting the backend -the most. ``varnishtop -i txurl`` is an essential command, showing -you the top `txurl` requests Varnish is sending to the backend. You -can see some other examples of `varnishtop` usage in -:ref:`users-guide-statistics`. +the most. ``varnishtop -i BereqURL`` is an essential command, showing +you the top requests Varnish is sending to the backend. You can see some +other examples of `varnishtop` usage in :ref:`users-guide-statistics`. Tool: varnishlog @@ -35,8 +34,8 @@ Tool: varnishlog When you have identified an URL which is frequently sent to the backend you can use `varnishlog` to have a look at the request. -``varnishlog -c -m 'RxURL:^/foo/bar`` will show you the requests -coming from the client ('-c') matching `/foo/bar`. +``varnishlog -q 'ReqURL ~ "^/foo/bar"'`` will show you the requests +coming from the client matching `/foo/bar`. For more information on how `varnishlog` works please see :ref:`users-guide-logging` or man :ref:`ref-varnishlog`. @@ -241,7 +240,8 @@ Age ~~~ Varnish adds an 'Age' header to indicate how long the object has been -kept inside Varnish. You can grep out 'Age' from `varnishlog` with ``varnishlog -i TxHeader -I ^Age``. +kept inside Varnish. You can grep out 'Age' from `varnishlog` with +``varnishlog -I RespHeader:^Age``. Pragma ~~~~~~ From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 497897e bump the varnishtest CLI timeout from 20 to 30 seconds Message-ID: commit 497897e9b1a87db25fb04de67dd9a2079efe21b4 Author: Nils Goroll Date: Wed Dec 3 14:55:58 2014 +0100 bump the varnishtest CLI timeout from 20 to 30 seconds This avoids false negatives with slow name resolutions diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 92027ba..5ebac71 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -98,7 +98,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) i = write(v->cli_fd, "\n", 1); assert(i == 1); } - i = VCLI_ReadResult(v->cli_fd, &retval, &r, 20.0); + i = VCLI_ReadResult(v->cli_fd, &retval, &r, 30.0); if (i != 0) { vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 7b7e76e White space OCD. Message-ID: commit 7b7e76ea32a44f20ffa02e18adfbc6e58f55d070 Author: Lasse Karstensen Date: Wed Dec 3 16:32:18 2014 +0100 White space OCD. diff --git a/etc/example.vcl b/etc/example.vcl index a2987bb..eefdd9c 100644 --- a/etc/example.vcl +++ b/etc/example.vcl @@ -20,14 +20,14 @@ backend default { sub vcl_recv { # Happens before we check if we have this in cache already. - # + # # Typically you clean up the request here, removing cookies you don't need, # rewriting the request, etc. } sub vcl_backend_response { # Happens after we have read the response headers from the backend. - # + # # Here you clean the response headers, removing silly Set-Cookie headers # and other mistakes your backend does. } @@ -35,6 +35,6 @@ sub vcl_backend_response { sub vcl_deliver { # Happens when we have all the pieces we need, and are about to send the # response to the client. - # + # # You can do accounting or modifying the final object here. } From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] e28c0a0 Remove trailing white space. Message-ID: commit e28c0a06f0e4e1ea099cb91475152b0d698fb8d8 Author: Lasse Karstensen Date: Wed Dec 3 17:19:35 2014 +0100 Remove trailing white space. diff --git a/redhat/varnish.params b/redhat/varnish.params index 636e975..27a14dd 100644 --- a/redhat/varnish.params +++ b/redhat/varnish.params @@ -1,35 +1,35 @@ # Varnish environment configuration description. This was derived from # the old style sysconfig/defaults settings -# Set this to 1 to make systemd reload try to switch vcl without restart. +# Set this to 1 to make systemd reload try to switch vcl without restart. RELOAD_VCL=1 # Main configuration file. You probably want to change it. -VARNISH_VCL_CONF=/etc/varnish/default.vcl +VARNISH_VCL_CONF=/etc/varnish/default.vcl # Default address and port to bind to. Blank address means all IPv4 # and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted # quad, or an IPv6 address in brackets. # VARNISH_LISTEN_ADDRESS=192.168.1.5 -VARNISH_LISTEN_PORT=6081 +VARNISH_LISTEN_PORT=6081 # Admin interface listen address and port -VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 -VARNISH_ADMIN_LISTEN_PORT=6082 +VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 +VARNISH_ADMIN_LISTEN_PORT=6082 # Shared secret file for admin interface -VARNISH_SECRET_FILE=/etc/varnish/secret +VARNISH_SECRET_FILE=/etc/varnish/secret # Backend storage specification, see Storage Types in the varnishd(5) # man page for details. VARNISH_STORAGE="file,/var/lib/varnish/varnish_storage.bin,1G" # Default TTL used when the backend does not specify one -VARNISH_TTL=120 +VARNISH_TTL=120 # User and group for the varnishd worker processes -VARNISH_USER=varnish -VARNISH_GROUP=varnish +VARNISH_USER=varnish +VARNISH_GROUP=varnish # Other options, see the man page varnishd(1) #DAEMON_OPTS="-p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300" From lkarsten at varnish-software.com Thu Jan 15 15:35:42 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:42 +0100 Subject: [4.0] 8bfe2e3 Typo Message-ID: commit 8bfe2e3f64577d8d0d031edd24b29bdefdda956b Author: Federico G. Schwindt Date: Thu Dec 4 04:07:41 2014 +0000 Typo diff --git a/doc/sphinx/users-guide/vcl-variables.rst b/doc/sphinx/users-guide/vcl-variables.rst index 644c046..70862e5 100644 --- a/doc/sphinx/users-guide/vcl-variables.rst +++ b/doc/sphinx/users-guide/vcl-variables.rst @@ -22,7 +22,7 @@ objects can be accessed and manipulated using VCL. *beresp* The backend response object. It contains the headers of the object coming from the backend. If you want to modify the response coming from the - server you modify this object in `vcl_backend_reponse`. + server you modify this object in `vcl_backend_response`. *resp* The HTTP response right before it is delivered to the client. It is From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 7665b41 Add links to bug reports. Message-ID: commit 7665b41146acb3e251cbe05ec75134fc6cc67f7e Author: Lasse Karstensen Date: Wed Dec 10 13:20:58 2014 +0100 Add links to bug reports. diff --git a/doc/changes.rst b/doc/changes.rst index ab1043b..8463a26 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -23,6 +23,14 @@ Bugs fixed * 1506_ - Keep Content-Length from backend if we can. * 1602_ - Fix a cornercase related to empty pass objects. +.. _1623: https://www.varnish-cache.org/trac/ticket/1623 +.. _1607: https://www.varnish-cache.org/trac/ticket/1607 +.. _1610: https://www.varnish-cache.org/trac/ticket/1610 +.. _1596: https://www.varnish-cache.org/trac/ticket/1596 +.. _1506: https://www.varnish-cache.org/trac/ticket/1506 +.. _1602: https://www.varnish-cache.org/trac/ticket/1602 +.. _1349: https://www.varnish-cache.org/trac/ticket/1349 + ============================================ Changes from 4.0.2-rc1 to 4.0.2 (2014-10-08) From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 7ecfc0b Improve systemd service units Message-ID: commit 7ecfc0b1e75f38643b71169740638cdb4903f2c3 Author: Federico G. Schwindt Date: Wed Dec 10 11:10:57 2014 +0000 Improve systemd service units Discussed with ingvar. diff --git a/redhat/varnish.service b/redhat/varnish.service index 659dba2..a4f3355 100644 --- a/redhat/varnish.service +++ b/redhat/varnish.service @@ -27,6 +27,7 @@ EnvironmentFile=/etc/varnish/varnish.params Type=forking PIDFile=/var/run/varnish.pid PrivateTmp=true +ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF ExecStart=/usr/sbin/varnishd \ -P /var/run/varnish.pid \ -f $VARNISH_VCL_CONF \ diff --git a/redhat/varnishlog.service b/redhat/varnishlog.service index 1e3e274..c7a0193 100644 --- a/redhat/varnishlog.service +++ b/redhat/varnishlog.service @@ -1,6 +1,6 @@ [Unit] Description=Varnish HTTP accelerator logging daemon -After=network.target +After=varnish.service [Service] Type=forking diff --git a/redhat/varnishncsa.service b/redhat/varnishncsa.service index df5f19f..e2ebdcd 100644 --- a/redhat/varnishncsa.service +++ b/redhat/varnishncsa.service @@ -1,6 +1,6 @@ [Unit] -Description=Varnish NCSA logging -After=network.target +Description=Varnish HTTP accelerator NCSA daemon +After=varnish.service [Service] Type=forking From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 2ecbcb4 Add STRING + REAL support Message-ID: commit 2ecbcb468b31c964ad87faf8910f0a9406c0173a Author: Federico G. Schwindt Date: Sun Dec 14 17:59:42 2014 +0000 Add STRING + REAL support diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index f9be7ec..a9e9d3b 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -97,6 +97,7 @@ varnish v1 -vcl { sub vcl_recv { set req.http.foo = "foo" + "bar"; set req.http.foo = "foo" + 1; + set req.http.foo = "foo" + 1.5; set req.http.foo = "foo" + now; set req.http.foo = now + 1s; diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 3557a4b..c9da0b7 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -672,6 +672,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) const char *ip; const struct symbol *sym; double d; + int i; *e = NULL; if (tl->t->tok == '(') { @@ -765,9 +766,15 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) } else if (fmt == REAL) { e1 = vcc_mk_expr(REAL, "%f", vcc_DoubleVal(tl)); ERRCHK(tl); - } else { + } else if (fmt == INT) { e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t)); vcc_NextToken(tl); + } else { + vcc_NumVal(tl, &d, &i); + if (i) + e1 = vcc_mk_expr(REAL, "%f", d); + else + e1 = vcc_mk_expr(INT, "%ld", (long)d); } e1->constant = EXPR_CONST; *e = e1; From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] e81ee6e Permit to compare 2 times using standard operators Message-ID: commit e81ee6e6f1e8ac199c34e48ff77e9a25dcabfca2 Author: Federico G. Schwindt Date: Wed Dec 10 20:34:07 2014 +0000 Permit to compare 2 times using standard operators Useful with upcoming std function. diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index c9da0b7..f18b39c 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -991,6 +991,7 @@ static const struct cmps { NUM_REL(DURATION), NUM_REL(BYTES), NUM_REL(REAL), + NUM_REL(TIME), {STRING, T_EQ, "!VRT_strcmp(\v1, \v2)" }, {STRING, T_NEQ, "VRT_strcmp(\v1, \v2)" }, From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 767a891 Add a missing ',' in pan_req panic string Message-ID: commit 767a8914c0ba83db8db8921619f56fa9cf4f151f Author: Martin Blix Grydeland Date: Mon Dec 15 13:27:31 2014 +0100 Add a missing ',' in pan_req panic string diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 67ba4cf..6d97386 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -341,7 +341,7 @@ pan_req(const struct req *req) " err_code = %d, err_reason = %s,\n", req->err_code, req->err_reason ? req->err_reason : "(null)"); - VSB_printf(pan_vsp, " restarts = %d, esi_level = %d\n", + VSB_printf(pan_vsp, " restarts = %d, esi_level = %d,\n", req->restarts, req->esi_level); if (req->sp != NULL) From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 7e80a5d Clarify comment Message-ID: commit 7e80a5d920601cf3a1cb475f216b3770978eb4aa Author: Federico G. Schwindt Date: Tue Dec 16 14:30:30 2014 +0000 Clarify comment diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index b0ebaf3..f03d32e 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -89,7 +89,7 @@ RFC2616_Ttl(struct busyobj *bo, double now) /* * Initial cacheability determination per [RFC2616, 13.4] - * We do not support ranges yet, so 206 is out. + * We do not support ranges to the backend yet, so 206 is out. */ if (http_GetHdr(hp, H_Age, &p)) { From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] d381e24 Relax an assertion for the IMS update candidate object Message-ID: commit d381e2458f39989df202be7c5719e1f60b20fb19 Author: Martin Blix Grydeland Date: Tue Dec 16 18:05:54 2014 +0100 Relax an assertion for the IMS update candidate object The streaming fetch of an object can fail between lookup time and when we actually use it. Relax this assertion. Fixes: #1647 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9c60b0f..cc5ede9 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -426,7 +426,7 @@ cnt_lookup(struct worker *wrk, struct req *req) switch (wrk->handling) { case VCL_RET_DELIVER: if (boc != NULL) { - AZ(oc->flags & (OC_F_FAILED|OC_F_PASS)); + AZ(oc->flags & OC_F_PASS); AZ(oc->exp_flags & OC_EF_DYING); AZ(boc->busyobj); VBF_Fetch(wrk, req, boc, o, VBF_BACKGROUND); From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 3fbeda8 Varnishncsa escapes non-printable chars. Message-ID: commit 3fbeda80f5349c2b502f3ab9a28a4ec8d3f31c1f Author: arianna-aondio Date: Wed Dec 17 15:57:43 2014 +0100 Varnishncsa escapes non-printable chars. Fixes: #1378 diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 162829d..dcda6e5 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -182,16 +182,61 @@ flushout(void) return (0); } +static int +vsb_esc_cat(struct vsb *sb, const char *b, const char *e) +{ + AN(b); + + for (; b < e; b++) { + if (isspace(*b)) { + switch (*b) { + case '\n': + VSB_cat(sb, "\\n"); + break; + case '\t': + VSB_cat(sb, "\\t"); + break; + case '\f': + VSB_cat(sb, "\\f"); + break; + case '\r': + VSB_cat(sb, "\\r"); + break; + case '\v': + VSB_cat(sb, "\\v"); + break; + default: + VSB_putc(sb, *b); + break; + } + } else if (isprint(*b)) { + switch (*b) { + case '"': + VSB_cat(sb, "\\\""); + break; + case '\\': + VSB_cat(sb, "\\\\"); + break; + default: + VSB_putc(sb, *b); + break; + } + } else + VSB_printf(sb, "\\x%02x", *b); + } + + return (VSB_error(sb)); +} + static inline int vsb_fcat(struct vsb *vsb, const struct fragment *f, const char *dflt) { - if (f->gen == CTX.gen) { assert(f->b <= f->e); - return (VSB_bcat(vsb, f->b, f->e - f->b)); + return (vsb_esc_cat(vsb, f->b, f->e)); } if (dflt) - return (VSB_cat(vsb, dflt)); + return (vsb_esc_cat(vsb, dflt, dflt + strlen(dflt))); return (-1); } @@ -226,10 +271,10 @@ format_fragment(const struct format *format) if (format->frag->gen != CTX.gen) { if (format->string == NULL) return (-1); - AZ(VSB_cat(CTX.vsb, format->string)); + AZ(vsb_esc_cat(CTX.vsb, format->string, + format->string + strlen(format->string))); return (0); } - AZ(vsb_fcat(CTX.vsb, format->frag, NULL)); return (1); } @@ -318,13 +363,14 @@ format_auth(const struct format *format) CTX.frag[F_auth].e)) { if (format->string == NULL) return (-1); - AZ(VSB_cat(CTX.vsb, format->string)); + AZ(vsb_esc_cat(CTX.vsb, format->string, + format->string + strlen(format->string))); return (0); } q = strchr(buf, ':'); if (q != NULL) *q = '\0'; - AZ(VSB_cat(CTX.vsb, buf)); + AZ(vsb_esc_cat(CTX.vsb, buf, buf + strlen(buf))); return (1); } From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 05765d4 %hh length modifier added for non-printabale chars. Message-ID: commit 05765d4be29b0717086cccd827b953585fd23640 Author: arianna-aondio Date: Fri Dec 19 10:04:00 2014 +0100 %hh length modifier added for non-printabale chars. diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index dcda6e5..6e01e60 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -222,7 +222,7 @@ vsb_esc_cat(struct vsb *sb, const char *b, const char *e) break; } } else - VSB_printf(sb, "\\x%02x", *b); + VSB_printf(sb, "\\x%02hhx", *b); } return (VSB_error(sb)); From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] cd8f905 Correct synopsis Message-ID: commit cd8f9051a1f7f6159c1d94b9dbed65518b9a92ca Author: Federico G. Schwindt Date: Sat Dec 27 09:12:02 2014 +0000 Correct synopsis diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index 54247fd..15a1446 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -12,7 +12,7 @@ SYNOPSIS ======== .. include:: ../include/varnishlog_synopsis.rst -varnishlog |synopsis| +varnishlog |synopsis| OPTIONS ======= From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 372e5a3 Update tags Message-ID: commit 372e5a339aa2f52d463ac08814de6a343b8d9f4b Author: Federico G. Schwindt Date: Tue Dec 30 03:16:45 2014 +0000 Update tags diff --git a/doc/sphinx/users-guide/operation-statistics.rst b/doc/sphinx/users-guide/operation-statistics.rst index 788e600..de25bd8 100644 --- a/doc/sphinx/users-guide/operation-statistics.rst +++ b/doc/sphinx/users-guide/operation-statistics.rst @@ -18,11 +18,10 @@ With suitable filtering using the -I, -i, -X and -x options, it can be used to display a ranking of requested documents, clients, user agents, or any other information which is recorded in the log. -``varnishtop -i rxurl`` will show you what URLs are being asked for -by the client. ``varnishtop -i txurl`` will show you what your backend -is being asked the most. ``varnishtop -i RxHeader -I -Accept-Encoding`` will show the most popular Accept-Encoding header -the client are sending you. +``varnishtop -i ReqURL`` will show you what URLs are being asked for by +the client. ``varnishtop -i BereqURL`` will show you what your backend +is being asked the most. ``varnishtop -I ReqHeader:Accept-Encoding`` will +show the most popular Accept-Encoding header the client are sending you. For more information please see :ref:`ref-varnishtop`. From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 8bfe4de Instruct Travis to test using clang and gcc Message-ID: commit 8bfe4de421718deca940724366eeba6a25365c33 Author: Federico G. Schwindt Date: Fri Jan 2 01:00:09 2015 +0000 Instruct Travis to test using clang and gcc diff --git a/.travis.yml b/.travis.yml index f55a37b..3ed018a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ --- -script: 'make -j3 check' +language: c +compiler: + - clang + - gcc before_install: - sudo apt-get install python-docutils - ./autogen.sh - ./configure +script: 'make -j3 check' From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 132c009 Slim this table down to 80 char width like all other source files. Message-ID: commit 132c0097e3564bc535beef411297b07d18288740 Author: Poul-Henning Kamp Date: Tue Jan 6 09:59:48 2015 +0000 Slim this table down to 80 char width like all other source files. diff --git a/include/tbl/http_headers.h b/include/tbl/http_headers.h index 0a5395f..53cd8fe 100644 --- a/include/tbl/http_headers.h +++ b/include/tbl/http_headers.h @@ -29,72 +29,89 @@ * Argument list: * --------------------------------------- * a Http header name - * b session field name + * b enum name * c Supress header in filter ops * * see [RFC2616 13.5.1 End-to-end and Hop-by-hop Headers] * */ + /*lint -save -e525 -e539 */ #ifndef HTTPH_R_PASS -#define HTTPH_R_PASS (1 << 0) /* Request (c->b) in pass mode */ +#define HTTPH_R_PASS (1 << 0 ) /* Request (c->b) in pass mode */ #define HTTPH_R_FETCH (1 << 1) /* Request (c->b) for fetch */ #define HTTPH_A_INS (1 << 2) /* Response (b->o) for insert */ #endif -HTTPH("Keep-Alive", H_Keep_Alive, HTTPH_R_PASS | HTTPH_R_FETCH ) /* RFC2068 */ -HTTPH("Accept", H_Accept, 0 ) /* RFC2616 14.1 */ -HTTPH("Accept-Charset", H_Accept_Charset, 0 ) /* RFC2616 14.2 */ -HTTPH("Accept-Encoding", H_Accept_Encoding, 0 ) /* RFC2616 14.3 */ -HTTPH("Accept-Language", H_Accept_Language, 0 ) /* RFC2616 14.4 */ -HTTPH("Accept-Ranges", H_Accept_Ranges, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.5 */ -HTTPH("Age", H_Age, HTTPH_A_INS) /* RFC2616 14.6 */ -HTTPH("Allow", H_Allow, 0 ) /* RFC2616 14.7 */ -HTTPH("Authorization", H_Authorization, 0 ) /* RFC2616 14.8 */ -HTTPH("Cache-Control", H_Cache_Control, HTTPH_R_FETCH ) /* RFC2616 14.9 */ -HTTPH("Connection", H_Connection, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.10 */ -HTTPH("Content-Encoding", H_Content_Encoding, 0 ) /* RFC2616 14.11 */ -HTTPH("Content-Language", H_Content_Language, 0 ) /* RFC2616 14.12 */ -HTTPH("Content-Length", H_Content_Length, HTTPH_R_FETCH ) /* RFC2616 14.13 */ -HTTPH("Content-Location", H_Content_Location, 0 ) /* RFC2616 14.14 */ -HTTPH("Content-MD5", H_Content_MD5, 0 ) /* RFC2616 14.15 */ -HTTPH("Content-Range", H_Content_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.16 */ -HTTPH("Content-Type", H_Content_Type, 0 ) /* RFC2616 14.17 */ -HTTPH("Cookie", H_Cookie, 0 ) /* RFC6265 4.2 */ -HTTPH("Date", H_Date, 0 ) /* RFC2616 14.18 */ -HTTPH("ETag", H_ETag, 0 ) /* RFC2616 14.19 */ -HTTPH("Expect", H_Expect, 0 ) /* RFC2616 14.20 */ -HTTPH("Expires", H_Expires, 0 ) /* RFC2616 14.21 */ -HTTPH("From", H_From, 0 ) /* RFC2616 14.22 */ -HTTPH("Host", H_Host, 0 ) /* RFC2616 14.23 */ -HTTPH("HTTP2-Settings", H_HTTP2_Settings, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* draft-ietf-httpbis-http2-12.txt */ -HTTPH("If-Match", H_If_Match, HTTPH_R_FETCH ) /* RFC2616 14.24 */ -HTTPH("If-Modified-Since", H_If_Modified_Since, HTTPH_R_FETCH ) /* RFC2616 14.25 */ -HTTPH("If-None-Match", H_If_None_Match, HTTPH_R_FETCH ) /* RFC2616 14.26 */ -HTTPH("If-Range", H_If_Range, HTTPH_R_FETCH ) /* RFC2616 14.27 */ -HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, HTTPH_R_FETCH ) /* RFC2616 14.28 */ -HTTPH("Last-Modified", H_Last_Modified, 0 ) /* RFC2616 14.29 */ -HTTPH("Location", H_Location, 0 ) /* RFC2616 14.30 */ -HTTPH("Max-Forwards", H_Max_Forwards, 0 ) /* RFC2616 14.31 */ -HTTPH("Pragma", H_Pragma, 0 ) /* RFC2616 14.32 */ -HTTPH("Proxy-Authenticate", H_Proxy_Authenticate, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.33 */ -HTTPH("Proxy-Authorization", H_Proxy_Authorization, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.34 */ -HTTPH("Range", H_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.35 */ -HTTPH("Referer", H_Referer, 0 ) /* RFC2616 14.36 */ -HTTPH("Retry-After", H_Retry_After, 0 ) /* RFC2616 14.37 */ -HTTPH("Server", H_Server, 0 ) /* RFC2616 14.38 */ -HTTPH("Set-Cookie", H_Set_Cookie, 0 ) /* RFC6265 4.1 */ -HTTPH("TE", H_TE, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.39 */ -HTTPH("Trailer", H_Trailer, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.40 */ -HTTPH("Transfer-Encoding", H_Transfer_Encoding, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.41 */ -HTTPH("Upgrade", H_Upgrade, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.42 */ -HTTPH("User-Agent", H_User_Agent, 0 ) /* RFC2616 14.43 */ -HTTPH("Vary", H_Vary, 0 ) /* RFC2616 14.44 */ -HTTPH("Via", H_Via, 0 ) /* RFC2616 14.45 */ -HTTPH("Warning", H_Warning, 0 ) /* RFC2616 14.46 */ -HTTPH("WWW-Authenticate", H_WWW_Authenticate, 0 ) /* RFC2616 14.47 */ -HTTPH("X-Forwarded-For", H_X_Forwarded_For, 0 ) /* Not RFC */ +/* Shorthand for this file only, to keep table narrow */ + +#if defined(P) || defined(F) || defined(I) || defined(H) +#error "Macro overloading" // Trust but verify +#endif + +#define P HTTPH_R_PASS +#define F HTTPH_R_FETCH +#define I HTTPH_A_INS +#define H(s,e,f) HTTPH(s, e, f) + +H("Keep-Alive", H_Keep_Alive, P|F ) // 2068 +H("Accept", H_Accept, 0 ) // 2616 14.1 +H("Accept-Charset", H_Accept_Charset, 0 ) // 2616 14.2 +H("Accept-Encoding", H_Accept_Encoding, 0 ) // 2616 14.3 +H("Accept-Language", H_Accept_Language, 0 ) // 2616 14.4 +H("Accept-Ranges", H_Accept_Ranges, F|I) // 2616 14.5 +H("Age", H_Age, I) // 2616 14.6 +H("Allow", H_Allow, 0 ) // 2616 14.7 +H("Authorization", H_Authorization, 0 ) // 2616 14.8 +H("Cache-Control", H_Cache_Control, F ) // 2616 14.9 +H("Connection", H_Connection, P|F|I) // 2616 14.10 +H("Content-Encoding", H_Content_Encoding, 0 ) // 2616 14.11 +H("Content-Language", H_Content_Language, 0 ) // 2616 14.12 +H("Content-Length", H_Content_Length, F ) // 2616 14.13 +H("Content-Location", H_Content_Location, 0 ) // 2616 14.14 +H("Content-MD5", H_Content_MD5, 0 ) // 2616 14.15 +H("Content-Range", H_Content_Range, F|I) // 2616 14.16 +H("Content-Type", H_Content_Type, 0 ) // 2616 14.17 +H("Cookie", H_Cookie, 0 ) // 6265 4.2 +H("Date", H_Date, 0 ) // 2616 14.18 +H("ETag", H_ETag, 0 ) // 2616 14.19 +H("Expect", H_Expect, 0 ) // 2616 14.20 +H("Expires", H_Expires, 0 ) // 2616 14.21 +H("From", H_From, 0 ) // 2616 14.22 +H("Host", H_Host, 0 ) // 2616 14.23 +H("HTTP2-Settings", H_HTTP2_Settings, P|F|I) // httpbis-http2-16.txt +H("If-Match", H_If_Match, F ) // 2616 14.24 +H("If-Modified-Since", H_If_Modified_Since, F ) // 2616 14.25 +H("If-None-Match", H_If_None_Match, F ) // 2616 14.26 +H("If-Range", H_If_Range, F ) // 2616 14.27 +H("If-Unmodified-Since",H_If_Unmodifed_Since, F ) // 2616 14.28 +H("Last-Modified", H_Last_Modified, 0 ) // 2616 14.29 +H("Location", H_Location, 0 ) // 2616 14.30 +H("Max-Forwards", H_Max_Forwards, 0 ) // 2616 14.31 +H("Pragma", H_Pragma, 0 ) // 2616 14.32 +H("Proxy-Authenticate", H_Proxy_Authenticate, F|I) // 2616 14.33 +H("Proxy-Authorization",H_Proxy_Authorization, F|I) // 2616 14.34 +H("Range", H_Range, F|I) // 2616 14.35 +H("Referer", H_Referer, 0 ) // 2616 14.36 +H("Retry-After", H_Retry_After, 0 ) // 2616 14.37 +H("Server", H_Server, 0 ) // 2616 14.38 +H("Set-Cookie", H_Set_Cookie, 0 ) // 6265 4.1 +H("TE", H_TE, P|F|I) // 2616 14.39 +H("Trailer", H_Trailer, P|F|I) // 2616 14.40 +H("Transfer-Encoding", H_Transfer_Encoding, P|F|I) // 2616 14.41 +H("Upgrade", H_Upgrade, P|F|I) // 2616 14.42 +H("User-Agent", H_User_Agent, 0 ) // 2616 14.43 +H("Vary", H_Vary, 0 ) // 2616 14.44 +H("Via", H_Via, 0 ) // 2616 14.45 +H("Warning", H_Warning, 0 ) // 2616 14.46 +H("WWW-Authenticate", H_WWW_Authenticate, 0 ) // 2616 14.47 +H("X-Forwarded-For", H_X_Forwarded_For, 0 ) // No RFC + +#undef P +#undef F +#undef I +#undef H /*lint -restore */ From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] d4c30d5 Language nit from herrpaco@github Message-ID: commit d4c30d5a42a23af56d4d87fdd97127c5ea172e0e Author: Poul-Henning Kamp Date: Tue Jan 6 13:54:20 2015 +0000 Language nit from herrpaco at github diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index b87a1a6..1adb5fe 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -32,7 +32,7 @@ Conventions used in this manual include: http://www.varnish-cache.org/ A hyperlink. -Longer listings like example command output and VCL will look like this:: +Longer listings like example command output and VCL look like this:: $ /opt/varnish/sbin/varnishd -V varnishd (varnish-4.0.0-tp1 revision ddd00e1) From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 17cdf89 Minor typos from dbs@github Message-ID: commit 17cdf898cce0370c4065afd88c63620734e4600c Author: Poul-Henning Kamp Date: Tue Jan 6 13:56:26 2015 +0000 Minor typos from dbs at github diff --git a/doc/sphinx/tutorial/introduction.rst b/doc/sphinx/tutorial/introduction.rst index 330764f..cff7268 100644 --- a/doc/sphinx/tutorial/introduction.rst +++ b/doc/sphinx/tutorial/introduction.rst @@ -30,7 +30,7 @@ Performance Varnish has a modern architecture and is written with performance in mind. It is usually bound by the speed of the network, effectively turning performance into a non-issue. You get to focus on how your web -application work and you can allow yourself, to some degree, to care +applications work and you can allow yourself, to some degree, to care less about performance and scalability. .. XXX:Not totally sure what the last sentence above means. benc @@ -58,7 +58,7 @@ About the Varnish development process ------------------------------------- Varnish is a community driven project. The development is overseen by -the Varnish Governing Board which currently consist of Poul-Henning Kamp +the Varnish Governing Board which currently consists of Poul-Henning Kamp (Architect), Rogier Mulhuijzen (Fastly) and Lasse Karstensen (Varnish Software). @@ -69,13 +69,13 @@ Getting in touch ---------------- You can get in touch with us through many channels. For real time chat -you can reach us on IRC trough the server irc.linpro.net on the #varnish +you can reach us on IRC through the server irc.linpro.net on the #varnish and #varnish-hacking channels. -There are two mailing lists available. One for user questions and one +There are two mailing lists available: one for user questions and one for development discussions. See https://www.varnish-cache.org/lists for information and signup. There is also a web forum on the same site. -Now that you have a vague idea on what Varnish Cache is, let see if we +Now that you have a vague idea on what Varnish Cache is, let's see if we can get it up and running. .. XXX:The above three paragraphs are repetitive this is already handled in previous chapters. The only new information is Governing Board which could be moved to the introduction and the paragraphs scrapped. benc From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] e73be76 Typo Message-ID: commit e73be7600c4c579a64cab32c7ce1dc48c98a1112 Author: Federico G. Schwindt Date: Tue Jan 6 14:21:41 2015 +0000 Typo diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 64e63a3..1864a83 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -39,7 +39,7 @@ * 'g' - Gauge, goes up and down * 'i' - Integer (deprecated, use 'g') * v - Verbosity: Counter verbosity level (see vsc_levels.h) - * e - Explantion: Short explanation of field (for screen use) + * e - Explanation: Short explanation of field (for screen use) * d - Description: Long explanation of field (for doc use) * * Please describe Gauge variables as "Number of..." to indicate that From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 2de6a95 varnishtest: fail inequality comparisons if either side is undef'ed Message-ID: commit 2de6a9578c325e78fe56d4dbd7970090a06a46d8 Author: Nils Goroll Date: Wed Jan 7 12:34:58 2015 +0100 varnishtest: fail inequality comparisons if either side is undef'ed e.g. >= 0.1 should fail for being an invalid comparison Conflicts: bin/varnishtest/tests/v00013.vtc diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index c428add..bf5c89e 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -37,5 +37,9 @@ client c1 { rxresp expect resp.status == 200 expect resp.http.foo == 2 - expect resp.http.bar >= 0.100 + + txreq -url /pass + rxresp + expect resp.status == 200 + expect resp.http.foo == 0 } -run diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 21fceed..8283c68 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -224,18 +224,16 @@ cmd_var_resolve(struct http *hp, char *spec) } else return (spec); hdr = http_find_header(hh, hdr); - if (hdr != NULL) - return (hdr); - return (""); + return (hdr); } static void cmd_http_expect(CMD_ARGS) { struct http *hp; - const char *lhs; + const char *lhs, *clhs; char *cmp; - const char *rhs; + const char *rhs, *crhs; vre_t *vre; const char *error; int erroroffset; @@ -252,14 +250,27 @@ cmd_http_expect(CMD_ARGS) AN(av[2]); AZ(av[3]); lhs = cmd_var_resolve(hp, av[0]); - if (lhs == NULL) - lhs = ""; cmp = av[1]; rhs = cmd_var_resolve(hp, av[2]); - if (rhs == NULL) - rhs = ""; - if (!strcmp(cmp, "==")) { - retval = strcmp(lhs, rhs) == 0; + + clhs = lhs ? lhs : ""; + crhs = rhs ? rhs : ""; + + if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { + vre = VRE_compile(crhs, 0, &error, &erroroffset); + if (vre == NULL) + vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", + error, erroroffset, crhs); + i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); + retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); + VRE_free(&vre); + } else if (!strcmp(cmp, "==")) { + retval = strcmp(clhs, crhs) == 0; + } else if (!strcmp(cmp, "!=")) { + retval = strcmp(clhs, crhs) != 0; + } else if (lhs == NULL || rhs == NULL) { + // fail inequality comparisons if either side is undef'ed + retval = 0; } else if (!strcmp(cmp, "<")) { retval = strcmp(lhs, rhs) < 0; } else if (!strcmp(cmp, "<=")) { @@ -268,24 +279,15 @@ cmd_http_expect(CMD_ARGS) retval = strcmp(lhs, rhs) >= 0; } else if (!strcmp(cmp, ">")) { retval = strcmp(lhs, rhs) > 0; - } else if (!strcmp(cmp, "!=")) { - retval = strcmp(lhs, rhs) != 0; - } else if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { - vre = VRE_compile(rhs, 0, &error, &erroroffset); - if (vre == NULL) - vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", - error, erroroffset, rhs); - i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); - retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); - VRE_free(&vre); } + if (retval == -1) vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) test not implemented", - av[0], lhs, av[1], av[2], rhs); + av[0], clhs, av[1], av[2], crhs); else vtc_log(hp->vl, retval ? 4 : 0, "EXPECT %s (%s) %s \"%s\" %s", - av[0], lhs, cmp, rhs, retval ? "match" : "failed"); + av[0], clhs, cmp, crhs, retval ? "match" : "failed"); } /********************************************************************** From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 30e2053 Update schema definition Message-ID: commit 30e20536b903972c92f3bf5e571c0de64957f5f2 Author: Federico G. Schwindt Date: Wed Jan 7 09:14:41 2015 +0000 Update schema definition diff --git a/bin/varnishstat/varnishstat.xsd b/bin/varnishstat/varnishstat.xsd index e9c5f3c..f5f14aa 100644 --- a/bin/varnishstat/varnishstat.xsd +++ b/bin/varnishstat/varnishstat.xsd @@ -6,8 +6,13 @@ + + + From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 44d9e96 Indent Message-ID: commit 44d9e966c892fc27d10d616bb61fc0e4dc2660b4 Author: Federico G. Schwindt Date: Wed Jan 7 09:17:37 2015 +0000 Indent diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index f5153b4..7f00317 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -104,7 +104,10 @@ do_json_cb(void *priv, const struct VSC_point * const pt) val = *(const volatile uint64_t*)pt->ptr; sec = pt->section; - if (*jp) *jp = 0; else printf(",\n"); + if (*jp) + *jp = 0; + else + printf(",\n"); printf("\t\""); /* build the JSON key name. */ @@ -113,19 +116,17 @@ do_json_cb(void *priv, const struct VSC_point * const pt) if (sec->fantom->ident[0]) printf("%s.", sec->fantom->ident); printf("%s\": {", pt->desc->name); - - if (strcmp(sec->fantom->type, "")) printf("\"type\": \"%s\", ", - sec->fantom->type); - if (strcmp(sec->fantom->ident, "")) printf("\"ident\": \"%s\", ", - sec->fantom->ident); - + if (strcmp(sec->fantom->type, "")) + printf("\"type\": \"%s\", ", sec->fantom->type); + if (strcmp(sec->fantom->ident, "")) + printf("\"ident\": \"%s\", ", sec->fantom->ident); printf("\"value\": %ju, ", (uintmax_t)val); - printf("\"flag\": \"%c\", ", pt->desc->flag); printf("\"description\": \"%s\"", pt->desc->sdesc); printf("}"); - if (*jp) printf("\n"); + if (*jp) + printf("\n"); return (0); } @@ -325,12 +326,12 @@ main(int argc, char * const *argv) do_once(vd, VSC_Main(vd, NULL)); else if (f_list) list_fields(vd); - else { + else assert(0); - } - if (!do_repeat) break; + if (!do_repeat) + break; - // end of output block marker. + /* end of output block marker. */ printf("\n"); (void)usleep(delay * 1e6); From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 4c03990 Sort options and remove undocumented alias Message-ID: commit 4c039901c44777fb547b68c770f89cddab115c69 Author: Federico G. Schwindt Date: Wed Jan 7 09:31:07 2015 +0000 Sort options and remove undocumented alias diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 00c4dac..bea41e2 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -867,6 +867,10 @@ handle_keypress(int ch) if (page_start + l_points < n_ptarray - 1) page_start += l_points; break; + case 'd': + hide_unseen = 1 - hide_unseen; + rebuild = 1; + break; case 'g': current = 0; page_start = 0; @@ -875,10 +879,6 @@ handle_keypress(int ch) current = n_ptarray - 1; page_start = current - l_points + 1; break; - case 'd': - hide_unseen = 1 - hide_unseen; - rebuild = 1; - break; case 'v': verbosity++; if (VSC_LevelDesc(verbosity) == NULL) @@ -886,7 +886,6 @@ handle_keypress(int ch) rebuild = 1; break; case 'q': - case 'Q': keep_running = 0; return; case '\003': /* Ctrl-C */ From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 3af02e6 Sort options, fix spelling and update formats Message-ID: commit 3af02e6707cd6ff31c71ba7a54357d4b557845c1 Author: Federico G. Schwindt Date: Thu Jan 8 03:39:05 2015 +0000 Sort options, fix spelling and update formats diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 8940d80..b8b5ef8 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -65,7 +65,7 @@ CURSES MODE =========== When neither -1, -j or -x options are given, the application starts up -in curses mode. This shows a continously updated view of the counter +in curses mode. This shows a continuously updated view of the counter values, along with their description. The top area shows process uptime information. @@ -119,17 +119,17 @@ The following keys control the interactive display: or Navigate the counter list one page down. + + Toggle between showing and hiding unseen counters. Unseen + counters are those that has been zero for the entire runtime + of varnishstat. Defaults to hide unseen counters. + Go to the top of the counter list. Go to the bottom of the counter list. - - Toggle between showing and hiding unseen counters. Unseen - counters are those that has been zero for the entire runtime - of varnishstat. Defaults to hide unseen counters. - Cycle through the verbosity levels. Defaults to only showing informational counters. @@ -145,11 +145,17 @@ XML Output When using the -x option, the output is:: - - FIELD NAME - FIELD VALUE - FIELD DESCRIPTION - + + + FIELD TYPE + FIELD IDENT + FIELD NAME + FIELD VALUE + FIELD FORMAT + FIELD DESCRIPTION + + [..] + JSON OUTPUT =========== @@ -158,24 +164,15 @@ With -j the output format is:: { "timestamp": "YYYY-MM-DDTHH:mm:SS", - "client_conn": { - "value": 0, "flag": "a", - "description": "Client connections accepted" - }, - "client_drop": { - "value": 0, "flag": "a", - "description": "Connection dropped, no sess/wrk" - }, - "LCK.backend.creat": { - "type": "LCK", "ident": "backend", "value": 1, - "flag": "a", "description": "Created locks" - }, + "FIELD NAME": {"type": "FIELD TYPE", "ident": "FIELD IDENT", "value": FIELD VALUE, "flag": "FIELD FORMAT", "description": "FIELD DESCRIPTION"}, [..] } -Timestamp is the time when the report was generated by varnishstat. +Type and ident are optional. Timestamp is the time when the report was +generated by varnishstat. -Repeated output with -1, -x or -j will have a single empty line (\\n) between each block of output. +Repeated output with -1, -x or -j will have a single empty line (\\n) +between each block of output. SEE ALSO From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 810e82b Update varnish-counters(7) Message-ID: commit 810e82b1923382721ad67484f798cd2044517665 Author: Federico G. Schwindt Date: Sat Jan 10 00:46:00 2015 +0000 Update varnish-counters(7) This manpage is auto-generated. Remove author, date and whatnot, it doesn't make sense here. diff --git a/man/vsc2rst.c b/man/vsc2rst.c index 96500bf..f25d2e1 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -55,11 +55,6 @@ int main(int argc, char **argv) P("---------------------------------"); P("Varnish counter field definitions"); P("---------------------------------"); - - P(":Author: Tollef Fog Heen"); - P(":Date: 2011-09-20"); - P(":Version: 1.0"); - P(":Manual section: 7"); P(""); P("COUNTER LEVELS"); From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 5209364 Remove the unused per random director struct bitmap Message-ID: commit 52093641e20c4f1ce91fb00eefd231f54286798c Author: Martin Blix Grydeland Date: Mon Jan 12 15:06:36 2015 +0100 Remove the unused per random director struct bitmap diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 8ae36a7..c32167e 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -46,7 +46,6 @@ struct vmod_directors_random { #define VMOD_DIRECTORS_RANDOM_MAGIC 0x4732d092 struct vdir *vd; unsigned n_backend; - struct vbitmap *vbm; }; static unsigned __match_proto__(vdi_healthy) @@ -85,8 +84,6 @@ vmod_random__init(const struct vrt_ctx *ctx, struct vmod_directors_random **rrp, AZ(*rrp); ALLOC_OBJ(rr, VMOD_DIRECTORS_RANDOM_MAGIC); AN(rr); - rr->vbm = vbit_init(8); - AN(rr->vbm); *rrp = rr; vdir_new(&rr->vd, vcl_name, vmod_rr_healthy, vmod_rr_getfd, rr); } @@ -100,7 +97,6 @@ vmod_random__fini(struct vmod_directors_random **rrp) *rrp = NULL; CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); vdir_delete(&rr->vd); - vbit_destroy(rr->vbm); FREE_OBJ(rr); } From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] b8a4bb6 Fix vcl.show -v handling with no VCL Message-ID: commit b8a4bb64d8806e18e4aea01e7069c08448159ecc Author: Federico G. Schwindt Date: Mon Jan 12 04:48:12 2015 +0000 Fix vcl.show -v handling with no VCL While here display the right VCL name if -v is used and the VCL is not found. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 2f7c1b9..7a6ac7d 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -381,18 +381,23 @@ ccf_config_show(struct cli *cli, const char * const *av, void *priv) int i; (void)priv; - if (!strcmp(av[2], "-v")) { - verbose = 1; - vcl = vcl_find(av[3]); - } else if (av[3] != NULL) { + if (!strcmp(av[2], "-v") && av[3] == NULL) { + VCLI_Out(cli, "Too few parameters"); + VCLI_SetResult(cli, CLIS_TOOFEW); + return; + } else if (strcmp(av[2], "-v") && av[3] != NULL) { VCLI_Out(cli, "Unknown options '%s'", av[2]); VCLI_SetResult(cli, CLIS_PARAM); return; + } else if (av[3] != NULL) { + verbose = 1; + vcl = vcl_find(av[3]); } else vcl = vcl_find(av[2]); if (vcl == NULL) { - VCLI_Out(cli, "No VCL named '%s'", av[2]); + VCLI_Out(cli, "No VCL named '%s'", + av[3] == NULL ? av[2] : av[3]); VCLI_SetResult(cli, CLIS_PARAM); return; } From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 5be6078 Normalise help output Message-ID: commit 5be60786e1941abd6289b68326bdffc751a5c382 Author: Federico G. Schwindt Date: Mon Jan 12 10:47:18 2015 +0000 Normalise help output Remove extra newlines, add tabs and ending punctuation. Conflicts: bin/varnishd/storage/storage_persistent.c diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 7afcef6..58e884e 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -460,9 +460,8 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv) static struct cli_proto vca_cmds[] = { { CLI_SERVER_START, "i", ccf_start }, - { "debug.listen_address", - "debug.listen_address", - "Report the actual listen address\n", 0, 0, + { "debug.listen_address", "debug.listen_address", + "\tReport the actual listen address.", 0, 0, "d", ccf_listen_address, NULL }, { NULL } }; diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 4773785..479872b 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -430,7 +430,7 @@ vbp_health(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.health", "debug.health", - "\tDump backend health stuff\n", + "\tDump backend health information.", 0, 0, "d", vbp_health }, { NULL } }; diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index 99b781c..0b67551 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -223,10 +223,10 @@ static struct cli_proto master_cmds[] = { { CLI_PING, "i", VCLS_func_ping }, { CLI_HELP, "i", VCLS_func_help }, { "debug.sizeof", "debug.sizeof", - "\tDump sizeof various data structures\n", + "\tDump sizeof various data structures.", 0, 0, "d", cli_debug_sizeof }, { "debug.panic.worker", "debug.panic.worker", - "\tPanic the worker process.\n", + "\tPanic the worker process.", 0, 0, "d", ccf_panic }, { NULL } }; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 429052d..3bec04e 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -286,7 +286,7 @@ debug_fragfetch(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.fragfetch", "debug.fragfetch", - "\tEnable fetch fragmentation\n", 1, 1, "d", debug_fragfetch }, + "\tEnable fetch fragmentation.", 1, 1, "d", debug_fragfetch }, { NULL } }; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 31d167d..bfa2619 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -170,9 +170,9 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv) static struct cli_proto debug_cmds[] = { { "debug.xid", "debug.xid", - "\tExamine or set XID\n", 0, 1, "d", cli_debug_xid }, + "\tExamine or set XID.", 0, 1, "d", cli_debug_xid }, { "debug.srandom", "debug.srandom", - "\tSeed the random(3) function\n", 0, 1, "d", + "\tSeed the random(3) function.", 0, 1, "d", cli_debug_srandom }, { NULL } }; diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index a2dc7c0..232bdd4 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -179,7 +179,7 @@ ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) } static struct cli_proto vcl_cmds[] = { - { "debug.vmod", "debug.vmod", "show loaded vmods", 0, 0, + { "debug.vmod", "debug.vmod", "\tShow loaded vmods.", 0, 0, "d", ccf_debug_vmod }, { NULL } }; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 4c7e4b5..ff148ba 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -343,7 +343,7 @@ hcb_dump(struct cli *cli, const char * const *av, void *priv) } static struct cli_proto hcb_cmds[] = { - { "hcb.dump", "hcb.dump", "dump HCB tree\n", 0, 0, "d", hcb_dump }, + { "hcb.dump", "hcb.dump", "\tDump HCB tree.", 0, 0, "d", hcb_dump }, { NULL } }; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 21fecfb..8c16692 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -120,7 +120,7 @@ mcf_panic(struct cli *cli, const char * const *av, void *priv) static struct cli_proto cli_debug[] = { { "debug.panic.master", "debug.panic.master", - "\tPanic the master process.\n", + "\tPanic the master process.", 0, 0, "d", mcf_panic, NULL}, { NULL } }; diff --git a/bin/varnishd/storage/stevedore_mgt.c b/bin/varnishd/storage/stevedore_mgt.c index 7a38171..109290f 100644 --- a/bin/varnishd/storage/stevedore_mgt.c +++ b/bin/varnishd/storage/stevedore_mgt.c @@ -70,7 +70,7 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ struct cli_proto cli_stv[] = { - { "storage.list", "storage.list", "List storage devices\n", + { "storage.list", "storage.list", "\tList storage devices.", 0, 0, "", stv_cli_list }, { NULL} }; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 6633799..1f9737f 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -670,14 +670,13 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv) } static struct cli_proto debug_cmds[] = { - { "debug.persistent", "debug.persistent", - "Persistent debugging magic:\n" - "\tdebug.persistent [stevedore [cmd]]\n" + { "debug.persistent", "debug.persistent", + "Persistent debugging magic:\n" + "\tdebug.persistent [ []]\n" "With no cmd arg, a summary of the silo is returned.\n" "Possible commands:\n" "\tsync\tClose current segment, open a new one\n" - "\tdump\tinclude objcores in silo summary\n" - "", + "\tdump\tinclude objcores in silo summary", 0, 2, "d", debug_persistent }, { NULL } }; diff --git a/include/vcli.h b/include/vcli.h index 4a18c82..e6762f0 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -122,7 +122,7 @@ #define CLI_SERVER_STOP \ "stop", \ "stop", \ - "\tStop the Varnish cache process", \ + "\tStop the Varnish cache process.", \ 0, 0 #define CLI_SERVER_START \ @@ -133,20 +133,20 @@ #define CLI_PING \ "ping", \ - "ping [timestamp]", \ - "\tKeep connection alive", \ + "ping []", \ + "\tKeep connection alive.", \ 0, 1 #define CLI_HELP \ "help", \ - "help [command]", \ - "\tShow command/protocol help", \ + "help []", \ + "\tShow command/protocol help.", \ 0, 1 #define CLI_QUIT \ "quit", \ "quit", \ - "\tClose connection", \ + "\tClose connection.", \ 0, 0 #define CLI_SERVER_STATUS \ @@ -163,7 +163,7 @@ #define CLI_AUTH \ "auth", \ - "auth response", \ + "auth ", \ "\tAuthenticate.", \ 1, 1 From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 2f5d19f Remove leaked snippet. Message-ID: commit 2f5d19f68f5df474edd4455ac9030305df568921 Author: Lasse Karstensen Date: Tue Jan 13 15:21:47 2015 +0100 Remove leaked snippet. diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index bf5c89e..5a87dcf 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -38,8 +38,4 @@ client c1 { expect resp.status == 200 expect resp.http.foo == 2 - txreq -url /pass - rxresp - expect resp.status == 200 - expect resp.http.foo == 0 } -run From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 3e8874e Collapse multiple X-Forwarded-For headers Message-ID: commit 3e8874ed945de580a92819b01c457b2734c6888b Author: Federico G. Schwindt Date: Wed Jan 14 04:32:50 2015 +0000 Collapse multiple X-Forwarded-For headers Fixes #1650 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index cc5ede9..88eaa53 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -724,6 +724,7 @@ cnt_recv(struct worker *wrk, struct req *req) * This really should be done earlier, but we want to capture * it in the VSL log. */ + http_CollectHdr(req->http, H_X_Forwarded_For); if (http_GetHdr(req->http, H_X_Forwarded_For, &xff)) { http_Unset(req->http, H_X_Forwarded_For); http_PrintfHeader(req->http, "X-Forwarded-For: %s, %s", diff --git a/bin/varnishtest/tests/r01650.vtc b/bin/varnishtest/tests/r01650.vtc new file mode 100644 index 0000000..e21ceba --- /dev/null +++ b/bin/varnishtest/tests/r01650.vtc @@ -0,0 +1,16 @@ +varnishtest "xff handling discards multiple headers" + +server s1 { + rxreq + expect req.http.X-Forwarded-For == "1.2.3.4, 5.6.7.8, 127.0.0.1" + txresp +} -start + +varnish v1 -vcl+backend { +} -start + +client c1 { + txreq -hdr "X-Forwarded-For: 1.2.3.4" -hdr "X-Forwarded-For: 5.6.7.8" + rxresp +} -run + From lkarsten at varnish-software.com Thu Jan 15 15:35:43 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:43 +0100 Subject: [4.0] 62c20c7 define AS_COPY_VAR in varnish.m4 if not already defined (autoconf < 2.63b) found at: http://www.open-mpi.org/community/lists/devel/2010/09/8472.php Message-ID: commit 62c20c7c90afe2f3db5a611255b575e0e784b7c8 Author: Geoff Simmons Date: Mon Dec 15 14:34:18 2014 +0100 define AS_COPY_VAR in varnish.m4 if not already defined (autoconf < 2.63b) found at: http://www.open-mpi.org/community/lists/devel/2010/09/8472.php diff --git a/varnish.m4 b/varnish.m4 index 16e27c5..d603e2b 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -28,6 +28,11 @@ # SUCH DAMAGE. # +# For compatibility with autoconf < 2.63b +m4_ifndef([AS_VAR_COPY], + [m4_define([AS_VAR_COPY], + [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])]) + # VARNISH_VMOD_INCLUDE_DIR([]) # ---------------------------- From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 12a6d79 Bump serial Message-ID: commit 12a6d79cf9f83a4e362df777d52453063a0bee67 Author: Federico G. Schwindt Date: Wed Jan 7 23:23:24 2015 +0000 Bump serial Forgotten when compatibility for autoconf < 2.63b was added. Conflicts: varnish.m4 diff --git a/varnish.m4 b/varnish.m4 index d603e2b..f4e9e9c 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -1,7 +1,7 @@ # varnish.m4 - Macros to locate Varnish header files. -*- Autoconf -*- -# serial 1 (varnish-4.0) +# serial 3 (varnish-4.0) -# Copyright (c) 2013 Varnish Software AS +# Copyright (c) 2013-2015 Varnish Software AS # All rights reserved. # # Author: Tollef Fog Heen From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 1ac441b Add std.time() Message-ID: commit 1ac441bc03670b4b4fbe76d5638dfb0753921e83 Author: Federico G. Schwindt Date: Tue Dec 16 11:05:56 2014 +0000 Add std.time() Converts an date in various formats to a VCL_TIME. diff --git a/bin/varnishtest/tests/m00020.vtc b/bin/varnishtest/tests/m00020.vtc new file mode 100644 index 0000000..3611cc4 --- /dev/null +++ b/bin/varnishtest/tests/m00020.vtc @@ -0,0 +1,40 @@ +varnishtest "Test std.time" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import ${vmod_std}; + + sub vcl_deliver { + if (std.time(req.http.x-date, now) < now - 1y) { + set resp.http.x-past = 1; + } + if (std.time(req.http.x-date, now) > now + 1y) { + set resp.http.x-future = 1; + } + } +} -start + +client c1 { + txreq -hdr "X-Date: Mon, 20 Dec 2010 00:00:00 GMT" + rxresp + expect resp.http.x-past == 1 + txreq -hdr "X-Date: Monday, 20-Dec-30 00:00:00 GMT" + rxresp + expect resp.http.x-future == 1 + txreq -hdr "X-Date: Mon Dec 20 00:00:00 2010" + rxresp + expect resp.http.x-past == 1 + txreq -hdr "X-Date: 2030-12-20T00:00:00" + rxresp + expect resp.http.x-future == 1 + txreq -hdr "X-Date: 1292803200.00" + rxresp + expect resp.http.x-past == 1 + txreq -hdr "X-Date: 1923955200" + rxresp + expect resp.http.x-future == 1 +} -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index a88382f..1bc92d6 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -227,6 +227,25 @@ Example | ... | } +$Function TIME time(STRING s, TIME fallback) + +Description + Converts the string *s* to a time. If conversion fails, + *fallback* will be returned. + + Supported formats: + + | "Sun, 06 Nov 1994 08:49:37 GMT" + | "Sunday, 06-Nov-94 08:49:37 GMT" + | "Sun Nov 6 08:49:37 1994" + | "1994-11-06T08:49:37" + | "784111777.00" + | "784111777" +Example + | if (std.time(resp.http.last-modified, now) < now - 1w) { + | ... + | } + SEE ALSO ======== diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index cdcd3cb..0771687 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -41,6 +41,7 @@ #include "vrt.h" #include "vsa.h" +#include "vtim.h" #include "vcc_if.h" VCL_DURATION __match_proto__(td_std_duration) @@ -219,3 +220,18 @@ vmod_time2real(const struct vrt_ctx *ctx, VCL_TIME t) return (t); } + +VCL_TIME __match_proto__(td_std_time) +vmod_time(VRT_CTX, VCL_STRING p, VCL_TIME d) +{ + double r; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + if (p == NULL) + return (d); + r = VTIM_parse(p); + if (r) + return (r); + return (vmod_real(ctx, p, d)); +} From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 13d7ff6 Add T to ISO8601 format. Message-ID: commit 13d7ff6f7922647052f5689eaec20c23a23e2c26 Author: Lasse Karstensen Date: Wed Jan 14 12:30:48 2015 +0100 Add T to ISO8601 format. Since we have been accepting ISO8601 without timezone up until now, continue doing so until 4.0 EOL. Based on 60c98eb by Federico G. Schwindt. diff --git a/bin/varnishtest/tests/m00020.vtc b/bin/varnishtest/tests/m00020.vtc index 3611cc4..c31eb24 100644 --- a/bin/varnishtest/tests/m00020.vtc +++ b/bin/varnishtest/tests/m00020.vtc @@ -28,6 +28,9 @@ client c1 { txreq -hdr "X-Date: Mon Dec 20 00:00:00 2010" rxresp expect resp.http.x-past == 1 + txreq -hdr "X-Date: 2030-12-20 00:00:00" + rxresp + expect resp.http.x-future == 1 txreq -hdr "X-Date: 2030-12-20T00:00:00" rxresp expect resp.http.x-future == 1 diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c index 50033c2..3a3ad7e 100644 --- a/lib/libvarnish/vtim.c +++ b/lib/libvarnish/vtim.c @@ -115,7 +115,8 @@ static const char *fmts[] = { "%a, %d %b %Y %T GMT", /* RFC 822 & RFC 1123 */ "%A, %d-%b-%y %T GMT", /* RFC 850 */ "%a %b %d %T %Y", /* ANSI-C asctime() */ - "%F %T", /* ISO 8601 */ + "%F %T", /* ISO 8601 (incorrect, only in 4.0) */ + "%FT%T", /* ISO 8601 */ NULL }; diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 0771687..181f9f9 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -222,7 +222,7 @@ vmod_time2real(const struct vrt_ctx *ctx, VCL_TIME t) } VCL_TIME __match_proto__(td_std_time) -vmod_time(VRT_CTX, VCL_STRING p, VCL_TIME d) +vmod_time(const struct vrt_ctx *ctx, VCL_STRING p, VCL_TIME d) { double r; From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] a4d271d Add Range error handling with HTTP 416. Message-ID: commit a4d271deb62d7af3f08813446ac1e4a585f729b2 Author: Lasse Karstensen Date: Thu Jan 15 10:40:11 2015 +0100 Add Range error handling with HTTP 416. A set of robustness fixes for Range handling backported from master. Patch by Federico G. Schwindt. diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 623b07b..dcb290f 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -101,14 +101,12 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) else len = req->obj->len; - if (strncmp(r, "bytes=", 6)) + if (strncasecmp(r, "bytes=", 6)) return; r += 6; /* The low end of range */ has_low = low = 0; - if (!vct_isdigit(*r) && *r != '-') - return; while (vct_isdigit(*r)) { has_low = 1; low *= 10; @@ -116,9 +114,6 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) r++; } - if (low >= len) - return; - if (*r != '-') return; r++; @@ -131,22 +126,31 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) high += *r - '0'; r++; } + if (high < low) + return; if (!has_low) { low = len - high; if (low < 0) low = 0; high = len - 1; - } - } else + } else if (high >= len) + high = len - 1; + } else if (has_low) high = len - 1; - if (*r != '\0') + else return; - if (high >= len) - high = len - 1; + if (*r != '\0') + return; - if (low > high) + if (low >= len) { + http_PrintfHeader(req->resp, "Content-Range: bytes */%jd", + (intmax_t)len); + http_Unset(req->resp, H_Content_Length); + http_PutResponse(req->resp, "HTTP/1.1", 416, NULL); + req->wantbody = 0; return; + } http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd", (intmax_t)low, (intmax_t)high, (intmax_t)len); diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc index 23910de..9eeee15 100644 --- a/bin/varnishtest/tests/c00034.vtc +++ b/bin/varnishtest/tests/c00034.vtc @@ -5,13 +5,11 @@ server s1 { txresp -bodylen 100 } -start -varnish v1 -vcl+backend { - +varnish v1 -arg "-p http_range_support=off" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; } } -start -varnish v1 -cliok "param.set http_range_support off" client c1 { txreq -hdr "Range: bytes=0-9" @@ -45,61 +43,71 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 100 + txreq -hdr "Range: bytes=-" + rxresp + expect resp.status == 200 + expect resp.bodylen == 100 + + txreq -hdr "Range: bytes=5-2" + rxresp + expect resp.status == 200 + expect resp.bodylen == 100 } -run -varnish v1 -expect s_resp_bodybytes == 500 +varnish v1 -expect s_resp_bodybytes == 700 client c1 { - - txreq -hdr "Range: bytes=0-9" + txreq -hdr "Range: bytes=-0" rxresp - expect resp.status == 206 - expect resp.bodylen == 10 + expect resp.status == 416 + expect resp.bodylen == 0 + expect resp.http.content-range == "bytes */100" - txreq -hdr "Range: bytes=10-19" + txreq -hdr "Range: bytes=100-" rxresp - expect resp.status == 206 - expect resp.bodylen == 10 + expect resp.status == 416 + expect resp.bodylen == 0 + expect resp.http.content-range == "bytes */100" +} -run - txreq -hdr "Range: bytes=90-" - rxresp - expect resp.status == 206 - expect resp.bodylen == 10 +varnish v1 -expect s_resp_bodybytes == 700 - txreq -hdr "Range: bytes=-9" +client c1 { + txreq -hdr "Range: bytes=0-49" rxresp expect resp.status == 206 - expect resp.bodylen == 9 + expect resp.bodylen == 50 + expect resp.http.content-range == "bytes 0-49/100" - txreq -hdr "Range: bytes=-" + txreq -hdr "Range: bytes=50-99" rxresp expect resp.status == 206 - expect resp.bodylen == 100 - - txreq -hdr "Range: bytes=102-102" - rxresp - expect resp.status == 200 - expect resp.bodylen == 100 + expect resp.bodylen == 50 + expect resp.http.content-range == "bytes 50-99/100" - txreq -hdr "Range: bytes=99-" + txreq -hdr "Range: bytes=-50" rxresp expect resp.status == 206 - expect resp.bodylen == 1 + expect resp.bodylen == 50 + expect resp.http.content-range == "bytes 50-99/100" - txreq -hdr "Range: bytes=99-70" + txreq -hdr "Range: bytes=50-" rxresp - expect resp.status == 200 - expect resp.bodylen == 100 + expect resp.status == 206 + expect resp.bodylen == 50 + expect resp.http.content-range == "bytes 50-99/100" - txreq -hdr "Range: bytes=-" + txreq -hdr "Range: bytes=0-0" rxresp expect resp.status == 206 - expect resp.bodylen == 100 + expect resp.bodylen == 1 + expect resp.http.content-range == "bytes 0-0/100" - txreq -hdr "Range: bytes=-101" + txreq -hdr "Range: bytes=-2000" rxresp expect resp.status == 206 expect resp.bodylen == 100 + expect resp.http.content-range == "bytes 0-99/100" } -run -varnish v1 -expect s_resp_bodybytes == 1040 +varnish v1 -expect s_resp_bodybytes == 1001 From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] fc3d123 Nils patch for retrying partial fetches, with minor changes by me. Message-ID: commit fc3d123ce7ed2a691c4ea2a461830f749f57f85c Author: Poul-Henning Kamp Date: Tue Dec 16 21:35:15 2014 +0000 Nils patch for retrying partial fetches, with minor changes by me. Fixes #1638 Fixes #1641 Ported to 4.0 by Martin Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9277e5c..4743133 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -223,6 +223,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) /*-------------------------------------------------------------------- * Start a new VSL transaction and try again + * Prepare the busyobj and fetch processors */ static enum fetch_step @@ -233,8 +234,27 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + assert(bo->state == BOS_REQ_DONE); + VSLb_ts_busyobj(bo, "Retry", W_TIM_real(wrk)); + /* VDI_CloseFd must have been called before */ + AZ(bo->vbc); + bo->should_close = 0; + + /* reset other bo attributes - See VBO_GetBusyObj */ + bo->storage_hint = NULL; + bo->do_esi = 0; + bo->do_gzip = 0; + bo->do_gunzip = 0; + bo->do_stream = 1; + bo->uncacheable = 0; + bo->abandon = 0; + + /* reset fetch processors */ + bo->failed = 0; + bo->vfp_nxt = 0; + // XXX: BereqEnd + BereqAcct ? wid = VXID_Get(&wrk->vxid_pool); VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); @@ -380,6 +400,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) bo->retries++; if (bo->retries <= cache_param->max_retries) return (F_STP_RETRY); + VSLb(bo->vsl, SLT_VCL_Error, "Too many retries, delivering 503"); return (F_STP_ERROR); @@ -538,6 +559,11 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VFP_Fetch_Body(bo, est); } + if (bo->failed) { + AN(bo->vbc); + VDI_CloseFd(&bo->vbc, &bo->acct); + } + if (bo->failed && !bo->do_stream) { assert(bo->state < BOS_STREAM); if (bo->fetch_obj != NULL) { @@ -690,6 +716,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); + AZ(bo->vbc); /* VDI_CloseFd must have been called before */ AN(bo->fetch_objcore->flags & OC_F_BUSY); AZ(bo->synth_body); @@ -716,8 +743,10 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_RETRY) { VSB_delete(bo->synth_body); bo->synth_body = NULL; + if (bo->retries++ < cache_param->max_retries) return (F_STP_RETRY); + return (F_STP_FAIL); } diff --git a/bin/varnishtest/tests/r01638.vtc b/bin/varnishtest/tests/r01638.vtc new file mode 100644 index 0000000..2ddebbb --- /dev/null +++ b/bin/varnishtest/tests/r01638.vtc @@ -0,0 +1,49 @@ +varnishtest "Test retry of straight insufficient bytes pass-fetch : do_stream = false" + +server s1 { + rxreq + txresp -hdr "Content-Length: 10000" -nolen -bodylen 5000 +} + +server s2 { + rxreq + txresp -bodylen 5 +} + +server s1 -start +server s2 -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_fetch { + set bereq.between_bytes_timeout = 10s; + if (bereq.retries == 0) { + set bereq.backend = s1; + } else { + set bereq.backend = s2; + } + } + sub vcl_backend_response { + set beresp.do_stream = false; + } + sub vcl_backend_error { + if (bereq.retries == 0) { + return (retry); + } else { + return (deliver); + } + } +} -start + +client c1 { + timeout 10 + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.bodylen == 5 +} -run + +server s1 -wait +server s2 -wait diff --git a/bin/varnishtest/tests/r01641.vtc b/bin/varnishtest/tests/r01641.vtc new file mode 100644 index 0000000..1dddc85 --- /dev/null +++ b/bin/varnishtest/tests/r01641.vtc @@ -0,0 +1,49 @@ +varnishtest "Test retry of straight insufficient bytes pass-fetch : do_esi = true" + +server s1 { + rxreq + txresp -hdr "Content-Length: 10000" -nolen -bodylen 5000 +} + +server s2 { + rxreq + txresp -bodylen 5 +} + +server s1 -start +server s2 -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_fetch { + set bereq.between_bytes_timeout = 10s; + if (bereq.retries == 0) { + set bereq.backend = s1; + } else { + set bereq.backend = s2; + } + } + sub vcl_backend_response { + set beresp.do_esi = true; + } + sub vcl_backend_error { + if (bereq.retries == 0) { + return (retry); + } else { + return (deliver); + } + } +} -start + +client c1 { + timeout 10 + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.bodylen == 5 +} -run + +server s1 -wait +server s2 -wait From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 97da7f3 Continuously update our total object size estimate when cond-fetching a still-being-streamed object. Message-ID: commit 97da7f346db387033fbda38c5a827af91ddb95cf Author: Poul-Henning Kamp Date: Tue Dec 16 09:55:19 2014 +0000 Continuously update our total object size estimate when cond-fetching a still-being-streamed object. Fixes: #1646 Keeping only the test case as the issue isn't in 4.0. Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishtest/tests/r01646.vtc b/bin/varnishtest/tests/r01646.vtc new file mode 100644 index 0000000..951350e --- /dev/null +++ b/bin/varnishtest/tests/r01646.vtc @@ -0,0 +1,54 @@ +varnishtest "cond/stream race ?" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: foo" + chunkedlen 32 + sema r1 sync 3 + chunkedlen 32 + sema r2 sync 2 + chunkedlen 32 + chunkedlen 0 +} -start + +server s2 { + rxreq + expect req.http.if-none-match == "foo" + txresp -status 304 +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + if (bereq.http.foo == "s2") { + set bereq.backend = s2; + } + } + sub vcl_backend_response { + set beresp.ttl = 1s; + set beresp.grace = 0s; + set beresp.keep = 30s; + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + txreq + rxresphdrs + sema r1 sync 3 + rxrespbody + expect resp.bodylen == 96 +} -start + +client c2 { + sema r1 sync 3 + delay 2 + txreq -hdr "foo: s2" + rxresphdrs + sema r2 sync 2 + rxrespbody + expect resp.bodylen == 96 +} -start + +client c1 -wait +client c2 -wait From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 2b931fe Handle template object failures during condfetch Message-ID: commit 2b931fed8ade30933485833a6a9fd0e3cd1d1db1 Author: Martin Blix Grydeland Date: Tue Dec 16 18:14:57 2014 +0100 Handle template object failures during condfetch Fixes: #1648 Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4743133..9478edc 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -658,6 +658,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) oi = ObjIterBegin(wrk, bo->ims_obj); do { ois = ObjIter(oi, &sp, &sl); + if (ois == OIS_ERROR) + VFP_Error(bo, "Template object failed"); while (sl > 0) { if (st == NULL) st = VFP_GetStorage(bo, bo->ims_obj->len - al); @@ -676,6 +678,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } } while (!bo->failed && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(&oi); + if (bo->ims_obj->objcore->flags & OC_F_FAILED) + VFP_Error(bo, "Template object failed"); if (bo->failed) return (F_STP_FAIL); diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc new file mode 100644 index 0000000..de0c364 --- /dev/null +++ b/bin/varnishtest/tests/r01648.vtc @@ -0,0 +1,75 @@ +varnishtest "#1648 - corrupt object in cache through IMS update" + +# This server sends a broken response body +server s1 { + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: \"foo\"" -hdr "Server: s1" + sema r1 sync 3 + delay 1 + chunked "abc" +} -start + +# This server validates the streaming response from s1 as it hasn't failed yet +server s2 { + rxreq + expect req.http.If-None-Match == "\"foo\"" + sema r1 sync 3 + txresp -status 304 -nolen -hdr "Server: s2" +} -start + +# This server sends the proper response body +server s3 { + rxreq + txresp -hdr "Server: s3" -body "abcdef" +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.http.client == "c1") { + set req.backend_hint = s1; + } else if (req.http.client == "c2") { + set req.backend_hint = s2; + } else if (req.http.client == "c3") { + set req.backend_hint = s3; + } + } + sub vcl_backend_response { + if (bereq.http.client == "c1") { + set beresp.ttl = 0.1s; + set beresp.grace = 0s; + set beresp.keep = 60s; + } + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +# This client gets a streaming failing result from s1 +client c1 { + txreq -hdr "Client: c1" + rxresphdrs + expect resp.status == 200 + expect resp.http.transfer-encoding == "chunked" +} -start + +delay 1 + +# This client gets a streaming failing result from s1 through +# IMS update by s2 +client c2 { + txreq -hdr "Client: c2" + sema r1 sync 3 + rxresphdrs + expect resp.status == 200 + expect resp.http.transfer-encoding == "chunked" +} -run + +delay 1 + +# This client should get a fresh fetch from s3 +client c3 { + txreq -hdr "Client: c3" + rxresp + expect resp.status == 200 + expect resp.body == "abcdef" +} -run From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] 08b7150 Prepare 4.0.3-beta1. Message-ID: commit 08b71502d034ec11796fa9bb0df9bdeadc8db67c Author: Lasse Karstensen Date: Thu Jan 15 16:24:22 2015 +0100 Prepare 4.0.3-beta1. diff --git a/doc/changes.rst b/doc/changes.rst index 8463a26..dc99893 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,35 +1,54 @@ ============================================== -Changes from 4.0.2 to 4.0.3-beta1 (2014-11-14) +Changes from 4.0.2 to 4.0.3-beta1 (2015-01-15) ============================================== - Changes since 4.0.2: +- Support older autoconf (< 2.63b) (el5) - A lot of minor documentation fixes. - bereq.uncacheable is now read-only. - obj.uncacheable is now readable in vcl_deliver. - [varnishadm] Prefer exact matches for backend.set_healthy. Bug 1349_. - Hard-coded -sfile default size is removed. -- Truncate duplicate Content- - [packaging] EL6 packages are once again built with -O2. +- [parameter] fetch_chunksize default is reduced to 16KB. (from 128KB) +- Added std.time() which converts strings to VCL_TIME. +- [packaging] packages now Provide strictABI (gitref) and ABI (VRT major/minor) +for VMOD use. Bugs fixed ---------- -* 1623_ - Fix varnishhist -d segfault. -* 1607_ - Don't leak reqs on failure to revive from waitinglist. -* 1610_ - Update forgotten varnishlog example to 4.0 syntax. +* 1378_ - Properly escape non-printable characters in varnishncsa. * 1596_ - Delay HSH_Complete() until the storage sanity functions has finished. * 1506_ - Keep Content-Length from backend if we can. * 1602_ - Fix a cornercase related to empty pass objects. - -.. _1623: https://www.varnish-cache.org/trac/ticket/1623 -.. _1607: https://www.varnish-cache.org/trac/ticket/1607 -.. _1610: https://www.varnish-cache.org/trac/ticket/1610 +* 1607_ - Don't leak reqs on failure to revive from waitinglist. +* 1610_ - Update forgotten varnishlog example to 4.0 syntax. +* 1612_ - Fix a cornercase related to empty pass objects. +* 1623_ - Fix varnishhist -d segfault. +* 1636_ - Outdated paragraph in Vary: documentation +* 1638_ - Fix panic when retrying a failed backend fetch. +* 1639_ - Restore the default SIGSEGV handler during pan_ic +* 1647_ - Relax an assertion for the IMS update candidate object. +* 1648_ - Avoid partial IMS updates to replace old object. +* 1650_ - Collapse multiple X-Forwarded-For headers + +.. _1378: https://www.varnish-cache.org/trac/ticket/1378 .. _1596: https://www.varnish-cache.org/trac/ticket/1596 .. _1506: https://www.varnish-cache.org/trac/ticket/1506 .. _1602: https://www.varnish-cache.org/trac/ticket/1602 -.. _1349: https://www.varnish-cache.org/trac/ticket/1349 +.. _1607: https://www.varnish-cache.org/trac/ticket/1607 +.. _1610: https://www.varnish-cache.org/trac/ticket/1610 +.. _1612: https://www.varnish-cache.org/trac/ticket/1612 +.. _1623: https://www.varnish-cache.org/trac/ticket/1623 +.. _1636: https://www.varnish-cache.org/trac/ticket/1636 +.. _1638: https://www.varnish-cache.org/trac/ticket/1638 +.. _1639: https://www.varnish-cache.org/trac/ticket/1639 +.. _1647: https://www.varnish-cache.org/trac/ticket/1647 +.. _1648: https://www.varnish-cache.org/trac/ticket/1648 +.. _1650: https://www.varnish-cache.org/trac/ticket/1650 + ============================================ diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 6c0e104..0b68eda 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,10 +1,10 @@ -%define XXXv_rc rc1 +%define v_rc beta1 %define vd_rc %{?v_rc:-%{?v_rc}} %define _use_internal_dependency_generator 0 %define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides Summary: High-performance HTTP accelerator Name: varnish -Version: 4.0.2 +Version: 4.0.3 #Release: 0.20140328%{?v_rc}%{?dist} Release: 1%{?v_rc}%{?dist} License: BSD From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] b7f9d3f Prepare 4.0.3-rc1. Message-ID: commit b7f9d3f4ce449a1397d4b855c35c991cec4b3596 Author: Lasse Karstensen Date: Thu Jan 15 16:27:39 2015 +0100 Prepare 4.0.3-rc1. Per our usual naming scheme, use -rc1 instead of -beta1. diff --git a/configure.ac b/configure.ac index f6690a5..cdc5422 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2014 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.0.3-beta1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.0.3-rc1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index dc99893..5bfbc0a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,6 +1,6 @@ -============================================== -Changes from 4.0.2 to 4.0.3-beta1 (2015-01-15) -============================================== +============================================ +Changes from 4.0.2 to 4.0.3-rc1 (2015-01-15) +============================================ Changes since 4.0.2: diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 0b68eda..44f0b93 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,4 +1,4 @@ -%define v_rc beta1 +%define v_rc rc1 %define vd_rc %{?v_rc:-%{?v_rc}} %define _use_internal_dependency_generator 0 %define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides From lkarsten at varnish-software.com Thu Jan 15 15:35:44 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 15 Jan 2015 16:35:44 +0100 Subject: [4.0] eea73f6 Fix minor RST formatting errors. Message-ID: commit eea73f6a75aaa361a5b87a52759ddaab438218a8 Author: Lasse Karstensen Date: Thu Jan 15 16:31:37 2015 +0100 Fix minor RST formatting errors. diff --git a/doc/changes.rst b/doc/changes.rst index 5bfbc0a..0765947 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -13,8 +13,7 @@ Changes since 4.0.2: - [packaging] EL6 packages are once again built with -O2. - [parameter] fetch_chunksize default is reduced to 16KB. (from 128KB) - Added std.time() which converts strings to VCL_TIME. -- [packaging] packages now Provide strictABI (gitref) and ABI (VRT major/minor) -for VMOD use. +- [packaging] packages now Provide strictABI (gitref) and ABI (VRT major/minor) for VMOD use. Bugs fixed ---------- @@ -34,6 +33,7 @@ Bugs fixed * 1648_ - Avoid partial IMS updates to replace old object. * 1650_ - Collapse multiple X-Forwarded-For headers +.. _1349: https://www.varnish-cache.org/trac/ticket/1349 .. _1378: https://www.varnish-cache.org/trac/ticket/1378 .. _1596: https://www.varnish-cache.org/trac/ticket/1596 .. _1506: https://www.varnish-cache.org/trac/ticket/1506 From phk at FreeBSD.org Thu Jan 15 16:12:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 17:12:15 +0100 Subject: [master] 4e7516a Add new waiters under lock to prevent races with the timer thread. Message-ID: commit 4e7516af86029eb12c0953c4243a69d75172d05a Author: Poul-Henning Kamp Date: Thu Jan 15 16:11:54 2015 +0000 Add new waiters under lock to prevent races with the timer thread. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 88b61c2..4f71f96 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -109,14 +109,11 @@ Wait_New(waiter_handle_f *func, volatile double *tmo) waiter->init(w); AN(w->impl->pass || w->pipes[1] >= 0); - if (w->pipes[1] >= 0 && VTAILQ_EMPTY(&waiters)) { - /* Start timer poker thread */ - AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL)); - } - Lck_Lock(&wait_mtx); VTAILQ_INSERT_TAIL(&waiters, w, list); nwaiters++; + if (w->pipes[1] >= 0 && nwaiters == 1) + AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL)); Lck_Unlock(&wait_mtx); return (w); } From phk at FreeBSD.org Thu Jan 15 16:32:45 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 15 Jan 2015 17:32:45 +0100 Subject: [master] 5566ce9 Use the common timer facility Message-ID: commit 5566ce98d072b6b8fe9d40a42fd65f8fdf516804 Author: Poul-Henning Kamp Date: Thu Jan 15 16:32:34 2015 +0000 Use the common timer facility diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 8f63c78..9bb7295 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -58,10 +58,7 @@ struct vwe { struct waiter *waiter; pthread_t epoll_thread; - pthread_t timer_thread; int epfd; - - int timer_pipes[2]; }; static void @@ -108,10 +105,8 @@ static void * vwe_thread(void *priv) { struct epoll_event ev[NEEV], *ep; - struct waited *sp, *sp2; - char junk; - double now, idle; - int dotimer, i, n; + double now; + int i, n; struct vwe *vwe; CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC); @@ -119,47 +114,10 @@ vwe_thread(void *priv) THR_SetName("cache-epoll"); while (1) { - dotimer = 0; n = epoll_wait(vwe->epfd, ev, NEEV, -1); now = VTIM_real(); - for (ep = ev, i = 0; i < n; i++, ep++) { - if (ep->data.ptr == vwe->timer_pipes && - (ep->events == EPOLLIN || ep->events == EPOLLPRI)) - { - assert(read(vwe->timer_pipes[0], &junk, 1)); - dotimer = 1; - } else - vwe_eev(vwe, ep, now); - } - if (!dotimer) - continue; - - /* check for timeouts */ - idle = now - *vwe->waiter->tmo; - VTAILQ_FOREACH_SAFE(sp, &vwe->waiter->waithead, list, sp2) { - if (sp->idle < idle) - Wait_Handle(vwe->waiter, sp, - WAITER_TIMEOUT, now); - } - } - return (NULL); -} - -/*--------------------------------------------------------------------*/ - -static void * -vwe_timeout_idle_ticker(void *priv) -{ - char ticker = 'R'; - struct vwe *vwe; - - CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC); - THR_SetName("cache-epoll-timeout_idle_ticker"); - - while (1) { - /* ticking */ - assert(write(vwe->timer_pipes[1], &ticker, 1)); - VTIM_sleep(100 * 1e-3); + for (ep = ev, i = 0; i < n; i++, ep++) + vwe_eev(vwe, ep, now); } return (NULL); } @@ -170,7 +128,6 @@ static void __match_proto__(waiter_init_f) vwe_init(struct waiter *w) { struct vwe *vwe; - struct epoll_event ev; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); vwe = w->priv; @@ -182,15 +139,7 @@ vwe_init(struct waiter *w) Wait_UsePipe(w); - AZ(pipe(vwe->timer_pipes)); - AZ(VFIL_nonblocking(vwe->timer_pipes[0])); - ev.data.ptr = vwe->timer_pipes; - ev.events = EPOLLIN | EPOLLPRI; - AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_ADD, vwe->timer_pipes[0], &ev)); - AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); - AZ(pthread_create(&vwe->timer_thread, - NULL, vwe_timeout_idle_ticker, vwe)); } /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Fri Jan 16 09:53:16 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 16 Jan 2015 10:53:16 +0100 Subject: [master] 091895c Spelling and indent Message-ID: commit 091895c35eea5ddbeb7a7565c2bbd864ecafad50 Author: Federico G. Schwindt Date: Fri Jan 16 09:52:41 2015 +0000 Spelling and indent diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index e0a765f..e1fa86f 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -56,7 +56,7 @@ * In a perfect world, we should vector through VRE to get to PCRE, * but since we rely on PCRE's ability to encode the regexp into a * byte string, that would be a little bit artificial, so this is - * the exception that confirmes the rule. + * the exception that confirms the rule. * */ @@ -568,7 +568,7 @@ BAN_Insert(struct ban *b) /* Hunt down duplicates, and mark them as completed */ bi = b; Lck_Lock(&ban_mtx); - while(!ban_shutdown && bi != be) { + while (!ban_shutdown && bi != be) { bi = VTAILQ_NEXT(bi, list); if (bi->flags & BANS_FLAG_COMPLETED) continue; From perbu at varnish-software.com Fri Jan 16 10:35:17 2015 From: perbu at varnish-software.com (Per Buer) Date: Fri, 16 Jan 2015 11:35:17 +0100 Subject: [master] 872f5a9 Add a backslash to fix the latex build Message-ID: commit 872f5a96b28ec4f7bdb2890de02b639d0d7ad6f6 Author: Per Buer Date: Fri Jan 16 11:35:15 2015 +0100 Add a backslash to fix the latex build diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index 4dfa40f..22b9e4c 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -67,7 +67,7 @@ want to know are: '-c' Same as '-b' but for client side traffic. -'-m tag:regex' +'-m tag\:regex' Only list transactions where the tag matches a regular expression. If it matches you will get the whole transaction. From fgsch at lodoss.net Fri Jan 16 15:08:24 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 16 Jan 2015 16:08:24 +0100 Subject: [master] e726134 Sync with reality Message-ID: commit e726134e1a3ab341007e7c86237048b796474217 Author: Federico G. Schwindt Date: Fri Jan 16 15:06:20 2015 +0000 Sync with reality This updates the last oustanding document to 4.0 diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index 22b9e4c..d3e715c 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -20,13 +20,13 @@ is logging. `varnishlog` gives you the raw logs, everything that is written to the logs. There are other clients that can access the logs as well, we'll show you these later. -In the terminal window you started Varnish now type ``varnishlog`` and -press enter. +In the terminal window you started Varnish now type ``varnishlog -g raw`` +and press enter. You'll see lines like these scrolling slowly by.:: - 0 CLI - Rd ping - 0 CLI - Wr 200 PONG 1273698726 1.0 + 0 CLI - Rd ping + 0 CLI - Wr 200 19 PONG 1273698726 1.0 These is the Varnish master process checking up on the caching process to see that everything is OK. @@ -37,25 +37,24 @@ app. You'll see lines like these.:: - 11 SessionOpen c 127.0.0.1 58912 0.0.0.0:8080 - 11 ReqStart c 127.0.0.1 58912 595005213 - 11 RxRequest c GET - 11 RxURL c / - 11 RxProtocol c HTTP/1.1 - 11 RxHeader c Host: localhost:8080 - 11 RxHeader c Connection: keep-alive + 11 SessOpen c 127.0.0.1 58912 :8080 0.0.0.0 8080 1273698726.933590 14 + 11 ReqStart c 127.0.0.1 58912 + 11 ReqMethod c GET + 11 ReqURL c / + 11 ReqProtocol c HTTP/1.1 + 11 ReqHeader c Host: localhost:8080 + 11 ReqHeader c Connection: keep-alive The first column is an arbitrary number, it identifies the -session. Lines with the same number are coming from the same session -and are being handled by the same thread. The second column is the -*tag* of the log message. All log entries are tagged with a tag -indicating what sort of activity is being logged. Tags starting with -'Rx' indicate Varnish is receiving data and 'Tx' indicates sending data. +transaction. Lines with the same number are coming from the same +transaction. The second column is the *tag* of the log message. All +log entries are tagged with a tag indicating what sort of activity is +being logged. -The third column tell us whether this is is data coming or going to -the client ('c') or to/from the backend ('b'). The forth column is the -data being logged. +The third column tell us whether this is is data coming from or going +to the client ('c'), or the backend ('b'). The forth column is the data +being logged. Now, you can filter quite a bit with `varnishlog`. The basic options we think you want to know are: @@ -67,9 +66,11 @@ want to know are: '-c' Same as '-b' but for client side traffic. -'-m tag\:regex' - Only list transactions where the tag matches a regular expression. If - it matches you will get the whole transaction. +'-g request' + Group transactions by request. + +'-q query' + Only list transactions matching this query. .. XXX:Maybe a couple of sample commands here? benc From phk at FreeBSD.org Mon Jan 19 08:13:34 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 09:13:34 +0100 Subject: [master] 647e7fa Fix a theoretical resource leak spotted by Coverity: If we are out of malloc space: we leak memory while we collapse. Message-ID: commit 647e7fa32f333989289fdbd0b3beaf6d75ce881c Author: Poul-Henning Kamp Date: Mon Jan 19 08:12:24 2015 +0000 Fix a theoretical resource leak spotted by Coverity: If we are out of malloc space: we leak memory while we collapse. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index bd6c932..6cf6370 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -288,8 +288,10 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, if (act == VDP_INIT) { vg = VGZ_NewUngzip(req->vsl, "U D -"); AN(vg); - if (vgz_getmbuf(vg)) + if (vgz_getmbuf(vg)) { + (void)VGZ_Destroy(&vg); return (-1); + } VGZ_Obuf(vg, vg->m_buf, vg->m_sz); *priv = vg; From phk at FreeBSD.org Mon Jan 19 08:14:30 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 09:14:30 +0100 Subject: [master] 5927ca2 Call cleanup functions in correct order. Message-ID: commit 5927ca2d94d097e35c18ea25f14e4856b3221020 Author: Poul-Henning Kamp Date: Mon Jan 19 08:14:13 2015 +0000 Call cleanup functions in correct order. Spotted by Coverity. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index faffadb..1fac6d8 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -352,8 +352,8 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, bp->display_name); Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; - VBE_DropRefLocked(bp, &bo->acct); VBT_Recycle(bp->tcp_pool, &bo->htc->vbc); + VBE_DropRefLocked(bp, &bo->acct); } bo->htc->vbc = NULL; bo->htc = NULL; From phk at FreeBSD.org Mon Jan 19 09:58:56 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 10:58:56 +0100 Subject: [master] ce7b751 Zero the pointer when we free a miniobj Message-ID: commit ce7b751dd0657ad9f4e13cdaef07a209e353c1ab Author: Poul-Henning Kamp Date: Mon Jan 19 09:57:53 2015 +0000 Zero the pointer when we free a miniobj diff --git a/include/miniobj.h b/include/miniobj.h index 746f606..3de4091 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -22,6 +22,7 @@ do { \ (to)->magic = (0); \ free(to); \ + to = NULL; \ } while (0) #define VALID_OBJ(ptr, type_magic) \ From phk at FreeBSD.org Mon Jan 19 09:58:57 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 10:58:57 +0100 Subject: [master] b46b256 Roll tcp pools all the way in. Message-ID: commit b46b25679f237e1276dc238b03cd7534efdb7a28 Author: Poul-Henning Kamp Date: Mon Jan 19 09:58:11 2015 +0000 Roll tcp pools all the way in. This also retires the vbc_mempool, which doesn't seem to improve things. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 1fac6d8..163fabe 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -42,11 +42,6 @@ #include "cache_backend.h" #include "cache_director.h" #include "vrt.h" -#include "vtcp.h" - -static struct mempool *vbcpool; - -static unsigned vbcps = sizeof(struct vbc); /*-------------------------------------------------------------------- * The "simple" director really isn't, since thats where all the actual @@ -62,19 +57,6 @@ struct vbe_dir { const struct vrt_backend *vrt; }; -/*--------------------------------------------------------------------*/ - -/* Private interface from backend_cfg.c */ -void -VBE_ReleaseConn(struct vbc *vc) -{ - - CHECK_OBJ_NOTNULL(vc, VBC_MAGIC); - assert(vc->backend == NULL); - assert(vc->fd < 0); - MPL_Free(vbcpool, vc); -} - #define FIND_TMO(tmx, dst, bo, be) \ do { \ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ @@ -85,65 +67,6 @@ VBE_ReleaseConn(struct vbc *vc) dst = cache_param->tmx; \ } while (0) -/*--------------------------------------------------------------------*/ - -static void -bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) -{ - int s; - double tmod; - struct backend *bp = vs->backend; - char abuf1[VTCP_ADDRBUFSIZE]; - char pbuf1[VTCP_PORTBUFSIZE]; - - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); - - Lck_Lock(&bp->mtx); - bp->refcount++; - bp->n_conn++; /* It mostly works */ - bp->vsc->conn++; - Lck_Unlock(&bp->mtx); - - assert(bp->ipv6 != NULL || bp->ipv4 != NULL); - - /* release lock during stuff that can take a long time */ - - FIND_TMO(connect_timeout, tmod, bo, vs->vrt); - s = VBT_Open(bp->tcp_pool, tmod, &vc->addr); - - vc->fd = s; - if (s < 0) { - Lck_Lock(&bp->mtx); - bp->n_conn--; - bp->vsc->conn--; - bp->refcount--; /* Only keep ref on success */ - Lck_Unlock(&bp->mtx); - vc->addr = NULL; - } else { - VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - VSLb(bo->vsl, SLT_BackendOpen, "%d %s %s %s ", - vc->fd, vs->backend->display_name, abuf1, pbuf1); - } -} - -/*-------------------------------------------------------------------- - * 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 - * use it (backends are not allowed to pipeline). - */ - -static int -vbe_CheckFd(int fd) -{ - struct pollfd pfd; - - pfd.fd = fd; - pfd.events = POLLIN; - pfd.revents = 0; - return(poll(&pfd, 1, 0) == 0); -} - /*-------------------------------------------------------------------- * Test if backend is healthy and report when it last changed */ @@ -166,80 +89,6 @@ VBE_Healthy(const struct backend *backend, double *changed) } /*-------------------------------------------------------------------- - * Get a connection to a particular backend. - */ - -static struct vbc * -vbe_GetVbe(struct busyobj *bo, struct vbe_dir *vs) -{ - struct vbc *vc; - struct backend *bp; - - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); - bp = vs->backend; - CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); - - if (!VBE_Healthy(bp, NULL)) { - VSC_C_main->backend_unhealthy++; - return (NULL); - } - - /* first look for vbc's we can recycle */ - while (1) { - vc = VBT_Get(bp->tcp_pool); - if (vc == NULL) - break; - - Lck_Lock(&bp->mtx); - bp->refcount++; - assert(vc->backend == bp); - assert(vc->fd >= 0); - AN(vc->addr); - Lck_Unlock(&bp->mtx); - - if (vbe_CheckFd(vc->fd)) { - VSLb(bo->vsl, SLT_Backend, "%d %s %s", - vc->fd, bo->director_resp->vcl_name, - bp->display_name); - vc->vdis = vs; - vc->recycled = 1; - return (vc); - } - VSLb(bo->vsl, SLT_BackendClose, "%d %s toolate", - vc->fd, bp->display_name); - - VTCP_close(&vc->fd); - VBE_DropRefConn(bp, NULL); - vc->backend = NULL; - VBE_ReleaseConn(vc); - } - - if (vs->vrt->max_connections > 0 && - bp->n_conn >= vs->vrt->max_connections) { - VSC_C_main->backend_busy++; - return (NULL); - } - - vc = MPL_Get(vbcpool, NULL); - XXXAN(vc); - vc->magic = VBC_MAGIC; - vc->fd = -1; - bes_conn_try(bo, vc, vs); - if (vc->fd < 0) { - VBE_ReleaseConn(vc); - VSC_C_main->backend_fail++; - return (NULL); - } - vc->backend = bp; - VSC_C_main->backend_conn++; - VSLb(bo->vsl, SLT_Backend, "%d %s %s", - vc->fd, bo->director_resp->vcl_name, bp->display_name); - vc->vdis = vs; - return (vc); -} - -/*-------------------------------------------------------------------- * */ @@ -278,7 +127,7 @@ VBE_DiscardHealth(const struct director *vdi) } /*-------------------------------------------------------------------- - * + * Get a connection to the backend */ static int __match_proto__(vdi_getfd_f) @@ -286,17 +135,47 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) { struct vbe_dir *vs; struct vbc *vc; + struct backend *bp; + double tmod; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + bp = vs->backend; + CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); - vc = vbe_GetVbe(bo, vs); + if (!VBE_Healthy(bp, NULL)) { + // XXX: per backend stats ? + VSC_C_main->backend_unhealthy++; + return (-1); + } + + if (vs->vrt->max_connections > 0 && + bp->n_conn >= vs->vrt->max_connections) { + // XXX: per backend stats ? + VSC_C_main->backend_busy++; + return (-1); + } + + FIND_TMO(connect_timeout, tmod, bo, vs->vrt); + vc = VBT_Get(bp->tcp_pool, tmod); if (vc == NULL) { + // XXX: Per backend stats ? + VSC_C_main->backend_fail++; VSLb(bo->vsl, SLT_FetchError, "no backend connection"); return (-1); } + assert(vc->fd >= 0); + vc->backend = bp; + AN(vc->addr); + + Lck_Lock(&bp->mtx); + bp->refcount++; + bp->n_conn++; + bp->vsc->conn++; + Lck_Unlock(&bp->mtx); + vc->backend->vsc->req++; if (bo->htc == NULL) bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc); @@ -343,10 +222,8 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, if (bo->doclose != SC_NULL) { VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd, bp->display_name); - VTCP_close(&bo->htc->vbc->fd); + VBT_Close(bp->tcp_pool, &bo->htc->vbc); VBE_DropRefConn(bp, &bo->acct); - bo->htc->vbc->backend = NULL; - VBE_ReleaseConn(bo->htc->vbc); } else { VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->htc->vbc->fd, bp->display_name); @@ -482,11 +359,3 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, bp[idx] = &vs->dir; } - -void -VBE_Init(void) -{ - - vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps); - AN(vbcpool); -} diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 0cda35e..63806ec 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -89,17 +89,14 @@ struct vbc { unsigned magic; #define VBC_MAGIC 0x0c5e6592 VTAILQ_ENTRY(vbc) list; - struct backend *backend; - struct vbe_dir *vdis; int fd; - const struct suckaddr *addr; - uint8_t recycled; + + struct backend *backend; }; /* cache_backend.c */ -void VBE_ReleaseConn(struct vbc *vc); void VBE_UseHealth(const struct director *vdi); void VBE_DiscardHealth(const struct director *vdi); @@ -127,6 +124,7 @@ struct tcp_pool *VBT_Ref(const char *name, const struct suckaddr *ip4, void VBT_Rel(struct tcp_pool **tpp); int VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa); void VBT_Recycle(struct tcp_pool *tp, struct vbc **vbc); -struct vbc *VBT_Get(struct tcp_pool *tp); +void VBT_Close(struct tcp_pool *tp, struct vbc **vbc); +struct vbc *VBT_Get(struct tcp_pool *tp, double tmo); diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 5495cff..90f18fe 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -25,7 +25,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * TCP connection pools for backends + * TCP connection pools. + * + * These are really a lot more general than just backends, but backends + * are all we use them for, so they live here for now. * */ @@ -57,7 +60,12 @@ struct tcp_pool { struct lock mtx; VTAILQ_HEAD(, vbc) connlist; + int n_conn; + VTAILQ_HEAD(, vbc) killlist; + int n_kill; + + int n_used; }; @@ -133,6 +141,7 @@ VBT_Rel(struct tcp_pool **tpp) assert(tp->refcnt > 0); if (--tp->refcnt > 0) return; + AZ(tp->n_used); VTAILQ_REMOVE(&pools, tp, list); free(tp->name); free(tp->ip4); @@ -140,18 +149,18 @@ VBT_Rel(struct tcp_pool **tpp) Lck_Delete(&tp->mtx); VTAILQ_FOREACH_SAFE(vbc, &tp->connlist, list, vbc2) { VTAILQ_REMOVE(&tp->connlist, vbc, list); - vbc->backend = NULL; - (void)close(vbc->fd); - vbc->fd = -1; - VBE_ReleaseConn(vbc); + tp->n_conn--; + VTCP_close(&vbc->fd); + FREE_OBJ(vbc); } VTAILQ_FOREACH_SAFE(vbc, &tp->killlist, list, vbc2) { VTAILQ_REMOVE(&tp->killlist, vbc, list); - vbc->backend = NULL; - (void)close(vbc->fd); - vbc->fd = -1; - VBE_ReleaseConn(vbc); + tp->n_kill--; + VTCP_close(&vbc->fd); + FREE_OBJ(vbc); } + AZ(tp->n_conn); + AZ(tp->n_kill); FREE_OBJ(tp); } @@ -189,16 +198,42 @@ VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa) */ void -VBT_Recycle(struct tcp_pool *tp, struct vbc **vbc) +VBT_Recycle(struct tcp_pool *tp, struct vbc **vbcp) +{ + struct vbc *vbc; + + CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); + vbc = *vbcp; + *vbcp = NULL; + CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); + + Lck_Lock(&tp->mtx); + vbc->recycled = 1; + VTAILQ_INSERT_HEAD(&tp->connlist, vbc, list); + tp->n_conn++; + tp->n_used--; + Lck_Unlock(&tp->mtx); +} + +/*-------------------------------------------------------------------- + * Close a connection. + */ + +void +VBT_Close(struct tcp_pool *tp, struct vbc **vbcp) { + struct vbc *vbc; CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); - CHECK_OBJ_NOTNULL((*vbc), VBC_MAGIC); + vbc = *vbcp; + *vbcp = NULL; + CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); + VTCP_close(&vbc->fd); + FREE_OBJ(vbc); Lck_Lock(&tp->mtx); - VTAILQ_INSERT_HEAD(&tp->connlist, *vbc, list); + tp->n_used--; Lck_Unlock(&tp->mtx); - *vbc = NULL; } /*-------------------------------------------------------------------- @@ -206,11 +241,12 @@ VBT_Recycle(struct tcp_pool *tp, struct vbc **vbc) */ struct vbc * -VBT_Get(struct tcp_pool *tp) +VBT_Get(struct tcp_pool *tp, double tmo) { struct vbc *vbc; struct pollfd pfd; + (void)tmo; CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); Lck_Lock(&tp->mtx); @@ -229,23 +265,40 @@ VBT_Get(struct tcp_pool *tp) VSC_C_main->backend_toolate++; do { VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; #if 0 VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); + tp->n_kill++; #else - vbc->backend = NULL; - (void)close(vbc->fd); - vbc->fd = -1; - VBE_ReleaseConn(vbc); + VTCP_close(&vbc->fd); + FREE_OBJ(vbc); #endif vbc = VTAILQ_FIRST(&tp->connlist); } while (vbc != NULL); } else { VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; + tp->n_used++; VSC_C_main->backend_reuse += 1; } } + if (vbc == NULL) + tp->n_used++; // Opening mostly works Lck_Unlock(&tp->mtx); + if (vbc != NULL) return (vbc); - return (NULL); + + ALLOC_OBJ(vbc, VBC_MAGIC); + if (vbc != NULL) { + vbc->fd = VBT_Open(tp, tmo, &vbc->addr); + if (vbc->fd < 0) + FREE_OBJ(vbc); + } + if (vbc == NULL) { + Lck_Lock(&tp->mtx); + tp->n_used--; + Lck_Unlock(&tp->mtx); + } + return (vbc); } diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index d204ef0..49611ab 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -82,6 +82,3 @@ void VDI_Finish(struct worker *wrk, struct busyobj *bo); int VDI_Http1Pipe(struct req *, struct busyobj *); int VDI_Healthy(const struct director *, const struct busyobj *); - -void VBE_Init(void); - diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index bc55e99..469134d 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -221,7 +221,6 @@ child_main(void) HTTP_Init(); - VBE_Init(); VBO_Init(); VBE_InitCfg(); VBP_Init(); diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 2ce95c6..cdb8646 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -211,7 +211,6 @@ struct params { ssize_t vsm_space; ssize_t vsl_space; - struct poolparam vbc_pool; struct poolparam req_pool; struct poolparam sess_pool; struct poolparam vbo_pool; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 50ba8ea..fc9dc78 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -615,13 +615,6 @@ struct parspec mgt_parspec[] = { 0, "off", "bool"}, - { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, - NULL, NULL, - "Parameters for backend connection memory pool.\n" - MEMPOOL_TEXT, - 0, - "10,100,10", ""}, - { "pool_req", tweak_poolparam, &mgt_param.req_pool, NULL, NULL, "Parameters for per worker pool request memory pool.\n" diff --git a/bin/varnishtest/tests/b00034.vtc b/bin/varnishtest/tests/b00034.vtc index 8e23d60..e3ba26b 100644 --- a/bin/varnishtest/tests/b00034.vtc +++ b/bin/varnishtest/tests/b00034.vtc @@ -5,9 +5,9 @@ server s1 { varnish v1 -vcl+backend {} -varnish v1 -cliok "param.set pool_vbc 1,10,1" -varnish v1 -clierr 106 "param.set pool_vbc 10" -varnish v1 -clierr 106 "param.set pool_vbc 10,1,1" -varnish v1 -clierr 106 "param.set pool_vbc a,10,10" -varnish v1 -clierr 106 "param.set pool_vbc 10,a,10" -varnish v1 -clierr 106 "param.set pool_vbc 10,10,a" +varnish v1 -cliok "param.set pool_req 1,10,1" +varnish v1 -clierr 106 "param.set pool_req 10" +varnish v1 -clierr 106 "param.set pool_req 10,1,1" +varnish v1 -clierr 106 "param.set pool_req a,10,10" +varnish v1 -clierr 106 "param.set pool_req 10,a,10" +varnish v1 -clierr 106 "param.set pool_req 10,10,a" diff --git a/bin/varnishtest/tests/c00050.vtc b/bin/varnishtest/tests/c00050.vtc index 2e787cb..6a3b35d 100644 --- a/bin/varnishtest/tests/c00050.vtc +++ b/bin/varnishtest/tests/c00050.vtc @@ -6,24 +6,24 @@ varnish v1 -vcl+backend {} -start delay 2 -varnish v1 -expect MEMPOOL.vbc.pool == 10 +varnish v1 -expect MEMPOOL.req0.pool == 10 -varnish v1 -cliok "param.set pool_vbc 90,100,100" +varnish v1 -cliok "param.set pool_req 90,100,100" delay 2 -varnish v1 -expect MEMPOOL.vbc.pool == 90 +varnish v1 -expect MEMPOOL.req0.pool == 90 -varnish v1 -cliok "param.set pool_vbc 50,80,100" +varnish v1 -cliok "param.set pool_req 50,80,100" delay 2 -varnish v1 -expect MEMPOOL.vbc.pool == 80 -varnish v1 -expect MEMPOOL.vbc.surplus == 10 +varnish v1 -expect MEMPOOL.req0.pool == 80 +varnish v1 -expect MEMPOOL.req0.surplus == 10 -varnish v1 -cliok "param.set pool_vbc 10,80,1" +varnish v1 -cliok "param.set pool_req 10,80,1" delay 2 -varnish v1 -expect MEMPOOL.vbc.pool == 10 -varnish v1 -expect MEMPOOL.vbc.timeout == 70 +varnish v1 -expect MEMPOOL.req0.pool == 10 +varnish v1 -expect MEMPOOL.req0.timeout == 70 From phk at FreeBSD.org Mon Jan 19 11:26:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 12:26:00 +0100 Subject: [master] 790ebc5 Comment polishing Message-ID: commit 790ebc5ad1c1591bf1d513b426de845a3981395f Author: Poul-Henning Kamp Date: Mon Jan 19 11:25:51 2015 +0000 Comment polishing diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 163fabe..113342b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Handle backend connections and backend request structures. + * The director implementation for VCL backends. * */ @@ -43,12 +43,6 @@ #include "cache_director.h" #include "vrt.h" -/*-------------------------------------------------------------------- - * The "simple" director really isn't, since thats where all the actual - * connections happen. Nonetheless, pretend it is simple by sequestering - * the directoricity of it under this line. - */ - struct vbe_dir { unsigned magic; #define VDI_SIMPLE_MAGIC 0x476d25b7 From phk at FreeBSD.org Mon Jan 19 12:57:08 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 13:57:08 +0100 Subject: [master] 97adb56 Make the compiled vcl a tad less confusing Message-ID: commit 97adb56bf242f6b92b9f2e07c36f81fdf4da7f02 Author: Poul-Henning Kamp Date: Mon Jan 19 12:39:31 2015 +0000 Make the compiled vcl a tad less confusing diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index bfcc2d5..f5908ad 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -111,7 +111,7 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) AN(sua); Fh(tl, 0, "static const unsigned long long"); - Fh(tl, 0, " sockaddr_%u[%d] = {\n", tl->unique, n); + Fh(tl, 0, " suckaddr_%u[%d] = {\n", tl->unique, n); memcpy(b, sua, vsa_suckaddr_len); free(sua); for (len = 0; len < n; len++) @@ -121,7 +121,7 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) p = TlAlloc(tl, 40); AN(p); - sprintf(p, "(const void*)sockaddr_%u", tl->unique); + sprintf(p, "(const void*)suckaddr_%u", tl->unique); tl->unique++; return (p); From phk at FreeBSD.org Mon Jan 19 12:57:08 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 13:57:08 +0100 Subject: [master] d60d80d Move responsibility for discarding backend probes. Message-ID: commit d60d80d36fbcf09a44bdd5cff88ea02011f185e7 Author: Poul-Henning Kamp Date: Mon Jan 19 12:56:45 2015 +0000 Move responsibility for discarding backend probes. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 113342b..4f8834d 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -102,25 +102,6 @@ VBE_UseHealth(const struct director *vdi) } /*-------------------------------------------------------------------- - * - */ - -void -VBE_DiscardHealth(const struct director *vdi) -{ - struct vbe_dir *vs; - - ASSERT_CLI(); - - if (strcmp(vdi->name, "simple")) - return; - CAST_OBJ_NOTNULL(vs, vdi->priv, VDI_SIMPLE_MAGIC); - if (vs->vrt->probe == NULL) - return; - VBP_Remove(vs->backend, vs->vrt->probe); -} - -/*-------------------------------------------------------------------- * Get a connection to the backend */ @@ -294,39 +275,49 @@ vbe_dir_getbody(const struct director *d, struct worker *wrk, /*--------------------------------------------------------------------*/ +static void +vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) +{ + int i; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + i = vbe_dir_getfd(d, bo); + V1P_Process(req, bo, i); + vbe_dir_finish(d, bo->wrk, bo); +} + +/*--------------------------------------------------------------------*/ + void -VRT_fini_vbe(VRT_CTX, struct director *d) +VRT_fini_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) { struct vbe_dir *vs; + struct director *d; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(dp); + (void)vrt; + + d = *dp; + *dp = NULL; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + if (vs->vrt->probe != NULL) + VBP_Remove(vs->backend, vs->vrt->probe); + VBE_DropRefVcl(vs->backend); free(vs->dir.vcl_name); vs->dir.magic = 0; FREE_OBJ(vs); - d->priv = NULL; } -static void -vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) -{ - int i; - - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - - i = vbe_dir_getfd(d, bo); - V1P_Process(req, bo, i); - vbe_dir_finish(d, bo->wrk, bo); -} void -VRT_init_vbe(VRT_CTX, struct director **bp, int idx, - const struct vrt_backend *vrt) +VRT_init_vbe(VRT_CTX, struct director **bp, const struct vrt_backend *vrt) { struct vbe_dir *vs; @@ -351,5 +342,5 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx, if (vs->vrt->probe != NULL) VBP_Insert(vs->backend, vs->vrt->probe, vs->vrt->hosthdr); - bp[idx] = &vs->dir; + * bp = &vs->dir; } diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 63806ec..32f3b8d 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -98,7 +98,6 @@ struct vbc { /* cache_backend.c */ void VBE_UseHealth(const struct director *vdi); -void VBE_DiscardHealth(const struct director *vdi); /* cache_backend_cfg.c */ void VBE_DropRefConn(struct backend *, const struct acct_bereq *); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index c6ea472..08f996b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -330,7 +330,6 @@ static void ccf_config_discard(struct cli *cli, const char * const *av, void *priv) { struct vcls *vcl; - int i; ASSERT_CLI(); AZ(priv); @@ -353,10 +352,6 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv) vcl->conf->discard = 1; Lck_Unlock(&vcl_mtx); - /* Tickle this VCL's backends to give up health polling */ - for(i = 1; i < vcl->conf->ndirector; i++) - VBE_DiscardHealth(vcl->conf->director[i]); - if (vcl->conf->busy == 0) VCL_Nuke(vcl); } diff --git a/include/vrt.h b/include/vrt.h index bc4a73d..09e2b52 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -225,8 +225,8 @@ void VRT_Rollback(VRT_CTX, const struct http *); void VRT_synth_page(VRT_CTX, const char *, ...); /* Backend related */ -void VRT_init_vbe(VRT_CTX, struct director **, int idx, const struct vrt_backend *); -void VRT_fini_vbe(VRT_CTX, struct director *); +void VRT_init_vbe(VRT_CTX, struct director **, const struct vrt_backend *); +void VRT_fini_vbe(VRT_CTX, struct director **, const struct vrt_backend *); /* Suckaddr related */ int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst); diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 25b13da..66feb7e 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -423,9 +423,11 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be) ifp = New_IniFin(tl); VSB_printf(ifp->ini, - "\tVRT_init_vbe(ctx, VCL_conf.director,\n" - "\t VGC_backend_%s, &vgc_dir_priv_%s);", vgcname, vgcname); - VSB_printf(ifp->fin, "\tVRT_fini_vbe(ctx, VGCDIR(%s));", vgcname); + "\tVRT_init_vbe(ctx, &VGCDIR(%s), &vgc_dir_priv_%s);", + vgcname, vgcname); + VSB_printf(ifp->fin, + "\tVRT_fini_vbe(ctx, &VGCDIR(%s), &vgc_dir_priv_%s);", + vgcname, vgcname); tl->ndirector++; } From phk at FreeBSD.org Mon Jan 19 13:53:54 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 14:53:54 +0100 Subject: [master] 93b6da1 Introduce the VCL_EVENT_ACTIVATE which is posted before vcl.use takes effect. Use this to move backend probes as appropriate. Message-ID: commit 93b6da19abbb9cdf5973b4f64005a9f7941a23f6 Author: Poul-Henning Kamp Date: Mon Jan 19 13:53:17 2015 +0000 Introduce the VCL_EVENT_ACTIVATE which is posted before vcl.use takes effect. Use this to move backend probes as appropriate. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 4f8834d..2c85d29 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -83,25 +83,6 @@ VBE_Healthy(const struct backend *backend, double *changed) } /*-------------------------------------------------------------------- - * - */ - -void -VBE_UseHealth(const struct director *vdi) -{ - struct vbe_dir *vs; - - ASSERT_CLI(); - - if (strcmp(vdi->name, "simple")) - return; - CAST_OBJ_NOTNULL(vs, vdi->priv, VDI_SIMPLE_MAGIC); - if (vs->vrt->probe == NULL) - return; - VBP_Use(vs->backend, vs->vrt->probe); -} - -/*-------------------------------------------------------------------- * Get a connection to the backend */ @@ -291,38 +272,14 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) /*--------------------------------------------------------------------*/ void -VRT_fini_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) +VRT_init_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) { struct vbe_dir *vs; - struct director *d; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(dp); - (void)vrt; - - d = *dp; - *dp = NULL; - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - - if (vs->vrt->probe != NULL) - VBP_Remove(vs->backend, vs->vrt->probe); - - VBE_DropRefVcl(vs->backend); - free(vs->dir.vcl_name); - vs->dir.magic = 0; - FREE_OBJ(vs); -} - - -void -VRT_init_vbe(VRT_CTX, struct director **bp, const struct vrt_backend *vrt) -{ - struct vbe_dir *vs; - - ASSERT_CLI(); - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AZ(*dp); ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC); XXXAN(vs); @@ -340,7 +297,48 @@ VRT_init_vbe(VRT_CTX, struct director **bp, const struct vrt_backend *vrt) vs->backend = VBE_AddBackend(NULL, vrt); if (vs->vrt->probe != NULL) - VBP_Insert(vs->backend, vs->vrt->probe, vs->vrt->hosthdr); + VBP_Insert(vs->backend, vrt->probe, vrt->hosthdr); - * bp = &vs->dir; + *dp = &vs->dir; +} + +void +VRT_use_vbe(VRT_CTX, const struct director *d, const struct vrt_backend *vrt) +{ + struct vbe_dir *vs; + + ASSERT_CLI(); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + + if (vrt->probe == NULL) + return; + + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + + VBP_Use(vs->backend, vrt->probe); +} + +void +VRT_fini_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) +{ + struct vbe_dir *vs; + struct director *d; + + ASSERT_CLI(); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(dp); + + d = *dp; + *dp = NULL; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + + if (vs->vrt->probe != NULL) + VBP_Remove(vs->backend, vrt->probe); + + VBE_DropRefVcl(vs->backend); + free(vs->dir.vcl_name); + vs->dir.magic = 0; + FREE_OBJ(vs); } diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 32f3b8d..26955a6 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -96,9 +96,6 @@ struct vbc { struct backend *backend; }; -/* cache_backend.c */ -void VBE_UseHealth(const struct director *vdi); - /* cache_backend_cfg.c */ void VBE_DropRefConn(struct backend *, const struct acct_bereq *); void VBE_DropRefVcl(struct backend *); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 08f996b..d74e9b0 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -360,7 +360,8 @@ static void ccf_config_use(struct cli *cli, const char * const *av, void *priv) { struct vcls *vcl; - int i; + struct vrt_ctx ctx; + unsigned hand = 0; (void)av; (void)priv; @@ -370,13 +371,19 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) VCLI_SetResult(cli, CLIS_PARAM); return; } + + INIT_OBJ(&ctx, VRT_CTX_MAGIC); + ctx.handling = &hand; + ctx.cli = cli; + if (vcl->conf->event_vcl(&ctx, VCL_EVENT_ACTIVATE)) { + VCLI_Out(cli, "VCL \"%s\" Failed to activate", av[2]); + VCLI_SetResult(cli, CLIS_CANT); + return; + } + Lck_Lock(&vcl_mtx); vcl_active = vcl; Lck_Unlock(&vcl_mtx); - - /* Tickle this VCL's backends to take over health polling */ - for(i = 1; i < vcl->conf->ndirector; i++) - VBE_UseHealth(vcl->conf->director[i]); } static void diff --git a/include/vrt.h b/include/vrt.h index 09e2b52..c30696a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -226,6 +226,7 @@ void VRT_synth_page(VRT_CTX, const char *, ...); /* Backend related */ void VRT_init_vbe(VRT_CTX, struct director **, const struct vrt_backend *); +void VRT_use_vbe(VRT_CTX, const struct director *, const struct vrt_backend *); void VRT_fini_vbe(VRT_CTX, struct director **, const struct vrt_backend *); /* Suckaddr related */ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index ea26bf2..aafcfc0 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -947,6 +947,7 @@ struct worker; enum vcl_event_e { VCL_EVENT_INIT, + VCL_EVENT_ACTIVATE, VCL_EVENT_FINI, }; diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 66feb7e..f6026ef 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -428,6 +428,10 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be) VSB_printf(ifp->fin, "\tVRT_fini_vbe(ctx, &VGCDIR(%s), &vgc_dir_priv_%s);", vgcname, vgcname); + VSB_printf(ifp->event, + "\tif (ev == VCL_EVENT_ACTIVATE)\n" + "\t\tVRT_use_vbe(ctx, VGCDIR(%s), &vgc_dir_priv_%s);", + vgcname, vgcname); tl->ndirector++; } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 32dc8f2..4ebe707 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -346,17 +346,16 @@ EmitInitFini(const struct vcc *tl) Fc(tl, 0, "{\n"); Fc(tl, 0, "\tif (ev == VCL_EVENT_INIT)\n"); Fc(tl, 0, "\t\treturn(VGC_Init(ctx));\n"); - Fc(tl, 0, "\telse if (ev == VCL_EVENT_FINI)\n"); + Fc(tl, 0, "\tif (ev == VCL_EVENT_FINI)\n"); Fc(tl, 0, "\t\treturn(VGC_Fini(ctx));\n"); - Fc(tl, 0, "\telse {\n"); + Fc(tl, 0, "\t\n"); VTAILQ_FOREACH(p, &tl->inifin, list) { AZ(VSB_finish(p->event)); if (VSB_len(p->event)) Fc(tl, 0, "\t/* %u */\n%s\n", p->n, VSB_data(p->event)); VSB_delete(p->event); } - Fc(tl, 0, "\t\treturn (0);\n"); - Fc(tl, 0, "\t}\n"); + Fc(tl, 0, "\treturn (0);\n"); Fc(tl, 0, "}\n"); } From lkarsten at varnish-software.com Mon Jan 19 15:21:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 19 Jan 2015 16:21:20 +0100 Subject: [4.0] 29e4a01 If we fail to reschedule from the waiting list, we ditch the entire waiting list in an attempt to recover. Message-ID: commit 29e4a01c5243c5fac87556a5828971685050254b Author: Martin Blix Grydeland Date: Tue Nov 18 11:41:17 2014 +0100 If we fail to reschedule from the waiting list, we ditch the entire waiting list in an attempt to recover. This also fixes buglet in previous commit which failed to call CNT_AcctLogCharge() Fixes: #1629 (cherry picked from commit 9fbcb4e94942a1bc7ff540f0a475b057a616b1ae) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 59e6d94..b666d07 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -520,6 +520,7 @@ hsh_rush(struct dstat *ds, struct objhead *oh) { unsigned u; struct req *req; + struct sess *sp; struct waitinglist *wl; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); @@ -535,8 +536,29 @@ hsh_rush(struct dstat *ds, struct objhead *oh) AZ(req->wrk); VTAILQ_REMOVE(&wl->list, req, w_list); DSL(DBG_WAITINGLIST, req->vsl->wid, "off waiting list"); - if (SES_ScheduleReq(req)) + if (SES_ScheduleReq(req)) { + /* + * In case of overloads, we ditch the entire + * waiting list. + */ + while (1) { + AN (req->vcl); + VCL_Rel(&req->vcl); + sp = req->sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CNT_AcctLogCharge(ds, req); + SES_ReleaseReq(req); + SES_Delete(sp, SC_OVERLOAD, NAN); + req = VTAILQ_FIRST(&wl->list); + if (req == NULL) + break; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + VTAILQ_REMOVE(&wl->list, req, w_list); + DSL(DBG_WAITINGLIST, req->vsl->wid, + "kill from waiting list"); + } break; + } } if (VTAILQ_EMPTY(&wl->list)) { oh->waitinglist = NULL; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 4ba15b6..f162e8e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -234,14 +234,7 @@ SES_ScheduleReq(struct req *req) sp->task.func = ses_req_pool_task; sp->task.priv = req; - if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) { - AN (req->vcl); - VCL_Rel(&req->vcl); - SES_ReleaseReq(req); - SES_Delete(sp, SC_OVERLOAD, NAN); - return (1); - } - return (0); + return (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)); } /*-------------------------------------------------------------------- From lkarsten at varnish-software.com Mon Jan 19 15:21:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 19 Jan 2015 16:21:20 +0100 Subject: [4.0] 51cee0b Don't attempt to run the fetch in the request thread if there are no threads available in the pool, fail the fetch and count it. Message-ID: commit 51cee0bff0072ef2d2b39be77b92f475694540d4 Author: Martin Blix Grydeland Date: Tue Nov 18 13:58:29 2014 +0100 Don't attempt to run the fetch in the request thread if there are no threads available in the pool, fail the fetch and count it. Fixes #1620 Fixes #1621 (cherry picked from commit 969674dcb3b4d430a38b7f1b1e41199b25cc8491) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9478edc..18c937d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -952,9 +952,13 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo->fetch_task.priv = bo; bo->fetch_task.func = vbf_fetch_thread; - if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT)) - vbf_fetch_thread(wrk, bo); - if (mode == VBF_BACKGROUND) { + if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT)) { + wrk->stats.fetch_no_thread++; + (void)vbf_stp_fail(req->wrk, bo); + if (bo->ims_obj != NULL) + (void)HSH_DerefObj(&wrk->stats, &bo->ims_obj); + VBO_DerefBusyObj(wrk, &bo); + } else if (mode == VBF_BACKGROUND) { VBO_waitstate(bo, BOS_REQ_DONE); } else { VBO_waitstate(bo, BOS_STREAM); diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index f93a86f..02e051c 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -237,8 +237,12 @@ VSC_F(fetch_304, uint64_t, 1, 'c', info, "beresp with no body because of 304 response." ) VSC_F(fetch_failed, uint64_t, 1, 'c', info, - "Fetch body failed", - "beresp body fetch failed." + "Fetch failed (all causes)", + "beresp fetch failed." +) +VSC_F(fetch_no_thread, uint64_t, 1, 'c', info, + "Fetch failed (no thread)", + "beresp fetch failed, no thread available." ) /*--------------------------------------------------------------------- From lkarsten at varnish-software.com Mon Jan 19 15:38:36 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 19 Jan 2015 16:38:36 +0100 Subject: [4.0] 653a9ea Keep the fetch thread busyobj pointer-ref separate from the client thread pointer-ref, and deref it on thread scheduling failure. Message-ID: commit 653a9ea1af81fdcdf16c34f7d910da6a77400132 Author: Martin Blix Grydeland Date: Tue Nov 18 13:12:58 2014 +0100 Keep the fetch thread busyobj pointer-ref separate from the client thread pointer-ref, and deref it on thread scheduling failure. The code tried to deref the same pointer twice, which failed because the VBO_DerefBusyobj() will clear the pointer when called. Separating allows calling VBO_DerefBusyobj() for each of them. Fixes: #1628 (cherry picked from commit 7746e30e2c53cf55f0f2525bb3f49c9ee83e9611) Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 18c937d..f87c1bd 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -896,7 +896,7 @@ void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, struct object *oldobj, enum vbf_fetch_mode_e mode) { - struct busyobj *bo; + struct busyobj *bo, *bo_fetch; const char *how; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -920,6 +920,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, VSLb(req->vsl, SLT_Link, "bereq %u %s", bo->vsl->wid & VSL_IDENTMASK, how); + bo_fetch = bo; bo->refcount = 2; oc->busyobj = bo; @@ -949,7 +950,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, AZ(bo->req); bo->req = req; - bo->fetch_task.priv = bo; + bo->fetch_task.priv = bo_fetch; bo->fetch_task.func = vbf_fetch_thread; if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT)) { @@ -957,17 +958,21 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, (void)vbf_stp_fail(req->wrk, bo); if (bo->ims_obj != NULL) (void)HSH_DerefObj(&wrk->stats, &bo->ims_obj); - VBO_DerefBusyObj(wrk, &bo); - } else if (mode == VBF_BACKGROUND) { - VBO_waitstate(bo, BOS_REQ_DONE); + VBO_DerefBusyObj(wrk, &bo_fetch); } else { - VBO_waitstate(bo, BOS_STREAM); - if (bo->state == BOS_FAILED) { - AN((oc->flags & OC_F_FAILED)); + bo_fetch = NULL; /* ref transferred to fetch thread */ + if (mode == VBF_BACKGROUND) { + VBO_waitstate(bo, BOS_REQ_DONE); } else { - AZ(bo->fetch_objcore->flags & OC_F_BUSY); + VBO_waitstate(bo, BOS_STREAM); + if (bo->state == BOS_FAILED) { + AN((oc->flags & OC_F_FAILED)); + } else { + AZ(bo->fetch_objcore->flags & OC_F_BUSY); + } } } + AZ(bo_fetch); VSLb_ts_req(req, "Fetch", W_TIM_real(wrk)); VBO_DerefBusyObj(wrk, &bo); THR_SetBusyobj(NULL); From phk at FreeBSD.org Mon Jan 19 16:29:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 17:29:27 +0100 Subject: [master] 5dd5f9d Miniobj-ify the compiled backend and probe structs Message-ID: commit 5dd5f9ddf4e23fe80edc2b83e4b353bdda2ac04b Author: Poul-Henning Kamp Date: Mon Jan 19 16:19:38 2015 +0000 Miniobj-ify the compiled backend and probe structs diff --git a/include/vrt.h b/include/vrt.h index c30696a..3e3589e 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -140,20 +140,24 @@ extern const void * const vrt_magic_string_end; extern const void * const vrt_magic_string_unset; struct vrt_backend_probe { - const char *url; - const char *request; - double timeout; - double interval; - unsigned exp_status; - unsigned window; - unsigned threshold; - unsigned initial; + unsigned magic; +#define VRT_BACKEND_PROBE_MAGIC 0x84998490 + const char *url; + const char *request; + double timeout; + double interval; + unsigned exp_status; + unsigned window; + unsigned threshold; + unsigned initial; }; /* * A backend is a host+port somewhere on the network */ struct vrt_backend { + unsigned magic; +#define VRT_BACKEND_MAGIC 0x4799ce6b const char *vcl_name; const char *ipv4_addr; const char *ipv6_addr; diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index f6026ef..800f3af 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -126,6 +126,7 @@ vcc_ParseProbeSpec(struct vcc *tl) status = 0; Fh(tl, 0, "static const struct vrt_backend_probe vgc_probe__%d = {\n", tl->nprobe++); + Fh(tl, 0, "\t.magic = VRT_BACKEND_PROBE_MAGIC,\n"); while (tl->t->tok != '}') { vcc_IsField(tl, &t_field, fs); @@ -305,6 +306,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be) Fb(tl, 0, "\nstatic const struct vrt_backend vgc_dir_priv_%s = {\n", vgcname); + Fb(tl, 0, "\t.magic = VRT_BACKEND_MAGIC,\n"); Fb(tl, 0, "\t.vcl_name = \"%.*s", PF(t_be)); Fb(tl, 0, "\",\n"); From phk at FreeBSD.org Mon Jan 19 16:29:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 19 Jan 2015 17:29:27 +0100 Subject: [master] dcdb236 Do away with the dedicated vbe_dir structure by giving director two private members. Message-ID: commit dcdb236c4fcd6e4743a3875cbbe8b5d6914f228d Author: Poul-Henning Kamp Date: Mon Jan 19 16:28:47 2015 +0000 Do away with the dedicated vbe_dir structure by giving director two private members. Check the now miniobj-ified structs from VCC. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 2c85d29..3e1b1bf 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -43,14 +43,6 @@ #include "cache_director.h" #include "vrt.h" -struct vbe_dir { - unsigned magic; -#define VDI_SIMPLE_MAGIC 0x476d25b7 - struct director dir; - struct backend *backend; - const struct vrt_backend *vrt; -}; - #define FIND_TMO(tmx, dst, bo, be) \ do { \ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ @@ -89,16 +81,15 @@ VBE_Healthy(const struct backend *backend, double *changed) static int __match_proto__(vdi_getfd_f) vbe_dir_getfd(const struct director *d, struct busyobj *bo) { - struct vbe_dir *vs; struct vbc *vc; struct backend *bp; double tmod; + const struct vrt_backend *vrt; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - bp = vs->backend; - CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); + CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); + CAST_OBJ_NOTNULL(vrt, d->priv2, VRT_BACKEND_MAGIC); if (!VBE_Healthy(bp, NULL)) { // XXX: per backend stats ? @@ -106,14 +97,14 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) return (-1); } - if (vs->vrt->max_connections > 0 && - bp->n_conn >= vs->vrt->max_connections) { + if (vrt->max_connections > 0 && + bp->n_conn >= vrt->max_connections) { // XXX: per backend stats ? VSC_C_main->backend_busy++; return (-1); } - FIND_TMO(connect_timeout, tmod, bo, vs->vrt); + FIND_TMO(connect_timeout, tmod, bo, vrt); vc = VBT_Get(bp->tcp_pool, tmod); if (vc == NULL) { // XXX: Per backend stats ? @@ -140,9 +131,9 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) bo->htc->vbc = vc; bo->htc->fd = vc->fd; FIND_TMO(first_byte_timeout, - bo->htc->first_byte_timeout, bo, vs->vrt); + bo->htc->first_byte_timeout, bo, vrt); FIND_TMO(between_bytes_timeout, - bo->htc->between_bytes_timeout, bo, vs->vrt); + bo->htc->between_bytes_timeout, bo, vrt); return (vc->fd); } @@ -150,14 +141,11 @@ static unsigned __match_proto__(vdi_healthy_f) vbe_dir_healthy(const struct director *d, const struct busyobj *bo, double *changed) { - struct vbe_dir *vs; struct backend *be; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - be = vs->backend; - CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); + CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); return (VBE_Healthy(be, changed)); } @@ -197,12 +185,12 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, struct busyobj *bo) { int i; - struct vbe_dir *vs; + const struct vrt_backend *vrt; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + CAST_OBJ_NOTNULL(vrt, d->priv2, VRT_BACKEND_MAGIC); i = vbe_dir_getfd(d, bo); if (i < 0) { @@ -211,7 +199,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, } AN(bo->htc); - i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr); + i = V1F_fetch_hdr(wrk, bo, vrt->hosthdr); /* * If we recycle a backend connection, there is a finite chance * that the backend closed it before we get a request to it. @@ -229,7 +217,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, return (-1); } AN(bo->htc); - i = V1F_fetch_hdr(wrk, bo, vs->vrt->hosthdr); + i = V1F_fetch_hdr(wrk, bo, vrt->hosthdr); } if (i != 0) { vbe_dir_finish(d, wrk, bo); @@ -274,71 +262,76 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) void VRT_init_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) { - struct vbe_dir *vs; + struct director *d; + struct backend *be; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(dp); AZ(*dp); - - 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, vrt->vcl_name); - vs->dir.http1pipe = vbe_dir_http1pipe; - vs->dir.healthy = vbe_dir_healthy; - vs->dir.gethdrs = vbe_dir_gethdrs; - vs->dir.getbody = vbe_dir_getbody; - vs->dir.finish = vbe_dir_finish; - - vs->vrt = vrt; - - vs->backend = VBE_AddBackend(NULL, vrt); - if (vs->vrt->probe != NULL) - VBP_Insert(vs->backend, vrt->probe, vrt->hosthdr); - - *dp = &vs->dir; + CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC); + + be = VBE_AddBackend(NULL, vrt); + AN(be); + ALLOC_OBJ(d, DIRECTOR_MAGIC); + XXXAN(d); + d->priv = be; + d->priv2 = vrt; + d->name = "backend"; + REPLACE(d->vcl_name, vrt->vcl_name); + d->http1pipe = vbe_dir_http1pipe; + d->healthy = vbe_dir_healthy; + d->gethdrs = vbe_dir_gethdrs; + d->getbody = vbe_dir_getbody; + d->finish = vbe_dir_finish; + + if (vrt->probe != NULL) + VBP_Insert(be, vrt->probe, vrt->hosthdr); + + *dp = d; } void VRT_use_vbe(VRT_CTX, const struct director *d, const struct vrt_backend *vrt) { - struct vbe_dir *vs; + struct backend *be; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC); + assert(d->priv2 == vrt); + + CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); if (vrt->probe == NULL) return; - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - - VBP_Use(vs->backend, vrt->probe); + VBP_Use(be, vrt->probe); } void VRT_fini_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt) { - struct vbe_dir *vs; struct director *d; + struct backend *be; ASSERT_CLI(); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(dp); + AN(*dp); + CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC); d = *dp; *dp = NULL; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); + assert(d->priv2 == vrt); + CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); - if (vs->vrt->probe != NULL) - VBP_Remove(vs->backend, vrt->probe); + if (vrt->probe != NULL) + VBP_Remove(be, vrt->probe); - VBE_DropRefVcl(vs->backend); - free(vs->dir.vcl_name); - vs->dir.magic = 0; - FREE_OBJ(vs); + VBE_DropRefVcl(be); + free(d->vcl_name); + FREE_OBJ(d); } diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c index 319b23b..4fc7163 100644 --- a/bin/varnishd/cache/cache_backend_poll.c +++ b/bin/varnishd/cache/cache_backend_poll.c @@ -463,7 +463,8 @@ VBP_Insert(struct backend *b, const struct vrt_backend_probe *p, unsigned u; ASSERT_CLI(); - AN(p); + CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); + CHECK_OBJ_NOTNULL(p, VRT_BACKEND_PROBE_MAGIC); if (b->probe == NULL) { ALLOC_OBJ(vt, VBP_TARGET_MAGIC); @@ -504,8 +505,8 @@ VBP_Use(const struct backend *b, const struct vrt_backend_probe *p) struct vbp_vcl *vcl; ASSERT_CLI(); - AN(p); CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); + CHECK_OBJ_NOTNULL(p, VRT_BACKEND_PROBE_MAGIC); AN(b->probe); vt = b->probe; @@ -531,6 +532,7 @@ VBP_Remove(struct backend *b, struct vrt_backend_probe const *p) ASSERT_CLI(); AN(p); CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); + CHECK_OBJ_NOTNULL(p, VRT_BACKEND_PROBE_MAGIC); AN(b->probe); vt = b->probe; diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 49611ab..6744ff1 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -71,6 +71,7 @@ struct director { vdi_getbody_f *getbody; vdi_finish_f *finish; void *priv; + const void *priv2; }; /* cache_director.c */ From fgsch at lodoss.net Tue Jan 20 10:28:47 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 20 Jan 2015 11:28:47 +0100 Subject: [master] e8bfec1 Improve std.syslog documentation and example Message-ID: commit e8bfec127190ae41b138630cba15bef114635680 Author: Federico G. Schwindt Date: Tue Jan 20 10:28:13 2015 +0000 Improve std.syslog documentation and example diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index a93721b..b84fdaf 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -77,18 +77,22 @@ Example $Function VOID log(STRING_LIST s) Description - Logs the string *s* to the shared memory log, using VSL tag *SLT_VCL_Log*. + Logs the string *s* to the shared memory log, using VSL tag + *SLT_VCL_Log*. Example std.log("Something fishy is going on with the vhost " + req.host); $Function VOID syslog(INT priority, STRING_LIST s) Description - Logs the string *s* to syslog marked with *priority*. See your - system's syslog.h file for the legal values of *priority*. + Logs the string *s* to syslog marked with *priority*. *priority* + is formed by ORing the facility and priority values. See your + system's syslog.h file for priorities and facility codes. Example std.syslog(8 + 1, "Something is wrong"); + This will send a message to syslog using LOG_USER | LOG_PID. + $Function STRING fileread(PRIV_CALL, STRING) Description From fgsch at lodoss.net Tue Jan 20 10:53:49 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 20 Jan 2015 11:53:49 +0100 Subject: [master] 3f2c0b0 Rework some examples Message-ID: commit 3f2c0b0cb4508fc1de578814df969593dea83157 Author: Federico G. Schwindt Date: Tue Jan 20 10:52:54 2015 +0000 Rework some examples diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index b84fdaf..1d04f0a 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -58,13 +58,14 @@ Example $Function VOID set_ip_tos(INT tos) Description - Sets the IP type-of-service (TOS) field for the current session to *tos*. + Sets the IP type-of-service (TOS) field for the current session + to *tos*. Please note that the TOS field is not removed by the end of the request so probably want to set it on every request should you utilize it. Example | if (req.url ~ ^/slow/) { - | std.set_ip_tos(0x0); + | std.set_ip_tos(0x0); | } $Function REAL random(REAL lo, REAL hi) @@ -89,7 +90,7 @@ Description is formed by ORing the facility and priority values. See your system's syslog.h file for priorities and facility codes. Example - std.syslog(8 + 1, "Something is wrong"); + std.syslog(9, "Something is wrong"); This will send a message to syslog using LOG_USER | LOG_PID. @@ -129,7 +130,7 @@ Description Converts the string *s* to an integer. If conversion fails, *fallback* will be returned. Example - | if (std.integer(beresp.http.x-foo, 0) > 5) { + | if (std.integer(req.http.x-foo, 0) > 5) { | ... | } @@ -150,7 +151,9 @@ Description Converts the string *s* to a real. If conversion fails, *fallback* will be returned. Example - set req.http.x-real = std.real(req.http.x-foo, 0.0); + | if (std.real(req.http.x-foo, 0.0) > 5.5) { + | ... + | } $Function TIME real2time(REAL r) @@ -231,6 +234,9 @@ Example | ... | } + This will check if the content of req.http.x-restrict occurs + anywhere in req.url. + $Function TIME time(STRING s, TIME fallback) Description From fgsch at lodoss.net Tue Jan 20 11:40:27 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 20 Jan 2015 12:40:27 +0100 Subject: [master] 4776a39 Fix example Message-ID: commit 4776a39fa7d93f1aace0d3a1e69ad2c59dc4a3e5 Author: Federico G. Schwindt Date: Tue Jan 20 11:39:32 2015 +0000 Fix example Spotted by Kristian. diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 1d04f0a..487e52d 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -92,7 +92,7 @@ Description Example std.syslog(9, "Something is wrong"); - This will send a message to syslog using LOG_USER | LOG_PID. + This will send a message to syslog using LOG_USER | LOG_ALERT. $Function STRING fileread(PRIV_CALL, STRING) From martin at varnish-software.com Tue Jan 20 13:38:44 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 20 Jan 2015 14:38:44 +0100 Subject: [4.0] b661f7e Don't attempt range delivery on a synth response Message-ID: commit b661f7e9f2a4aab29d0f16f11a0aa27513afb63c Author: Martin Blix Grydeland Date: Tue Jan 20 14:14:52 2015 +0100 Don't attempt range delivery on a synth response This could happen on a 200 synth object if the client request had a Range header. The range code path would fail because it requires an obj which the synth path doesn't have. Fixes: #1660 diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index dcb290f..e0a9618 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -358,7 +358,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo) void V1D_Deliver_Synth(struct req *req) { - char *r; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AZ(req->obj); @@ -395,16 +394,6 @@ V1D_Deliver_Synth(struct req *req) req->vdps[0] = v1d_bytes; req->vdp_nxt = 0; - if ( - req->wantbody && - !(req->res_mode & RES_ESI_CHILD) && - cache_param->http_range_support && - http_GetStatus(req->resp) == 200) { - http_SetHeader(req->resp, "Accept-Ranges: bytes"); - if (http_GetHdr(req->http, H_Range, &r)) - v1d_dorange(req, NULL, r); - } - WRW_Reserve(req->wrk, &req->sp->fd, req->vsl, req->t_prev); /* diff --git a/bin/varnishtest/tests/r01660.vtc b/bin/varnishtest/tests/r01660.vtc new file mode 100644 index 0000000..1ce133c --- /dev/null +++ b/bin/varnishtest/tests/r01660.vtc @@ -0,0 +1,18 @@ +varnishtest "#1660: range and synth" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (synth(200, "OK")); + } +} -start + +client c1 { + txreq -hdr "Range: 0-1" + rxresp + expect resp.status == 200 +} -run From phk at FreeBSD.org Wed Jan 21 08:35:53 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 21 Jan 2015 09:35:53 +0100 Subject: [master] d034148 Add the scaffolding for destroying waiters, now I just need to make it also work. Message-ID: commit d03414855ed325464db5e42faeb7d62ed113b3d9 Author: Poul-Henning Kamp Date: Wed Jan 21 08:35:22 2015 +0000 Add the scaffolding for destroying waiters, now I just need to make it also work. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 4f71f96..1629625 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -112,6 +112,8 @@ Wait_New(waiter_handle_f *func, volatile double *tmo) Lck_Lock(&wait_mtx); VTAILQ_INSERT_TAIL(&waiters, w, list); nwaiters++; + + /* We assume all waiters either use pipes or don't use pipes */ if (w->pipes[1] >= 0 && nwaiters == 1) AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL)); Lck_Unlock(&wait_mtx); @@ -119,6 +121,19 @@ Wait_New(waiter_handle_f *func, volatile double *tmo) } void +Wait_Destroy(struct waiter **wp) +{ + struct waiter *w; + + AN(wp); + w = *wp; + *wp = NULL; + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + AN(w->impl->fini); + w->impl->fini(w); +} + +void Wait_UsePipe(struct waiter *w) { CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index ee4b6bc..8b52b6b 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -58,6 +58,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now); /* cache_waiter.c */ int Wait_Enter(const struct waiter *, struct waited *); struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout); +void Wait_Destroy(struct waiter **); const char *Wait_GetName(void); void Wait_Init(void); diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 14b5e6f..f18dd7e 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -50,6 +50,7 @@ struct waiter { }; typedef void waiter_init_f(struct waiter *); +typedef void waiter_fini_f(struct waiter *); typedef int waiter_pass_f(void *priv, struct waited *); typedef void waiter_inject_f(const struct waiter *, struct waited *); typedef void waiter_evict_f(const struct waiter *, struct waited *); @@ -57,6 +58,7 @@ typedef void waiter_evict_f(const struct waiter *, struct waited *); struct waiter_impl { const char *name; waiter_init_f *init; + waiter_fini_f *fini; waiter_pass_f *pass; waiter_inject_f *inject; waiter_evict_f *evict; From phk at FreeBSD.org Wed Jan 21 09:35:26 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 21 Jan 2015 10:35:26 +0100 Subject: [master] ef6918d Attempt to implement waiter destruction in kqueue and poll waiters. Message-ID: commit ef6918d6ece269e10fc65a242afe8c17f272fc24 Author: Poul-Henning Kamp Date: Wed Jan 21 09:35:04 2015 +0000 Attempt to implement waiter destruction in kqueue and poll waiters. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 822c0a2..96ae0a3 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -272,6 +272,8 @@ ses_handle(struct waited *wp, enum wait_event ev, double now) if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) SES_Delete(sp, SC_OVERLOAD, now); break; + case WAITER_CLOSE: + WRONG("Should not see WAITER_CLOSE on client side"); default: WRONG("Wrong event in ses_handle"); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 1629625..db0ef8a 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -124,13 +124,42 @@ void Wait_Destroy(struct waiter **wp) { struct waiter *w; + struct waited *wx = NULL; + int written; + double now; AN(wp); w = *wp; *wp = NULL; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + + Lck_Lock(&wait_mtx); + VTAILQ_REMOVE(&waiters, w, list); + w->dismantle = 1; + Lck_Unlock(&wait_mtx); + + if (w->pipes[1] >= 0) { + while (1) { + written = write(w->pipes[1], &wx, sizeof wx); + if (written == sizeof wx) + break; + (void)usleep(10000); + } + } AN(w->impl->fini); w->impl->fini(w); + now = VTIM_real(); + while (1) { + wx = VTAILQ_FIRST(&w->waithead); + if (wx == NULL) + break; + VTAILQ_REMOVE(&w->waithead, wx, list); + if (wx == w->pipe_w) + FREE_OBJ(wx); + else + w->func(wx, WAITER_CLOSE, now); + } + FREE_OBJ(w); } void @@ -157,6 +186,7 @@ Wait_Enter(const struct waiter *w, struct waited *wp) CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); assert(wp->fd >= 0); + AZ(w->dismantle); if (w->impl->pass != NULL) return (w->impl->pass(w->priv, wp)); @@ -218,11 +248,13 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); if (ss[j] == w->pipe_w) { dotimer = 1; - continue; + } else if (ss[j] == NULL) { + AN(w->dismantle); + } else { + assert(ss[j]->fd >= 0); + VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); + w->impl->inject(w, ss[j]); } - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); - w->impl->inject(w, ss[j]); } AZ(i); diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 9bb7295..7ded624 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -57,7 +57,7 @@ struct vwe { #define VWE_MAGIC 0x6bd73424 struct waiter *waiter; - pthread_t epoll_thread; + pthread_t thread; int epfd; }; @@ -113,7 +113,7 @@ vwe_thread(void *priv) THR_SetName("cache-epoll"); - while (1) { + while (!vew->waiter->dismantle) { n = epoll_wait(vwe->epfd, ev, NEEV, -1); now = VTIM_real(); for (ep = ev, i = 0; i < n; i++, ep++) @@ -139,7 +139,21 @@ vwe_init(struct waiter *w) Wait_UsePipe(w); - AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe)); + AZ(pthread_create(&vwe->thread, NULL, vwe_thread, vwe)); +} + +/*--------------------------------------------------------------------*/ + +static void __match_proto__(waiter_fini_f) +vwe_fini(struct waiter *w) +{ + struct vwe *vwe; + void *vp; + + CAST_OBJ_NOTNULL(vwe, w->priv, VWE_MAGIC); + + AZ(pthread_join(vwe->thread, &vp)); + WRONG("Not Yet Implemented"); } /*--------------------------------------------------------------------*/ @@ -147,6 +161,7 @@ vwe_init(struct waiter *w) const struct waiter_impl waiter_epoll = { .name = "epoll", .init = vwe_init, + .fini = vwe_fini, .inject = vwe_inject, .size = sizeof(struct vwe), }; diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 8609048..d371d7e 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -133,13 +133,10 @@ vwk_thread(void *priv) CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); THR_SetName("cache-kqueue"); - vwk->kq = kqueue(); - assert(vwk->kq >= 0); - vwk_kq_flush(vwk); vwk->nki = 0; - while (1) { + while (!vwk->waiter->dismantle) { n = kevent(vwk->kq, vwk->ki, vwk->nki, ke, NKEV, NULL); assert(n <= NKEV); if (n == 0) { @@ -168,6 +165,9 @@ vwk_init(struct waiter *w) INIT_OBJ(vwk, VWK_MAGIC); vwk->waiter = w; + vwk->kq = kqueue(); + assert(vwk->kq >= 0); + Wait_UsePipe(w); AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); @@ -175,9 +175,23 @@ vwk_init(struct waiter *w) /*--------------------------------------------------------------------*/ +static void __match_proto__(waiter_fini_f) +vwk_fini(struct waiter *w) +{ + struct vwk *vwk; + void *vp; + + CAST_OBJ_NOTNULL(vwk, w->priv, VWK_MAGIC); + AZ(pthread_join(vwk->thread, &vp)); + AZ(close(vwk->kq)); +} + +/*--------------------------------------------------------------------*/ + const struct waiter_impl waiter_kqueue = { .name = "kqueue", .init = vwk_init, + .fini = vwk_fini, .inject = vwk_inject, .size = sizeof(struct vwk), }; diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 48c3cd7..81763a1 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -45,7 +45,7 @@ struct vwp { #define VWP_MAGIC 0x4b2cc735 struct waiter *waiter; - pthread_t poll_thread; + pthread_t thread; struct pollfd *pollfd; unsigned npoll; unsigned hpoll; @@ -137,7 +137,7 @@ vwp_main(void *priv) CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); THR_SetName("cache-poll"); - while (1) { + while (!vwp->waiter->dismantle) { assert(vwp->hpoll < vwp->npoll); while (vwp->hpoll > 0 && vwp->pollfd[vwp->hpoll].fd == -1) vwp->hpoll--; @@ -172,7 +172,7 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ static void __match_proto__(waiter_init_f) -vwp_poll_init(struct waiter *w) +vwp_init(struct waiter *w) { struct vwp *vwp; @@ -183,14 +183,28 @@ vwp_poll_init(struct waiter *w) vwp_pollspace(vwp, 256); Wait_UsePipe(w); - AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); + AZ(pthread_create(&vwp->thread, NULL, vwp_main, vwp)); +} + +/*--------------------------------------------------------------------*/ + +static void __match_proto__(waiter_fini_f) +vwp_fini(struct waiter *w) +{ + struct vwp *vwp; + void *vp; + + CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); + AZ(pthread_join(vwp->thread, &vp)); + free(vwp->pollfd); } /*--------------------------------------------------------------------*/ const struct waiter_impl waiter_poll = { .name = "poll", - .init = vwp_poll_init, + .init = vwp_init, + .fini = vwp_fini, .inject = vwp_inject, .evict = vwp_evict, .size = sizeof(struct vwp), diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 158a624..5ba8a8a 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -53,7 +53,7 @@ struct vws { #define VWS_MAGIC 0x0b771473 struct waiter *waiter; - pthread_t ports_thread; + pthread_t thread; int dport; }; @@ -150,7 +150,7 @@ vws_thread(void *priv) timeout = &max_ts; - while (1) { + while (!vws->waiter->dismantle) { port_event_t ev[MAX_EVENTS]; u_int nevents; int ei, ret; @@ -259,7 +259,20 @@ vws_init(struct waiter *w) INIT_OBJ(vws, VWS_MAGIC); vws->waiter = w; - AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws)); + AZ(pthread_create(&vws->thread, NULL, vws_thread, vws)); +} + +/*--------------------------------------------------------------------*/ + +static void __match_proto__(waiter_fini_f) +vws_fini(struct waiter *w) +{ + struct vws *vwe; + void *vp; + + CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC); + AZ(pthread_join(vwp->thread, &vp)); + WRONG("Not Yet Implemented"); } /*--------------------------------------------------------------------*/ @@ -267,6 +280,7 @@ vws_init(struct waiter *w) const struct waiter_impl waiter_ports = { .name = "ports", .init = vws_init, + .fini = vws_fini, .pass = vws_pass, .size = sizeof(struct vws), }; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 8b52b6b..953df8e 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -48,7 +48,8 @@ struct waiter; enum wait_event { WAITER_REMCLOSE, WAITER_TIMEOUT, - WAITER_ACTION + WAITER_ACTION, + WAITER_CLOSE }; #define WAITER_DEFAULT "platform dependent" diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index f18dd7e..d83d369 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -36,6 +36,7 @@ struct waiter { #define WAITER_MAGIC 0x17c399db const struct waiter_impl *impl; VTAILQ_ENTRY(waiter) list; + int dismantle; waiter_handle_f * func; From phk at FreeBSD.org Wed Jan 21 10:06:26 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 21 Jan 2015 11:06:26 +0100 Subject: [master] ab09f23 typo Message-ID: commit ab09f23be96558b07ca1ecbe9d4352a07054af60 Author: Poul-Henning Kamp Date: Wed Jan 21 10:06:21 2015 +0000 typo diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 7ded624..f7f1edb 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -113,7 +113,7 @@ vwe_thread(void *priv) THR_SetName("cache-epoll"); - while (!vew->waiter->dismantle) { + while (!vwe->waiter->dismantle) { n = epoll_wait(vwe->epfd, ev, NEEV, -1); now = VTIM_real(); for (ep = ev, i = 0; i < n; i++, ep++) From phk at FreeBSD.org Wed Jan 21 10:25:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 21 Jan 2015 11:25:27 +0100 Subject: [master] 500c656 More typos Message-ID: commit 500c6565390f6ce653d0cbac1f0e7f15cd780459 Author: Poul-Henning Kamp Date: Wed Jan 21 10:25:14 2015 +0000 More typos diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 5ba8a8a..91ddf48 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -267,11 +267,11 @@ vws_init(struct waiter *w) static void __match_proto__(waiter_fini_f) vws_fini(struct waiter *w) { - struct vws *vwe; + struct vws *vws; void *vp; CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC); - AZ(pthread_join(vwp->thread, &vp)); + AZ(pthread_join(vws->thread, &vp)); WRONG("Not Yet Implemented"); } From martin at varnish-software.com Wed Jan 21 15:23:20 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 21 Jan 2015 16:23:20 +0100 Subject: [master] 336f2eb Correctly account for the entire terminator space needed when checking vary length Message-ID: commit 336f2eb8fe1c8f46dbf32a9bad387171eee69c85 Author: Martin Blix Grydeland Date: Wed Jan 21 16:03:25 2015 +0100 Correctly account for the entire terminator space needed when checking vary length diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 492af99..8424223 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -321,7 +321,7 @@ VRY_Match(struct req *req, const uint8_t *vary) lh = 0xffff; } - if (vsp + ln + 2 >= req->vary_e) { + if (vsp + ln + 3 >= req->vary_e) { /* * Not enough space to build new entry * and put terminator behind it. From phk at FreeBSD.org Thu Jan 22 09:15:18 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 22 Jan 2015 10:15:18 +0100 Subject: [master] 738a138 Add a pointless break for Coveritys sake Message-ID: commit 738a1385a64b416ff9815c94b878ef81bd37b9a5 Author: Poul-Henning Kamp Date: Thu Jan 22 09:14:47 2015 +0000 Add a pointless break for Coveritys sake diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 96ae0a3..7992834 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -274,6 +274,7 @@ ses_handle(struct waited *wp, enum wait_event ev, double now) break; case WAITER_CLOSE: WRONG("Should not see WAITER_CLOSE on client side"); + break; default: WRONG("Wrong event in ses_handle"); } From fgsch at lodoss.net Thu Jan 22 15:21:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 22 Jan 2015 16:21:11 +0100 Subject: [master] bab3db5 Fix typo Message-ID: commit bab3db55cb66c063ff3a319f5ad50b4850121e31 Author: Federico G. Schwindt Date: Thu Jan 22 15:21:13 2015 +0000 Fix typo Spotted by: scn diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 487e52d..93ef0b7 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -81,7 +81,7 @@ Description Logs the string *s* to the shared memory log, using VSL tag *SLT_VCL_Log*. Example - std.log("Something fishy is going on with the vhost " + req.host); + std.log("Something fishy is going on with the vhost " + req.http.host); $Function VOID syslog(INT priority, STRING_LIST s) From lkarsten at varnish-software.com Thu Jan 22 15:45:33 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:33 +0100 Subject: [4.0] d4152ea Sync with reality Message-ID: commit d4152ea12db762b85628b81d64c805146293b6fe Author: Federico G. Schwindt Date: Fri Jan 16 15:06:20 2015 +0000 Sync with reality This updates the last oustanding document to 4.0 Conflicts: doc/sphinx/users-guide/operation-logging.rst diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index 4dfa40f..d3e715c 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -20,13 +20,13 @@ is logging. `varnishlog` gives you the raw logs, everything that is written to the logs. There are other clients that can access the logs as well, we'll show you these later. -In the terminal window you started Varnish now type ``varnishlog`` and -press enter. +In the terminal window you started Varnish now type ``varnishlog -g raw`` +and press enter. You'll see lines like these scrolling slowly by.:: - 0 CLI - Rd ping - 0 CLI - Wr 200 PONG 1273698726 1.0 + 0 CLI - Rd ping + 0 CLI - Wr 200 19 PONG 1273698726 1.0 These is the Varnish master process checking up on the caching process to see that everything is OK. @@ -37,25 +37,24 @@ app. You'll see lines like these.:: - 11 SessionOpen c 127.0.0.1 58912 0.0.0.0:8080 - 11 ReqStart c 127.0.0.1 58912 595005213 - 11 RxRequest c GET - 11 RxURL c / - 11 RxProtocol c HTTP/1.1 - 11 RxHeader c Host: localhost:8080 - 11 RxHeader c Connection: keep-alive + 11 SessOpen c 127.0.0.1 58912 :8080 0.0.0.0 8080 1273698726.933590 14 + 11 ReqStart c 127.0.0.1 58912 + 11 ReqMethod c GET + 11 ReqURL c / + 11 ReqProtocol c HTTP/1.1 + 11 ReqHeader c Host: localhost:8080 + 11 ReqHeader c Connection: keep-alive The first column is an arbitrary number, it identifies the -session. Lines with the same number are coming from the same session -and are being handled by the same thread. The second column is the -*tag* of the log message. All log entries are tagged with a tag -indicating what sort of activity is being logged. Tags starting with -'Rx' indicate Varnish is receiving data and 'Tx' indicates sending data. +transaction. Lines with the same number are coming from the same +transaction. The second column is the *tag* of the log message. All +log entries are tagged with a tag indicating what sort of activity is +being logged. -The third column tell us whether this is is data coming or going to -the client ('c') or to/from the backend ('b'). The forth column is the -data being logged. +The third column tell us whether this is is data coming from or going +to the client ('c'), or the backend ('b'). The forth column is the data +being logged. Now, you can filter quite a bit with `varnishlog`. The basic options we think you want to know are: @@ -67,9 +66,11 @@ want to know are: '-c' Same as '-b' but for client side traffic. -'-m tag:regex' - Only list transactions where the tag matches a regular expression. If - it matches you will get the whole transaction. +'-g request' + Group transactions by request. + +'-q query' + Only list transactions matching this query. .. XXX:Maybe a couple of sample commands here? benc From lkarsten at varnish-software.com Thu Jan 22 15:45:33 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:33 +0100 Subject: [4.0] de40d3e Install _all_ headers under ${prefix}/include/.. Message-ID: commit de40d3ee2a2f1e6eff33aa9d56e718aaa149f702 Author: Federico G. Schwindt Date: Sat Nov 8 01:47:26 2014 +0000 Install _all_ headers under ${prefix}/include/.. Fixes #1616 Conflicts: bin/varnishd/Makefile.am varnish.m4 diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 402cd0d..8cf16de 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -87,10 +87,9 @@ varnishd_SOURCES = \ waiter/cache_waiter_ports.c noinst_HEADERS = \ - cache/cache_backend.h \ + builtin_vcl.h \ cache/cache_esi.h \ common/heritage.h \ - builtin_vcl.h \ hash/hash_slinger.h \ mgt/mgt.h \ mgt/mgt_cli.h \ @@ -100,8 +99,7 @@ noinst_HEADERS = \ waiter/waiter.h # Headers for use with vmods -pkgdataincludedir = $(pkgdatadir)/include -nobase_pkgdatainclude_HEADERS = \ +nobase_pkginclude_HEADERS = \ cache/cache.h \ cache/cache_backend.h \ common/common.h \ diff --git a/include/Makefile.am b/include/Makefile.am index 96d9663..b7487d6 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -37,6 +37,24 @@ nobase_pkginclude_HEADERS = \ vapi/vapi_options.h \ vcli.h +# Headers for use with vmods +nobase_pkginclude_HEADERS += \ + miniobj.h \ + vas.h \ + vav.h \ + vbm.h \ + vcl.h \ + vcs.h \ + vmod_abi.h \ + vqueue.h \ + vre.h \ + vdef.h \ + vrt.h \ + vrt_obj.h \ + vsa.h \ + vsb.h \ + vsha256.h + # Private headers nobase_noinst_HEADERS = \ binary_heap.h \ @@ -68,25 +86,6 @@ nobase_noinst_HEADERS = \ vut.h \ vut_options.h -# Headers for use with vmods -pkgdataincludedir = $(pkgdatadir)/include -nobase_pkgdatainclude_HEADERS = \ - miniobj.h \ - vas.h \ - vav.h \ - vbm.h \ - vcl.h \ - vcs.h \ - vmod_abi.h \ - vqueue.h \ - vre.h \ - vdef.h \ - vrt.h \ - vrt_obj.h \ - vsa.h \ - vsb.h \ - vsha256.h - tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vcl.h vrt_obj.h: $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl @PYTHON@ $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir) $(top_builddir) diff --git a/varnish.m4 b/varnish.m4 index f4e9e9c..8339cb0 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -58,10 +58,9 @@ variable if you installed software in a non-standard prefix.]) fi ]) -VARNISH_PKG_GET_VAR([VMOD_INCLUDE_DIR], [vmodincludedir]) VARNISH_PKG_GET_VAR([VAPI_INCLUDE_DIR], [pkgincludedir]) _CPPFLAGS="$CPPFLAGS" -VMOD_INCLUDES="-I$VMOD_INCLUDE_DIR -I$VAPI_INCLUDE_DIR" +VMOD_INCLUDES="-I$VAPI_INCLUDE_DIR" CPPFLAGS="$VMOD_INCLUDES $CPPFLAGS" AC_CHECK_HEADERS([vsha256.h cache/cache.h]) CPPFLAGS="$_CPPFLAGS" diff --git a/varnishapi-uninstalled.pc.in b/varnishapi-uninstalled.pc.in index 3a8f744..d252289 100644 --- a/varnishapi-uninstalled.pc.in +++ b/varnishapi-uninstalled.pc.in @@ -8,7 +8,6 @@ pkgincludedir=${includedir}/@PACKAGE@ datarootdir=@datarootdir@ datadir=@datadir@ pkgdatadir=${datadir}/@PACKAGE@ -pkgdataincludedir=${pkgdatadir}/include vmoddir=${libdir}/@PACKAGE@/vmods builddir=@abs_top_builddir@ srcdir=@abs_top_srcdir@ diff --git a/varnishapi.pc.in b/varnishapi.pc.in index 059725e..b2a6e93 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -8,8 +8,6 @@ pkgincludedir=${includedir}/@PACKAGE@ datarootdir=@datarootdir@ datadir=@datadir@ pkgdatadir=${datadir}/@PACKAGE@ -pkgdataincludedir=${pkgdatadir}/include -vmodincludedir=${pkgdataincludedir} vmoddir=${libdir}/@PACKAGE@/vmods vmodtool=${pkgdatadir}/vmodtool.py From lkarsten at varnish-software.com Thu Jan 22 15:45:33 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:33 +0100 Subject: [4.0] ef24169 Fix out-of-tree builds Message-ID: commit ef241692250c35735ce71d0f2715bacd7e192b05 Author: Nils Goroll Date: Mon Sep 29 16:33:32 2014 +0200 Fix out-of-tree builds Fixes #1479 diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 0d681e8..c872ddd 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -10,7 +10,7 @@ BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(srcdir) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(distdir) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest @@ -95,7 +95,6 @@ EXTRA_DIST = \ glossary \ installation \ phk \ - reference \ tutorial \ users-guide \ whats-new @@ -144,11 +143,16 @@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_op BUILT_SOURCES += include/varnishhist_options.rst \ include/varnishhist_synopsis.rst -reference/vmod_std.generated.rst: $(top_srcdir)/lib/libvmod_std/vmod_std.rst +.PHONY: reference +reference: + test -d $@ || mkdir $@ +BUILT_SOURCES += reference + +reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst cp $? $@ BUILT_SOURCES += reference/vmod_std.generated.rst -reference/vmod_directors.generated.rst: $(top_srcdir)/lib/libvmod_directors/vmod_directors.rst +reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst cp $? $@ BUILT_SOURCES += reference/vmod_directors.generated.rst diff --git a/man/Makefile.am b/man/Makefile.am index c7dd1bf..d791d1f 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -86,8 +86,8 @@ varnishhist.1: \ $(top_srcdir)/doc/sphinx/include/varnishhist_synopsis.rst ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ -vmod_std.3: $(top_srcdir)/lib/libvmod_std/vmod_std.man.rst +vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst ${RST2MAN} $(RST2ANY_FLAGS) $? $@ -vmod_directors.3: $(top_srcdir)/lib/libvmod_directors/vmod_directors.man.rst +vmod_directors.3: $(top_builddir)/lib/libvmod_directors/vmod_directors.man.rst ${RST2MAN} $(RST2ANY_FLAGS) $? $@ From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] 42f33cd Minor typo in varnishsizes' -P documentation Message-ID: commit 42f33cd01ab2593c2dc33b670a2b960d90448e72 Author: Tollef Fog Heen Date: Mon Dec 8 14:22:11 2014 +0100 Minor typo in varnishsizes' -P documentation diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index fdd217e..f3223f3 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -47,7 +47,7 @@ #define HIS_OPT_P \ VOPT("P:", "[-P ]", \ "Profile definition", \ - "Either specify \"size\" or \"responstime\" profile or" \ + "Either specify \"size\" or \"responsetime\" profile or" \ " create a new one. Define the tag we'll look for, and the" \ " field number of the value we are interested in. min and" \ " max are the boundaries of the graph (these are power of" \ From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] 0a61894 complete overhaul of vcl-built-in-subs.rst documentation Message-ID: commit 0a61894da5c00f0bab05f932026656376f24c957 Author: Nils Goroll Date: Mon Oct 13 17:13:41 2014 +0200 complete overhaul of vcl-built-in-subs.rst documentation Add missing bits and sync with reality. Relevant fixes: * a synth object is never cached * by a backend_response object may be diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 32f8fbd..cd78355 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -1,44 +1,55 @@ - -.. XXX:This document needs substantional review. - .. _vcl-built-in-subs: +==================== Built in subroutines --------------------- +==================== + +Various built-in subroutines are called during processing of client- +and backend requests as well as upon ``vcl.load`` and ``vcl.discard``. + +See :ref:`reference-states` for a defailed graphical overview of the +states and how they relate to core code functions and VCL subroutines. +----------- +client side +----------- + +.. _vcl_recv: vcl_recv ~~~~~~~~ Called at the beginning of a request, after the complete request has -been received and parsed. Its purpose is to decide whether or not to -serve the request, how to do it, and, if applicable, which backend to -use. +been received and parsed, after a `restart` or as the result of an ESI +include. -It is also used to modify the request, something you'll probably find -yourself doing frequently. +Its purpose is to decide whether or not to serve the request, possibly +modify it and decide on how to process it further. A backend hint may +be set as a default for the backend processing side. The `vcl_recv` subroutine may terminate with calling ``return()`` on one of the following keywords: - synth(status code, reason) - Return a synthetic object with the specified status code to the - client and abandon the request. + ``hash`` + Continue processing the object as a potential candidate for + caching. Passes the control over to :ref:`vcl_hash`. - pass - Switch to pass mode. Control will eventually pass to vcl_pass. + ``pass`` + Switch to pass mode. Control will eventually pass to :ref:`vcl_pass`. - pipe - Switch to pipe mode. Control will eventually pass to vcl_pipe. + ``pipe`` + Switch to pipe mode. Control will eventually pass to :ref:`vcl_pipe`. - hash - Continue processing the object as a potential candidate for - caching. Passes the control over to vcl_hash. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. - purge + ``purge`` Purge the object and it's variants. Control passes through vcl_hash to vcl_purge. +.. _vcl_pipe: + vcl_pipe ~~~~~~~~ @@ -52,12 +63,15 @@ other VCL subroutine will ever get called after `vcl_pipe`. The `vcl_pipe` subroutine may terminate with calling ``return()`` with one of the following keywords: - synth(status code, reason) - Return the specified status code to the client and abandon the request. - - pipe + ``pipe`` Proceed with pipe mode. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. _vcl_pass: + vcl_pass ~~~~~~~~ @@ -69,64 +83,86 @@ submitted over the same client connection are handled normally. The `vcl_pass` subroutine may terminate with calling ``return()`` with one of the following keywords: - synth(status code, reason) - Return the specified status code to the client and abandon the request. + ``fetch`` + Proceed with pass mode - initiate a backend request. - fetch - Proceed with pass mode. - - restart + ``restart`` Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. _vcl_hit: vcl_hit ~~~~~~~ -Called when a cache lookup is successful. +Called when a cache lookup is successful. The object being hit may be +stale: It can have a zero or negative `ttl` with only `grace` or +`keep` time left. The `vcl_hit` subroutine may terminate with calling ``return()`` with one of the following keywords: + ``deliver`` + Deliver the object. If it is stale, a background fetch to refresh + it is triggered. + + ``fetch`` + Synchronously refresh the object from the backend despite the + cache hit. Control will eventually pass to :ref:`vcl_miss`. - restart + ``pass`` + Switch to pass mode. Control will eventually pass to :ref:`vcl_pass`. + + ``restart`` Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. - deliver - Deliver the object. Control passes to `vcl_deliver`. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. - synth(status code, reason) - Return the specified status code to the client and abandon the request. +.. XXX: #1603 hit should not go to miss +.. _vcl_miss: vcl_miss ~~~~~~~~ Called after a cache lookup if the requested document was not found in -the cache. Its purpose is to decide whether or not to attempt to -retrieve the document from the backend, and which backend to use. +the cache or if :ref:`vcl_hit` returned ``fetch``. + +Its purpose is to decide whether or not to attempt to retrieve the +document from the backend. A backend hint may be set as a default for +the backend processing side. The `vcl_miss` subroutine may terminate with calling ``return()`` with one of the following keywords: - synth(status code, reason) - Return the specified status code to the client and abandon the request. - - pass - Switch to pass mode. Control will eventually pass to `vcl_pass`. - - fetch + ``fetch`` Retrieve the requested object from the backend. Control will eventually pass to `vcl_backend_fetch`. - restart + ``pass`` + Switch to pass mode. Control will eventually pass to :ref:`vcl_pass`. + + ``restart`` Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. XXX: #1603 hit should not go to miss + +.. _vcl_hash: vcl_hash ~~~~~~~~ @@ -134,13 +170,18 @@ vcl_hash Called after `vcl_recv` to create a hash value for the request. This is used as a key to look up the object in Varnish. -The `vcl_hash` subroutine may terminate with calling ``return()`` with one -of the following keywords: +The `vcl_hash` subroutine may only terminate with calling ``return(lookup)``: - lookup - Look up the object in cache. Control passes to vcl_miss, vcl_hit - or vcl_purge. + ``lookup`` + Look up the object in cache. + Control passes to :ref:`vcl_purge` when coming from a ``purge`` + return in `vcl_recv`. + Otherwise control passes to :ref:`vcl_hit`, :ref:`vcl_miss` or + :ref:`vcl_pass` if the cache lookup result was a hit, a miss or hit + on a hit-for-pass object (object with ``obj.uncacheable == + true``), respectively. +.. _vcl_purge: vcl_purge ~~~~~~~~~ @@ -150,31 +191,66 @@ Called after the purge has been executed and all its variants have been evited. The `vcl_purge` subroutine may terminate with calling ``return()`` with one of the following keywords: - synth - Produce a response. - - restart + ``restart`` Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. _vcl_deliver: vcl_deliver ~~~~~~~~~~~ -Called before a cached object is delivered to the client. +Called before any object except a `vcl_synth` result is delivered to the client. The `vcl_deliver` subroutine may terminate with calling ``return()`` with one of the following keywords: - deliver + ``deliver`` Deliver the object to the client. - restart + ``restart`` + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation + error. + + ``synth(status code, reason)`` + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. _vcl_synth: + +vcl_synth +~~~~~~~~~ + +Called to deliver a synthetic object. A synthetic object is generated +in VCL, not fetched from the backend. Its body may be contructed using +the ``synthetic()`` function. + +A `vcl_synth` defined object never enters the cache, contrary to a +:ref:`vcl_backend_error` defined object, which may end up in cache. + +The subroutine may terminate with calling ``return()`` with one of the +following keywords: + + ``deliver`` + Directly deliver the object defined by `vcl_synth` to the + client without calling `vcl_deliver`. + + ``restart`` Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. +------------ +Backend Side +------------ + +.. _vcl_backend_fetch: vcl_backend_fetch ~~~~~~~~~~~~~~~~~ @@ -185,67 +261,71 @@ typically alter the request before it gets to the backend. The `vcl_backend_fetch` subroutine may terminate with calling ``return()`` with one of the following keywords: - fetch + ``fetch`` Fetch the object from the backend. - abandon - Abandon the backend request and generates an error. + ``abandon`` + Abandon the backend request. Unless the backend request was a + background fetch, control is passed to :ref:`vcl_synth` on the + client side with ``resp.status`` preset to 503. +.. _vcl_backend_response: vcl_backend_response ~~~~~~~~~~~~~~~~~~~~ -Called after the response headers has been successfully retrieved from +Called after the response headers have been successfully retrieved from the backend. The `vcl_backend_response` subroutine may terminate with calling ``return()`` with one of the following keywords: - deliver - Possibly insert the object into the cache, then deliver it to the - Control will eventually pass to `vcl_deliver`. + ``deliver`` + For a 304 response, create an updated cache object. + Otherwise, fetch the object body from the backend and initiate + delivery to any waiting client requests, possibly in parallel + (streaming). - abandon - Abandon the backend request and generates an error. + ``abandon`` + Abandon the backend request. Unless the backend request was a + background fetch, control is passed to :ref:`vcl_synth` on the + client side with ``resp.status`` preset to 503. - retry + ``retry`` Retry the backend transaction. Increases the `retries` counter. - If the number of retries is higher than *max_retries* Varnish - emits a guru meditation error. + If the number of retries is higher than *max_retries*, + control will be passed to :ref:`vcl_backend_error`. + +.. _vcl_backend_error: vcl_backend_error ~~~~~~~~~~~~~~~~~ -This subroutine is called if we fail the backend fetch. +This subroutine is called if we fail the backend fetch or if +*max_retries* has been exceeded. + +A synthetic object is generated in VCL, whose body may be contructed +using the ``synthetic()`` function. The `vcl_backend_error` subroutine may terminate with calling ``return()`` with one of the following keywords: - deliver - Deliver the error. + ``deliver`` + Deliver and possibly cache the object defined in + `vcl_backend_error` **as if it was fetched from the backend**, also + referred to as a "backend synth". - retry - Retry the backend transaction. Increases the `retries` counter. If - the number of retries is higher than *max_retries* Varnish emits a - guru meditation error. - -vcl_synth -~~~~~~~~~ - -Called to deliver a synthetic object. A synthetic object is generated -in VCL, not fetched from the backend. It is typically contructed using -the synthetic() function. - - -The subroutine may terminate with calling ``return()`` with one of the -following keywords: + ``retry`` + Retry the backend transaction. Increases the `retries` counter. + If the number of retries is higher than *max_retries*, + :ref:`vcl_synth` on the client side is called with ``resp.status`` + preset to 503. - deliver - Deliver the object. If the object has a positive TTL then the - object is also stored in cache. +---------------------- +vcl.load / vcl.discard +---------------------- - restart - Restart processing the object. +.. _vcl_init: vcl_init ~~~~~~~~ @@ -256,9 +336,13 @@ Typically used to initialize VMODs. The `vcl_init` subroutine may terminate with calling ``return()`` with one of the following keywords: - ok + ``ok`` Normal return, VCL continues loading. + ``fail`` + Abort loading of this VCL. + +.. _vcl_fini: vcl_fini ~~~~~~~~ @@ -269,5 +353,5 @@ Typically used to clean up VMODs. The `vcl_fini` subroutine may terminate with calling ``return()`` with one of the following keywords: - ok + ``ok`` Normal return, VCL will be discarded. From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] 83e40df Install _all_ headers under ${prefix}/include/.. Message-ID: commit 83e40dfac66109250d4d13054a2238e5875aa0de Author: Federico G. Schwindt Date: Sat Nov 8 01:47:26 2014 +0000 Install _all_ headers under ${prefix}/include/.. Fixes #1616 Conflicts: varnish.m4 From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] 06056e3 Be more consistent about per-hop/end-to-end headers. Message-ID: commit 06056e3076bd0c14c2e82d8e081871fff9aea66c Author: Poul-Henning Kamp Date: Tue Jan 20 16:11:17 2015 +0100 Be more consistent about per-hop/end-to-end headers. Conflicts: bin/varnishd/cache/cache_http.c bin/varnishd/http1/cache_http1_fsm.c diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6aca502..660d6b7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1019,7 +1019,7 @@ void http_SetStatus(struct http *to, uint16_t status); const char *http_GetReq(const struct http *hp); int http_HdrIs(const struct http *hp, const char *hdr, const char *val); int http_IsHdr(const txt *hh, const char *hdr); -enum sess_close http_DoConnection(const struct http *); +enum sess_close http_DoConnection(struct http *); void http_CopyHome(struct http *hp); void http_Unset(struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 159751b..c00f330 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -493,12 +493,13 @@ http_GetHdrField(const struct http *hp, const char *hdr, */ enum sess_close -http_DoConnection(const struct http *hp) +http_DoConnection(struct http *hp) { char *p, *q; enum sess_close ret; unsigned u; + http_CollectHdr(hp, H_Connection); if (!http_GetHdr(hp, H_Connection, &p)) { if (hp->protover < 11) return (SC_REQ_HTTP10); @@ -517,6 +518,17 @@ http_DoConnection(const struct http *hp) u = pdiff(p, q); if (u == 5 && !strncasecmp(p, "close", u)) ret = SC_REQ_CLOSE; + + /* Refuse removal of well-known-headers if they would pass. */ +/*lint -save -e506 */ +#define HTTPH(a, x, c) \ + if (!((c) & HTTPH_R_PASS) && \ + strlen(a) == u && !strncasecmp(a, p, u)) \ + return (SC_RX_BAD); +#include "tbl/http_headers.h" +#undef HTTPH +/*lint -restore */ + u = http_findhdr(hp, u, p); if (u != 0) hp->hdf[u] |= HDF_FILTER; diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index d83d522..2934181 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -376,6 +376,13 @@ http1_dissect(struct worker *wrk, struct req *req) AZ(req->err_code); req->ws_req = WS_Snapshot(req->ws); req->doclose = http_DoConnection(req->http); + if (req->doclose == SC_RX_BAD) { + r = write(req->sp->fd, r_400, strlen(r_400)); + if (r > 0) + req->acct.resp_hdrbytes += r; + SES_Close(req->sp, req->doclose); + return (REQ_FSM_DONE); + } http_Unset(req->http, H_Expect); diff --git a/bin/varnishtest/tests/c00016.vtc b/bin/varnishtest/tests/c00016.vtc index 83c9527..3e0b2be 100644 --- a/bin/varnishtest/tests/c00016.vtc +++ b/bin/varnishtest/tests/c00016.vtc @@ -23,3 +23,9 @@ client c1 { rxresp expect req.http.Bar == } -run + +client c1 { + txreq -hdr "foo: 1" -hdr "Age: 200" -hdr "Connection: Age" + rxresp + expect resp.status == 400 +} -run diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index 5b77eba..351cc58 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -29,18 +29,19 @@ /*lint -save -e525 -e539 */ -SESS_CLOSE(REM_CLOSE, "Client Closed") -SESS_CLOSE(REQ_CLOSE, "Client requested close") -SESS_CLOSE(REQ_HTTP10, "Proto < HTTP/1.1") -SESS_CLOSE(RX_BODY, "Failure receiving req.body") -SESS_CLOSE(RX_JUNK, "Received junk data") -SESS_CLOSE(RX_OVERFLOW, "Received buffer overflow") -SESS_CLOSE(RX_TIMEOUT, "Receive timeout") -SESS_CLOSE(TX_PIPE, "Piped transaction") -SESS_CLOSE(TX_ERROR, "Error transaction") -SESS_CLOSE(TX_EOF, "EOF transmission") -SESS_CLOSE(RESP_CLOSE, "Backend/VCL requested close") -SESS_CLOSE(OVERLOAD, "Out of some resource") +SESS_CLOSE(REM_CLOSE, "Client Closed") +SESS_CLOSE(REQ_CLOSE, "Client requested close") +SESS_CLOSE(REQ_HTTP10, "Proto < HTTP/1.1") +SESS_CLOSE(RX_BAD, "Received bad request") +SESS_CLOSE(RX_BODY, "Failure receiving req.body") +SESS_CLOSE(RX_JUNK, "Received junk data") +SESS_CLOSE(RX_OVERFLOW, "Received buffer overflow") +SESS_CLOSE(RX_TIMEOUT, "Receive timeout") +SESS_CLOSE(TX_PIPE, "Piped transaction") +SESS_CLOSE(TX_ERROR, "Error transaction") +SESS_CLOSE(TX_EOF, "EOF transmission") +SESS_CLOSE(RESP_CLOSE, "Backend/VCL requested close") +SESS_CLOSE(OVERLOAD, "Out of some resource") SESS_CLOSE(SESS_PIPE_OVERFLOW, "Session pipe overflow") /*lint -restore */ From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] afbe27c Introduce "VRT_CTX" as a shorthand macro for "const struct vrt_ctx *ctx" Message-ID: commit afbe27c0ef296d8770293ab46aba5fb68bb1a086 Author: Poul-Henning Kamp Date: Thu Sep 25 08:50:50 2014 +0000 Introduce "VRT_CTX" as a shorthand macro for "const struct vrt_ctx *ctx" diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4ffb51a..cdeba66 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -52,7 +52,7 @@ const void * const vrt_magic_string_unset = &vrt_magic_string_unset; /*--------------------------------------------------------------------*/ void -VRT_error(const struct vrt_ctx *ctx, unsigned code, const char *reason) +VRT_error(VRT_CTX, unsigned code, const char *reason) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -69,7 +69,7 @@ VRT_error(const struct vrt_ctx *ctx, unsigned code, const char *reason) /*--------------------------------------------------------------------*/ void -VRT_count(const struct vrt_ctx *ctx, unsigned u) +VRT_count(VRT_CTX, unsigned u) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -81,7 +81,7 @@ VRT_count(const struct vrt_ctx *ctx, unsigned u) /*--------------------------------------------------------------------*/ void -VRT_acl_log(const struct vrt_ctx *ctx, const char *msg) +VRT_acl_log(VRT_CTX, const char *msg) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -91,7 +91,7 @@ VRT_acl_log(const struct vrt_ctx *ctx, const char *msg) /*--------------------------------------------------------------------*/ static struct http * -vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where) +vrt_selecthttp(VRT_CTX, enum gethdr_e where) { struct http *hp; @@ -121,7 +121,7 @@ vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where) /*--------------------------------------------------------------------*/ char * -VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs) +VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs) { char *p; struct http *hp; @@ -199,7 +199,7 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap) */ const char * -VRT_CollectString(const struct vrt_ctx *ctx, const char *p, ...) +VRT_CollectString(VRT_CTX, const char *p, ...) { va_list ap; const char *b; @@ -215,7 +215,7 @@ VRT_CollectString(const struct vrt_ctx *ctx, const char *p, ...) /*--------------------------------------------------------------------*/ void -VRT_SetHdr(const struct vrt_ctx *ctx , const struct gethdr_s *hs, +VRT_SetHdr(VRT_CTX , const struct gethdr_s *hs, const char *p, ...) { struct http *hp; @@ -245,7 +245,7 @@ VRT_SetHdr(const struct vrt_ctx *ctx , const struct gethdr_s *hs, /*--------------------------------------------------------------------*/ void -VRT_handling(const struct vrt_ctx *ctx, unsigned hand) +VRT_handling(VRT_CTX, unsigned hand) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -258,7 +258,7 @@ VRT_handling(const struct vrt_ctx *ctx, unsigned hand) */ void -VRT_hashdata(const struct vrt_ctx *ctx, const char *str, ...) +VRT_hashdata(VRT_CTX, const char *str, ...) { va_list ap; const char *p; @@ -285,7 +285,7 @@ VRT_hashdata(const struct vrt_ctx *ctx, const char *str, ...) /*--------------------------------------------------------------------*/ double -VRT_r_now(const struct vrt_ctx *ctx) +VRT_r_now(VRT_CTX) { (void)ctx; @@ -295,7 +295,7 @@ VRT_r_now(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ char * -VRT_IP_string(const struct vrt_ctx *ctx, VCL_IP ip) +VRT_IP_string(VRT_CTX, VCL_IP ip) { char *p; unsigned len; @@ -315,7 +315,7 @@ VRT_IP_string(const struct vrt_ctx *ctx, VCL_IP ip) } char * -VRT_INT_string(const struct vrt_ctx *ctx, long num) +VRT_INT_string(VRT_CTX, long num) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -323,7 +323,7 @@ VRT_INT_string(const struct vrt_ctx *ctx, long num) } char * -VRT_REAL_string(const struct vrt_ctx *ctx, double num) +VRT_REAL_string(VRT_CTX, double num) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -331,7 +331,7 @@ VRT_REAL_string(const struct vrt_ctx *ctx, double num) } char * -VRT_TIME_string(const struct vrt_ctx *ctx, double t) +VRT_TIME_string(VRT_CTX, double t) { char *p; @@ -361,7 +361,7 @@ VRT_BOOL_string(unsigned val) /*--------------------------------------------------------------------*/ void -VRT_Rollback(const struct vrt_ctx *ctx, const struct http *hp) +VRT_Rollback(VRT_CTX, const struct http *hp) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -382,7 +382,7 @@ VRT_Rollback(const struct vrt_ctx *ctx, const struct http *hp) /*--------------------------------------------------------------------*/ void -VRT_synth_page(const struct vrt_ctx *ctx, const char *str, ...) +VRT_synth_page(VRT_CTX, const char *str, ...) { va_list ap; const char *p; @@ -412,7 +412,7 @@ VRT_synth_page(const struct vrt_ctx *ctx, const char *str, ...) /*--------------------------------------------------------------------*/ void -VRT_ban_string(const struct vrt_ctx *ctx, const char *str) +VRT_ban_string(VRT_CTX, const char *str) { char *a1, *a2, *a3; char **av; @@ -479,7 +479,7 @@ VRT_ban_string(const struct vrt_ctx *ctx, const char *str) */ int -VRT_CacheReqBody(const struct vrt_ctx *ctx, long long maxsize) +VRT_CacheReqBody(VRT_CTX, long long maxsize) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -497,7 +497,7 @@ VRT_CacheReqBody(const struct vrt_ctx *ctx, long long maxsize) */ void -VRT_purge(const struct vrt_ctx *ctx, double ttl, double grace, double keep) +VRT_purge(VRT_CTX, double ttl, double grace, double keep) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index fd6353a..0695633 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -62,7 +62,7 @@ VRT_re_fini(void *rep) } int -VRT_re_match(const struct vrt_ctx *ctx, const char *s, void *re) +VRT_re_match(VRT_CTX, const char *s, void *re) { vre_t *t; int i; @@ -81,7 +81,7 @@ VRT_re_match(const struct vrt_ctx *ctx, const char *s, void *re) } const char * -VRT_regsub(const struct vrt_ctx *ctx, int all, const char *str, void *re, +VRT_regsub(VRT_CTX, int all, const char *str, void *re, const char *sub) { int ovector[30]; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index a5f0bde..45614c8 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -68,7 +68,7 @@ vrt_do_string(struct http *hp, int fld, #define VRT_HDR_L(obj, hdr, fld) \ void \ -VRT_l_##obj##_##hdr(const struct vrt_ctx *ctx, const char *p, ...) \ +VRT_l_##obj##_##hdr(VRT_CTX, const char *p, ...) \ { \ va_list ap; \ \ @@ -80,7 +80,7 @@ VRT_l_##obj##_##hdr(const struct vrt_ctx *ctx, const char *p, ...) \ #define VRT_HDR_R(obj, hdr, fld) \ const char * \ -VRT_r_##obj##_##hdr(const struct vrt_ctx *ctx) \ +VRT_r_##obj##_##hdr(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \ @@ -93,7 +93,7 @@ VRT_r_##obj##_##hdr(const struct vrt_ctx *ctx) \ #define VRT_STATUS_L(obj) \ void \ -VRT_l_##obj##_status(const struct vrt_ctx *ctx, long num) \ +VRT_l_##obj##_status(VRT_CTX, long num) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -112,7 +112,7 @@ VRT_l_##obj##_status(const struct vrt_ctx *ctx, long num) \ #define VRT_STATUS_R(obj) \ long \ -VRT_r_##obj##_status(const struct vrt_ctx *ctx) \ +VRT_r_##obj##_status(VRT_CTX) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -148,7 +148,7 @@ VRT_STATUS_R(beresp) #define VBERESPW0(field) #define VBERESPW1(field) \ void \ -VRT_l_beresp_##field(const struct vrt_ctx *ctx, unsigned a) \ +VRT_l_beresp_##field(VRT_CTX, unsigned a) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ @@ -158,7 +158,7 @@ VRT_l_beresp_##field(const struct vrt_ctx *ctx, unsigned a) \ #define VBERESPR0(field) #define VBERESPR1(field) \ unsigned \ -VRT_r_beresp_##field(const struct vrt_ctx *ctx) \ +VRT_r_beresp_##field(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ @@ -174,7 +174,7 @@ VRT_r_beresp_##field(const struct vrt_ctx *ctx) \ /*--------------------------------------------------------------------*/ unsigned -VRT_r_bereq_uncacheable(const struct vrt_ctx *ctx) +VRT_r_bereq_uncacheable(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); @@ -182,7 +182,7 @@ VRT_r_bereq_uncacheable(const struct vrt_ctx *ctx) } void -VRT_l_beresp_uncacheable(const struct vrt_ctx *ctx, unsigned a) +VRT_l_beresp_uncacheable(VRT_CTX, unsigned a) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); @@ -196,7 +196,7 @@ VRT_l_beresp_uncacheable(const struct vrt_ctx *ctx, unsigned a) } unsigned -VRT_r_beresp_uncacheable(const struct vrt_ctx *ctx) +VRT_r_beresp_uncacheable(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); @@ -206,7 +206,7 @@ VRT_r_beresp_uncacheable(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ const char * -VRT_r_client_identity(const struct vrt_ctx *ctx) +VRT_r_client_identity(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -218,7 +218,7 @@ VRT_r_client_identity(const struct vrt_ctx *ctx) } void -VRT_l_client_identity(const struct vrt_ctx *ctx, const char *str, ...) +VRT_l_client_identity(VRT_CTX, const char *str, ...) { va_list ap; const char *b; @@ -240,7 +240,7 @@ VRT_l_client_identity(const struct vrt_ctx *ctx, const char *str, ...) #define BEREQ_TIMEOUT(which) \ void \ -VRT_l_bereq_##which(const struct vrt_ctx *ctx, double num) \ +VRT_l_bereq_##which(VRT_CTX, double num) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -249,7 +249,7 @@ VRT_l_bereq_##which(const struct vrt_ctx *ctx, double num) \ } \ \ double \ -VRT_r_bereq_##which(const struct vrt_ctx *ctx) \ +VRT_r_bereq_##which(VRT_CTX) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -264,7 +264,7 @@ BEREQ_TIMEOUT(between_bytes_timeout) /*--------------------------------------------------------------------*/ const char * -VRT_r_beresp_backend_name(const struct vrt_ctx *ctx) +VRT_r_beresp_backend_name(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -279,7 +279,7 @@ VRT_r_beresp_backend_name(const struct vrt_ctx *ctx) } VCL_IP -VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx) +VRT_r_beresp_backend_ip(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -294,7 +294,7 @@ VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ const char * -VRT_r_beresp_storage_hint(const struct vrt_ctx *ctx) +VRT_r_beresp_storage_hint(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); @@ -305,7 +305,7 @@ VRT_r_beresp_storage_hint(const struct vrt_ctx *ctx) } void -VRT_l_beresp_storage_hint(const struct vrt_ctx *ctx, const char *str, ...) +VRT_l_beresp_storage_hint(VRT_CTX, const char *str, ...) { va_list ap; const char *b; @@ -328,7 +328,7 @@ VRT_l_beresp_storage_hint(const struct vrt_ctx *ctx, const char *str, ...) #define REQ_VAR_L(nm, elem, type,extra) \ \ void \ -VRT_l_req_##nm(const struct vrt_ctx *ctx, type arg) \ +VRT_l_req_##nm(VRT_CTX, type arg) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ @@ -339,7 +339,7 @@ VRT_l_req_##nm(const struct vrt_ctx *ctx, type arg) \ #define REQ_VAR_R(nm, elem, type) \ \ type \ -VRT_r_req_##nm(const struct vrt_ctx *ctx) \ +VRT_r_req_##nm(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ @@ -354,7 +354,7 @@ REQ_VAR_R(ttl, d_ttl, double) /*--------------------------------------------------------------------*/ void -VRT_l_bereq_backend(const struct vrt_ctx *ctx, struct director *be) +VRT_l_bereq_backend(VRT_CTX, struct director *be) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -363,7 +363,7 @@ VRT_l_bereq_backend(const struct vrt_ctx *ctx, struct director *be) } struct director * -VRT_r_bereq_backend(const struct vrt_ctx *ctx) +VRT_r_bereq_backend(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -374,7 +374,7 @@ VRT_r_bereq_backend(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ void -VRT_l_req_esi(const struct vrt_ctx *ctx, unsigned process_esi) +VRT_l_req_esi(VRT_CTX, unsigned process_esi) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -388,7 +388,7 @@ VRT_l_req_esi(const struct vrt_ctx *ctx, unsigned process_esi) } unsigned -VRT_r_req_esi(const struct vrt_ctx *ctx) +VRT_r_req_esi(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -397,7 +397,7 @@ VRT_r_req_esi(const struct vrt_ctx *ctx) } long -VRT_r_req_esi_level(const struct vrt_ctx *ctx) +VRT_r_req_esi_level(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -408,7 +408,7 @@ VRT_r_req_esi_level(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ unsigned -VRT_r_req_can_gzip(const struct vrt_ctx *ctx) +VRT_r_req_can_gzip(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -419,7 +419,7 @@ VRT_r_req_can_gzip(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ long -VRT_r_req_restarts(const struct vrt_ctx *ctx) +VRT_r_req_restarts(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -428,7 +428,7 @@ VRT_r_req_restarts(const struct vrt_ctx *ctx) } long -VRT_r_bereq_retries(const struct vrt_ctx *ctx) +VRT_r_bereq_retries(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -444,7 +444,7 @@ VRT_r_bereq_retries(const struct vrt_ctx *ctx) #define VRT_DO_EXP_L(which, sexp, fld) \ \ void \ -VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \ +VRT_l_##which##_##fld(VRT_CTX, double a) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -458,7 +458,7 @@ VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \ #define VRT_DO_EXP_R(which, sexp, fld, offset) \ \ double \ -VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \ +VRT_r_##which##_##fld(VRT_CTX) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -484,7 +484,7 @@ VRT_DO_EXP_R(beresp, ctx->bo->exp, keep, 0) */ const char * -VRT_r_req_xid(const struct vrt_ctx *ctx) +VRT_r_req_xid(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -495,7 +495,7 @@ VRT_r_req_xid(const struct vrt_ctx *ctx) } const char * -VRT_r_bereq_xid(const struct vrt_ctx *ctx) +VRT_r_bereq_xid(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -509,7 +509,7 @@ VRT_r_bereq_xid(const struct vrt_ctx *ctx) #define REQ_BOOL(hash_var) \ void \ -VRT_l_req_##hash_var(const struct vrt_ctx *ctx, unsigned val) \ +VRT_l_req_##hash_var(VRT_CTX, unsigned val) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -518,7 +518,7 @@ VRT_l_req_##hash_var(const struct vrt_ctx *ctx, unsigned val) \ } \ \ unsigned \ -VRT_r_req_##hash_var(const struct vrt_ctx *ctx) \ +VRT_r_req_##hash_var(VRT_CTX) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ @@ -532,7 +532,7 @@ REQ_BOOL(hash_always_miss) /*--------------------------------------------------------------------*/ VCL_IP -VRT_r_client_ip(const struct vrt_ctx *ctx) +VRT_r_client_ip(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -542,7 +542,7 @@ VRT_r_client_ip(const struct vrt_ctx *ctx) } VCL_IP -VRT_r_server_ip(const struct vrt_ctx *ctx) +VRT_r_server_ip(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -552,7 +552,7 @@ VRT_r_server_ip(const struct vrt_ctx *ctx) } const char* -VRT_r_server_identity(const struct vrt_ctx *ctx) +VRT_r_server_identity(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -563,7 +563,7 @@ VRT_r_server_identity(const struct vrt_ctx *ctx) } const char* -VRT_r_server_hostname(const struct vrt_ctx *ctx) +VRT_r_server_hostname(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -575,7 +575,7 @@ VRT_r_server_hostname(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ long -VRT_r_obj_hits(const struct vrt_ctx *ctx) +VRT_r_obj_hits(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); @@ -585,7 +585,7 @@ VRT_r_obj_hits(const struct vrt_ctx *ctx) } unsigned -VRT_r_obj_uncacheable(const struct vrt_ctx *ctx) +VRT_r_obj_uncacheable(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -598,7 +598,7 @@ VRT_r_obj_uncacheable(const struct vrt_ctx *ctx) #define HTTP_VAR(x) \ struct http * \ -VRT_r_##x(const struct vrt_ctx *ctx) \ +VRT_r_##x(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->http_##x, HTTP_MAGIC); \ diff --git a/include/vrt.h b/include/vrt.h index 1c5eea2..e7939aa 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -105,6 +105,8 @@ struct vrt_ctx { double now; }; +#define VRT_CTX const struct vrt_ctx *ctx + /***********************************************************************/ struct vmod_data { @@ -186,42 +188,40 @@ struct vrt_ref { /* ACL related */ #define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */ -void VRT_acl_log(const struct vrt_ctx *, const char *msg); +void VRT_acl_log(VRT_CTX, const char *msg); /* req related */ -int VRT_CacheReqBody(const struct vrt_ctx *, long long maxsize); +int VRT_CacheReqBody(VRT_CTX, long long maxsize); /* Regexp related */ void VRT_re_init(void **, const char *); void VRT_re_fini(void *); -int VRT_re_match(const struct vrt_ctx *, const char *, void *re); -const char *VRT_regsub(const struct vrt_ctx *, int all, const char *, - void *, const char *); +int VRT_re_match(VRT_CTX, const char *, void *re); +const char *VRT_regsub(VRT_CTX, int all, const char *, void *, const char *); -void VRT_ban_string(const struct vrt_ctx *, const char *); -void VRT_purge(const struct vrt_ctx *, double ttl, double grace, double keep); +void VRT_ban_string(VRT_CTX, const char *); +void VRT_purge(VRT_CTX, double ttl, double grace, double keep); -void VRT_count(const struct vrt_ctx *, unsigned); +void VRT_count(VRT_CTX, unsigned); int VRT_rewrite(const char *, const char *); -void VRT_error(const struct vrt_ctx *, unsigned, const char *); +void VRT_error(VRT_CTX, unsigned, const char *); int VRT_switch_config(const char *); -char *VRT_GetHdr(const struct vrt_ctx *, const struct gethdr_s *); -void VRT_SetHdr(const struct vrt_ctx *, const struct gethdr_s *, - const char *, ...); -void VRT_handling(const struct vrt_ctx *, unsigned hand); +char *VRT_GetHdr(VRT_CTX, const struct gethdr_s *); +void VRT_SetHdr(VRT_CTX, const struct gethdr_s *, const char *, ...); +void VRT_handling(VRT_CTX, unsigned hand); -void VRT_hashdata(const struct vrt_ctx *, const char *str, ...); +void VRT_hashdata(VRT_CTX, const char *str, ...); /* Simple stuff */ int VRT_strcmp(const char *s1, const char *s2); void VRT_memmove(void *dst, const void *src, unsigned len); -void VRT_Rollback(const struct vrt_ctx *, const struct http *); +void VRT_Rollback(VRT_CTX, const struct http *); /* Synthetic pages */ -void VRT_synth_page(const struct vrt_ctx *, const char *, ...); +void VRT_synth_page(VRT_CTX, const char *, ...); /* Backend related */ void VRT_init_dir(struct cli *, struct director **, int idx, const void *priv); @@ -252,10 +252,10 @@ int VRT_Stv(const char *nm); /* Convert things to string */ -char *VRT_IP_string(const struct vrt_ctx *, VCL_IP); -char *VRT_INT_string(const struct vrt_ctx *, VCL_INT); -char *VRT_REAL_string(const struct vrt_ctx *, VCL_REAL); -char *VRT_TIME_string(const struct vrt_ctx *, VCL_TIME); +char *VRT_IP_string(VRT_CTX, VCL_IP); +char *VRT_INT_string(VRT_CTX, VCL_INT); +char *VRT_REAL_string(VRT_CTX, VCL_REAL); +char *VRT_TIME_string(VRT_CTX, VCL_TIME); const char *VRT_BOOL_string(VCL_BOOL); const char *VRT_BACKEND_string(VCL_BACKEND); -const char *VRT_CollectString(const struct vrt_ctx *, const char *p, ...); +const char *VRT_CollectString(VRT_CTX, const char *p, ...); diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 372ef1c..884fe3d 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -915,6 +915,7 @@ file_header(fo) fo.write(""" struct vrt_ctx; +#define VRT_CTX const struct vrt_ctx *ctx struct req; struct busyobj; struct ws; @@ -923,7 +924,7 @@ struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(const struct vrt_ctx *ctx); +typedef int vcl_func_f(VRT_CTX); """) def tbl40(a, b): @@ -1057,7 +1058,7 @@ def one_var(nm, spec): fo.write('\t "VRT_r_%s(ctx)",\n' % cnam) if nm == i[0]: fh.write("VCL_" + typ + - " VRT_r_%s(const struct vrt_ctx *);\n" % cnam ) + " VRT_r_%s(VRT_CTX);\n" % cnam ) restrict(fo, spec[2]) if len(spec[3]) == 0: @@ -1070,7 +1071,7 @@ def one_var(nm, spec): fo.write('\t "VRT_l_%s(ctx, ",\n' % cnam) if nm == i[0]: fh.write( - "void VRT_l_%s(const struct vrt_ctx *, " % cnam) + "void VRT_l_%s(VRT_CTX, " % cnam) if typ != "STRING": fh.write("VCL_" + typ + ");\n") else: diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 997ae3c..72dd304 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -354,7 +354,7 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) Fh(tl, 0, "\nstatic int\n"); Fh(tl, 0, - "match_acl_%s_%s(const struct vrt_ctx *ctx, const VCL_IP p)\n", + "match_acl_%s_%s(VRT_CTX, const VCL_IP p)\n", anon ? "anon" : "named", acln); Fh(tl, 0, "{\n"); Fh(tl, 0, "\tconst unsigned char *a;\n"); diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 4077c1c..7bc4bc2 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -670,11 +670,11 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) for (i = 1; i < VCL_MET_MAX; i++) { Fh(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); Fh(tl, 1, - "VGC_function_%s(const struct vrt_ctx *ctx);\n", + "VGC_function_%s(VRT_CTX);\n", method_tab[i].name); Fc(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); Fc(tl, 1, - "VGC_function_%s(const struct vrt_ctx *ctx)\n", + "VGC_function_%s(VRT_CTX)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index 2b52846..e235090 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -251,9 +251,9 @@ vcc_ParseFunction(struct vcc *tl) } tl->curproc = vcc_AddProc(tl, tl->t); Fh(tl, 0, "int VGC_function_%.*s " - "(const struct vrt_ctx *ctx);\n", PF(tl->t)); + "(VRT_CTX);\n", PF(tl->t)); Fc(tl, 1, "\nint __match_proto__(vcl_func_t)\n"); - Fc(tl, 1, "VGC_function_%.*s(const struct vrt_ctx *ctx)\n", + Fc(tl, 1, "VGC_function_%.*s(VRT_CTX)\n", PF(tl->t)); } vcc_NextToken(tl); diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index bf386f3..0fcf148 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -358,7 +358,7 @@ class Func(object): s = ctypes[self.retval] + " vmod_" + self.cnam + "(" p = "" if not fini: - s += "const struct vrt_ctx *" + s += "VRT_CTX" p = ", " if self.pfx != None: s += p + self.pfx @@ -375,7 +375,7 @@ class Func(object): s += " td_" + modname + "_" + self.cnam + "(" p = "" if not fini: - s += "const struct vrt_ctx *" + s += "VRT_CTX" p = ", " if self.pfx != None: s += p + self.pfx @@ -859,7 +859,6 @@ def runmain(inputvcc, outputname="vcc_if"): write_c_file_warning(fc) write_c_file_warning(fh) - fh.write('struct vrt_ctx;\n') fh.write('struct VCL_conf;\n') fh.write('struct vmod_priv;\n') fh.write("\n") diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index b952f64..76e5a5f 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -37,7 +37,7 @@ #include "vcc_if.h" VCL_VOID __match_proto__(td_debug_panic) -vmod_panic(const struct vrt_ctx *ctx, const char *str, ...) +vmod_panic(VRT_CTX, const char *str, ...) { va_list ap; const char *b; @@ -50,7 +50,7 @@ vmod_panic(const struct vrt_ctx *ctx, const char *str, ...) } VCL_STRING __match_proto__(td_debug_author) -vmod_author(const struct vrt_ctx *ctx, VCL_ENUM id) +vmod_author(VRT_CTX, VCL_ENUM id) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -76,7 +76,7 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *cfg) } VCL_VOID __match_proto__(td_debug_test_priv_call) -vmod_test_priv_call(const struct vrt_ctx *ctx, struct vmod_priv *priv) +vmod_test_priv_call(VRT_CTX, struct vmod_priv *priv) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -89,7 +89,7 @@ vmod_test_priv_call(const struct vrt_ctx *ctx, struct vmod_priv *priv) } VCL_VOID __match_proto__(td_debug_test_priv_vcl) -vmod_test_priv_vcl(const struct vrt_ctx *ctx, struct vmod_priv *priv) +vmod_test_priv_vcl(VRT_CTX, struct vmod_priv *priv) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -97,7 +97,7 @@ vmod_test_priv_vcl(const struct vrt_ctx *ctx, struct vmod_priv *priv) } VCL_BLOB -vmod_str2blob(const struct vrt_ctx *ctx, VCL_STRING s) +vmod_str2blob(VRT_CTX, VCL_STRING s) { struct vmod_priv *p; @@ -111,7 +111,7 @@ vmod_str2blob(const struct vrt_ctx *ctx, VCL_STRING s) } VCL_STRING -vmod_blob2hex(const struct vrt_ctx *ctx, VCL_BLOB b) +vmod_blob2hex(VRT_CTX, VCL_BLOB b) { char *s, *p; uint8_t *q; @@ -131,7 +131,7 @@ vmod_blob2hex(const struct vrt_ctx *ctx, VCL_BLOB b) } VCL_BACKEND -vmod_no_backend(const struct vrt_ctx *ctx) +vmod_no_backend(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -139,7 +139,7 @@ vmod_no_backend(const struct vrt_ctx *ctx) } VCL_VOID __match_proto__(td_debug_rot52) -vmod_rot52(const struct vrt_ctx *ctx, VCL_HTTP hp) +vmod_rot52(VRT_CTX, VCL_HTTP hp) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index ad24578..91dfa0d 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -42,7 +42,7 @@ struct vmod_debug_obj { }; VCL_VOID -vmod_obj__init(const struct vrt_ctx *ctx, struct vmod_debug_obj **op, +vmod_obj__init(VRT_CTX, struct vmod_debug_obj **op, const char *vcl_name, VCL_STRING s) { struct vmod_debug_obj *o; @@ -70,7 +70,7 @@ vmod_obj__fini(struct vmod_debug_obj **op) } VCL_VOID __match_proto__() -vmod_obj_enum(const struct vrt_ctx *ctx, struct vmod_debug_obj *o, VCL_ENUM e) +vmod_obj_enum(VRT_CTX, struct vmod_debug_obj *o, VCL_ENUM e) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -79,7 +79,7 @@ vmod_obj_enum(const struct vrt_ctx *ctx, struct vmod_debug_obj *o, VCL_ENUM e) } VCL_STRING __match_proto__() -vmod_obj_foo(const struct vrt_ctx *ctx, struct vmod_debug_obj *o, VCL_STRING s) +vmod_obj_foo(VRT_CTX, struct vmod_debug_obj *o, VCL_STRING s) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -90,7 +90,7 @@ vmod_obj_foo(const struct vrt_ctx *ctx, struct vmod_debug_obj *o, VCL_STRING s) } VCL_TIME __match_proto__() -vmod_obj_date(const struct vrt_ctx *ctx, struct vmod_debug_obj *o) +vmod_obj_date(VRT_CTX, struct vmod_debug_obj *o) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index edec2af..3552116 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -75,7 +75,7 @@ vmod_rr_getfd(const struct director *dir, struct busyobj *bo) } VCL_VOID __match_proto__() -vmod_fallback__init(const struct vrt_ctx *ctx, +vmod_fallback__init(VRT_CTX, struct vmod_directors_fallback **rrp, const char *vcl_name) { struct vmod_directors_fallback *rr; @@ -102,7 +102,7 @@ vmod_fallback__fini(struct vmod_directors_fallback **rrp) } VCL_VOID __match_proto__() -vmod_fallback_add_backend(const struct vrt_ctx *ctx, +vmod_fallback_add_backend(VRT_CTX, struct vmod_directors_fallback *rr, VCL_BACKEND be) { @@ -112,7 +112,7 @@ vmod_fallback_add_backend(const struct vrt_ctx *ctx, } VCL_BACKEND __match_proto__() -vmod_fallback_backend(const struct vrt_ctx *ctx, +vmod_fallback_backend(VRT_CTX, struct vmod_directors_fallback *rr) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 090039f..6ff2a77 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -52,7 +52,7 @@ struct vmod_directors_hash { }; VCL_VOID __match_proto__() -vmod_hash__init(const struct vrt_ctx *ctx, struct vmod_directors_hash **rrp, +vmod_hash__init(VRT_CTX, struct vmod_directors_hash **rrp, const char *vcl_name) { struct vmod_directors_hash *rr; @@ -82,7 +82,7 @@ vmod_hash__fini(struct vmod_directors_hash **rrp) } VCL_VOID __match_proto__() -vmod_hash_add_backend(const struct vrt_ctx *ctx, +vmod_hash_add_backend(VRT_CTX, struct vmod_directors_hash *rr, VCL_BACKEND be, double w) { @@ -93,7 +93,7 @@ vmod_hash_add_backend(const struct vrt_ctx *ctx, } VCL_BACKEND __match_proto__() -vmod_hash_backend(const struct vrt_ctx *ctx, struct vmod_directors_hash *rr, +vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, const char *arg, ...) { struct SHA256Context sha_ctx; diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index c32167e..91a281e 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -74,7 +74,7 @@ vmod_rr_getfd(const struct director *dir, struct busyobj *bo) } VCL_VOID __match_proto__() -vmod_random__init(const struct vrt_ctx *ctx, struct vmod_directors_random **rrp, +vmod_random__init(VRT_CTX, struct vmod_directors_random **rrp, const char *vcl_name) { struct vmod_directors_random *rr; @@ -101,7 +101,7 @@ vmod_random__fini(struct vmod_directors_random **rrp) } VCL_VOID __match_proto__() -vmod_random_add_backend(const struct vrt_ctx *ctx, +vmod_random_add_backend(VRT_CTX, struct vmod_directors_random *rr, VCL_BACKEND be, double w) { @@ -112,7 +112,7 @@ vmod_random_add_backend(const struct vrt_ctx *ctx, } VCL_BACKEND __match_proto__() -vmod_random_backend(const struct vrt_ctx *ctx, struct vmod_directors_random *rr) +vmod_random_backend(VRT_CTX, struct vmod_directors_random *rr) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index 629bbbf..89e588b 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -78,7 +78,7 @@ vmod_rr_getfd(const struct director *dir, struct busyobj *bo) } VCL_VOID __match_proto__() -vmod_round_robin__init(const struct vrt_ctx *ctx, +vmod_round_robin__init(VRT_CTX, struct vmod_directors_round_robin **rrp, const char *vcl_name) { struct vmod_directors_round_robin *rr; @@ -105,7 +105,7 @@ vmod_round_robin__fini(struct vmod_directors_round_robin **rrp) } VCL_VOID __match_proto__() -vmod_round_robin_add_backend(const struct vrt_ctx *ctx, +vmod_round_robin_add_backend(VRT_CTX, struct vmod_directors_round_robin *rr, VCL_BACKEND be) { @@ -115,7 +115,7 @@ vmod_round_robin_add_backend(const struct vrt_ctx *ctx, } VCL_BACKEND __match_proto__() -vmod_round_robin_backend(const struct vrt_ctx *ctx, +vmod_round_robin_backend(VRT_CTX, struct vmod_directors_round_robin *rr) { diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index ea2a41d..63af0e6 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -49,7 +49,7 @@ #include "vcc_if.h" VCL_VOID __match_proto__(td_std_set_ip_tos) -vmod_set_ip_tos(const struct vrt_ctx *ctx, VCL_INT tos) +vmod_set_ip_tos(VRT_CTX, VCL_INT tos) { int itos = tos; @@ -59,7 +59,7 @@ vmod_set_ip_tos(const struct vrt_ctx *ctx, VCL_INT tos) } static const char * -vmod_updown(const struct vrt_ctx *ctx, int up, const char *s, va_list ap) +vmod_updown(VRT_CTX, int up, const char *s, va_list ap) { unsigned u; char *b, *e; @@ -95,7 +95,7 @@ vmod_updown(const struct vrt_ctx *ctx, int up, const char *s, va_list ap) } VCL_STRING __match_proto__(td_std_toupper) -vmod_toupper(const struct vrt_ctx *ctx, const char *s, ...) +vmod_toupper(VRT_CTX, const char *s, ...) { const char *p; va_list ap; @@ -108,7 +108,7 @@ vmod_toupper(const struct vrt_ctx *ctx, const char *s, ...) } VCL_STRING __match_proto__(td_std_tolower) -vmod_tolower(const struct vrt_ctx *ctx, const char *s, ...) +vmod_tolower(VRT_CTX, const char *s, ...) { const char *p; va_list ap; @@ -121,7 +121,7 @@ vmod_tolower(const struct vrt_ctx *ctx, const char *s, ...) } VCL_REAL __match_proto__(td_std_random) -vmod_random(const struct vrt_ctx *ctx, VCL_REAL lo, VCL_REAL hi) +vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi) { double a; @@ -133,7 +133,7 @@ vmod_random(const struct vrt_ctx *ctx, VCL_REAL lo, VCL_REAL hi) } VCL_VOID __match_proto__(td_std_log) -vmod_log(const struct vrt_ctx *ctx, const char *fmt, ...) +vmod_log(VRT_CTX, const char *fmt, ...) { unsigned u; va_list ap; @@ -154,7 +154,7 @@ vmod_log(const struct vrt_ctx *ctx, const char *fmt, ...) } VCL_VOID __match_proto__(td_std_syslog) -vmod_syslog(const struct vrt_ctx *ctx, VCL_INT fac, const char *fmt, ...) +vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) { unsigned u; va_list ap; @@ -172,7 +172,7 @@ vmod_syslog(const struct vrt_ctx *ctx, VCL_INT fac, const char *fmt, ...) } VCL_VOID __match_proto__(td_std_collect) -vmod_collect(const struct vrt_ctx *ctx, VCL_HEADER hdr) +vmod_collect(VRT_CTX, VCL_HEADER hdr) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -187,7 +187,7 @@ vmod_collect(const struct vrt_ctx *ctx, VCL_HEADER hdr) } VCL_BOOL __match_proto__(td_std_healthy) -vmod_healthy(const struct vrt_ctx *ctx, VCL_BACKEND be) +vmod_healthy(VRT_CTX, VCL_BACKEND be) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (be == NULL) @@ -197,7 +197,7 @@ vmod_healthy(const struct vrt_ctx *ctx, VCL_BACKEND be) } VCL_INT __match_proto__(td_std_port) -vmod_port(const struct vrt_ctx *ctx, VCL_IP ip) +vmod_port(VRT_CTX, VCL_IP ip) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (ip == NULL) @@ -206,13 +206,13 @@ vmod_port(const struct vrt_ctx *ctx, VCL_IP ip) } VCL_VOID __match_proto__(td_std_rollback) -vmod_rollback(const struct vrt_ctx *ctx, VCL_HTTP hp) +vmod_rollback(VRT_CTX, VCL_HTTP hp) { VRT_Rollback(ctx, hp); } VCL_VOID __match_proto__(td_std_timestamp) -vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label) +vmod_timestamp(VRT_CTX, VCL_STRING label) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -232,7 +232,7 @@ vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label) } VCL_STRING __match_proto__(td_std_strstr) -vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr) +vmod_strstr(VRT_CTX, VCL_STRING mstr, VCL_STRING msubstr) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -243,7 +243,7 @@ vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr) } VCL_VOID __match_proto__(td_std_cache_req_body) -vmod_cache_req_body(const struct vrt_ctx *ctx, VCL_BYTES size) +vmod_cache_req_body(VRT_CTX, VCL_BYTES size) { int result; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 181f9f9..298b7c4 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -45,7 +45,7 @@ #include "vcc_if.h" VCL_DURATION __match_proto__(td_std_duration) -vmod_duration(const struct vrt_ctx *ctx, VCL_STRING p, VCL_DURATION d) +vmod_duration(VRT_CTX, VCL_STRING p, VCL_DURATION d) { char *e; double r; @@ -102,7 +102,7 @@ vmod_duration(const struct vrt_ctx *ctx, VCL_STRING p, VCL_DURATION d) } VCL_INT __match_proto__(td_std_integer) -vmod_integer(const struct vrt_ctx *ctx, VCL_STRING p, VCL_INT i) +vmod_integer(VRT_CTX, VCL_STRING p, VCL_INT i) { char *e; long r; @@ -129,7 +129,7 @@ vmod_integer(const struct vrt_ctx *ctx, VCL_STRING p, VCL_INT i) } VCL_IP -vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d) +vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d) { struct addrinfo hints, *res0 = NULL; const struct addrinfo *res; @@ -168,7 +168,7 @@ vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d) } VCL_REAL __match_proto__(td_std_real) -vmod_real(const struct vrt_ctx *ctx, VCL_STRING p, VCL_REAL d) +vmod_real(VRT_CTX, VCL_STRING p, VCL_REAL d) { char *e; double r; @@ -198,7 +198,7 @@ vmod_real(const struct vrt_ctx *ctx, VCL_STRING p, VCL_REAL d) } VCL_TIME __match_proto__(td_std_real2time) -vmod_real2time(const struct vrt_ctx *ctx, VCL_REAL r) +vmod_real2time(VRT_CTX, VCL_REAL r) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -206,7 +206,7 @@ vmod_real2time(const struct vrt_ctx *ctx, VCL_REAL r) } VCL_INT __match_proto__(td_std_time2integer) -vmod_time2integer(const struct vrt_ctx *ctx, VCL_TIME t) +vmod_time2integer(VRT_CTX, VCL_TIME t) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -214,7 +214,7 @@ vmod_time2integer(const struct vrt_ctx *ctx, VCL_TIME t) } VCL_REAL __match_proto__(td_std_time2real) -vmod_time2real(const struct vrt_ctx *ctx, VCL_TIME t) +vmod_time2real(VRT_CTX, VCL_TIME t) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index 4fce9a2..0e37268 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -83,7 +83,7 @@ free_frfile(void *ptr) } VCL_STRING __match_proto__(td_std_fileread) -vmod_fileread(const struct vrt_ctx *ctx, struct vmod_priv *priv, +vmod_fileread(VRT_CTX, struct vmod_priv *priv, VCL_STRING file_name) { struct frfile *frf = NULL; diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 8f7f93b..6f6a90b 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -50,7 +50,7 @@ compa(const void *a, const void *b) } VCL_STRING __match_proto__(td_std_querysort) -vmod_querysort(const struct vrt_ctx *ctx, VCL_STRING url) +vmod_querysort(VRT_CTX, VCL_STRING url) { const char *cq, *cu; char *p, *r; From lkarsten at varnish-software.com Thu Jan 22 15:45:34 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 22 Jan 2015 16:45:34 +0100 Subject: [4.0] b62b011 Preparing for a 4.0.3-rc2. Message-ID: commit b62b01144ed845a76455d2722c765ac47571605d Author: Lasse Karstensen Date: Thu Jan 22 16:42:41 2015 +0100 Preparing for a 4.0.3-rc2. Not tagging it yet. diff --git a/configure.ac b/configure.ac index cdc5422..ae333f2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS -Copyright (c) 2006-2014 Varnish Software AS]) +Copyright (c) 2006-2015 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.0.3-rc1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.0.3-rc2], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index 0765947..ba50deb 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,3 +1,22 @@ +================================================ +Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-22) +================================================ + +Changes since 4.0.3-rc1: + +- Assorted documentation updates. + +Bugs fixed +---------- + +- 1479_ - Fix out-of-tree builds. +- 1616_ - Correct header file placement. +- 1620_ - Fail miss properly if out of backend threads. (Also 1621_) +- 1628_ - Avoid dereferencing null in VBO_DerefBusyObj(). +- 1629_ - Ditch rest of waiting list on failure to reschedule. +- 1660_ - Don't attempt range delivery on a synth response + + ============================================ Changes from 4.0.2 to 4.0.3-rc1 (2015-01-15) ============================================ From phk at FreeBSD.org Thu Jan 22 23:43:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 00:43:24 +0100 Subject: [master] 48d6d38 Minor fixes to make destroying waiters work Message-ID: commit 48d6d3804830aa00f4f55729d1c0d41acd9cbb10 Author: Poul-Henning Kamp Date: Thu Jan 22 23:18:29 2015 +0000 Minor fixes to make destroying waiters work diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index db0ef8a..ec8aebb 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -185,7 +185,7 @@ Wait_Enter(const struct waiter *w, struct waited *wp) CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - assert(wp->fd >= 0); + assert(wp->fd > 0); // stdin never comes here AZ(w->dismantle); if (w->impl->pass != NULL) @@ -245,11 +245,11 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) return; for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { - CHECK_OBJ_NOTNULL(ss[j], WAITED_MAGIC); - if (ss[j] == w->pipe_w) { - dotimer = 1; - } else if (ss[j] == NULL) { + CHECK_OBJ_ORNULL(ss[j], WAITED_MAGIC); + if (ss[j] == NULL) { AN(w->dismantle); + } else if (ss[j] == w->pipe_w) { + dotimer = 1; } else { assert(ss[j]->fd >= 0); VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); @@ -258,6 +258,8 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) } AZ(i); + wait_updidle(w, now); + if (!dotimer) return; From phk at FreeBSD.org Thu Jan 22 23:43:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 00:43:24 +0100 Subject: [master] 06faac1 Define a debug bit to mark that we are running under varnishtest control and always set it in varnishtest Message-ID: commit 06faac1b74d2f96a621439d4b062b5f1381abfbc Author: Poul-Henning Kamp Date: Thu Jan 22 23:21:34 2015 +0000 Define a debug bit to mark that we are running under varnishtest control and always set it in varnishtest diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 1a826ea..2506093 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -390,6 +390,7 @@ varnish_launch(struct varnish *v) VSB_printf(vsb, " -p syslog_cli_traffic=off"); VSB_printf(vsb, " -p sigsegv_handler=on"); VSB_printf(vsb, " -p thread_pool_min=10"); + VSB_printf(vsb, " -p debug=+vtc_mode"); VSB_printf(vsb, " -a '%s'", "127.0.0.1:0"); VSB_printf(vsb, " -M '%s %s'", abuf, pbuf); VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir); diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 81d5e38..ba9400a 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -39,3 +39,4 @@ DEBUG_BIT(VCLREL, vclrel, "Rapid VCL release") DEBUG_BIT(LURKER, lurker, "VSL Ban lurker") DEBUG_BIT(ESI_CHOP, esi_chop, "Chop ESI fetch to bits") DEBUG_BIT(FLUSH_HEAD, flush_head, "Flush after http1 head") +DEBUG_BIT(VTC_MODE, vtc_mode, "Varnishtest Mode") From phk at FreeBSD.org Thu Jan 22 23:43:24 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 00:43:24 +0100 Subject: [master] cf85e6c Hook a waiter up to each backend connection pool. Message-ID: commit cf85e6c1984267dd23b7974213ca07fe1e6b6075 Author: Poul-Henning Kamp Date: Thu Jan 22 23:41:31 2015 +0000 Hook a waiter up to each backend connection pool. This should solve the problem of old stale backend connections, as the waiter will discover the backend closing their end. A default timeout of one minute from our end is hardcoded for now, it will be VCL configurable once I make it over to the VCC. For now a lot of debugging VSL's have been left in, until we see how much trouble this causes... diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 26955a6..ff3b187 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -84,6 +84,15 @@ struct backend { /* -------------------------------------------------------------------*/ +enum vbc_waiter { + VBC_W_NEW, + VBC_W_INWAIT, + VBC_W_STOLEN, + VBC_W_NOWAIT, + VBC_W_PENDING, + VBC_W_KILL, +}; + /* Backend connection */ struct vbc { unsigned magic; @@ -92,6 +101,8 @@ struct vbc { int fd; const struct suckaddr *addr; uint8_t recycled; + enum vbc_waiter in_waiter; + struct waited waited[1]; struct backend *backend; }; diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 90f18fe..23ada15 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -46,6 +46,7 @@ #include "vrt.h" #include "vtcp.h" #include "vsa.h" +#include "waiter/waiter.h" struct tcp_pool { unsigned magic; @@ -59,12 +60,18 @@ struct tcp_pool { int refcnt; struct lock mtx; + struct waiter *waiter; + volatile double timeout; + VTAILQ_HEAD(, vbc) connlist; int n_conn; VTAILQ_HEAD(, vbc) killlist; int n_kill; + VTAILQ_HEAD(, vbc) pendlist; + int n_pend; + int n_used; }; @@ -72,6 +79,60 @@ struct tcp_pool { static VTAILQ_HEAD(, tcp_pool) pools = VTAILQ_HEAD_INITIALIZER(pools); /*-------------------------------------------------------------------- + * Waiter-handler + */ + +static void __match_proto__(waiter_handle_f) +tcp_handle(struct waited *w, enum wait_event ev, double now) +{ + struct vbc *vbc; + struct tcp_pool *tp; + + CAST_OBJ_NOTNULL(vbc, w->ptr, VBC_MAGIC); + (void)ev; + (void)now; + tp = vbc->backend->tcp_pool; // NB: Incestous + + Lck_Lock(&tp->mtx); + switch (vbc->in_waiter) { + case VBC_W_KILL: +VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d KILL", + vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); + assert(vbc->fd < 0); + tp->n_kill--; + VTAILQ_REMOVE(&tp->killlist, vbc, list); + FREE_OBJ(vbc); + break; + case VBC_W_PENDING: +VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d PENDING", + vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); + vbc->in_waiter = VBC_W_NOWAIT; + VTAILQ_REMOVE(&tp->pendlist, vbc, list); + tp->n_pend--; + break; + case VBC_W_STOLEN: +VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d STOLEN", + vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); + vbc->in_waiter = VBC_W_NOWAIT; + vbc = NULL; + break; + case VBC_W_INWAIT: +VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d INWAIT", + vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); + VTCP_close(&vbc->fd); + VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; + FREE_OBJ(vbc); + break; + default: + WRONG("Wrong vbc in_wait state"); + } + Lck_Unlock(&tp->mtx); + if (vbc != NULL) + VBT_Recycle(tp, &vbc); +} + +/*-------------------------------------------------------------------- * Reference a TCP pool given by {name, ip4, ip6} triplet. Create if * it doesn't exist already. */ @@ -121,6 +182,8 @@ VBT_Ref(const char *name, const struct suckaddr *ip4, VTAILQ_INIT(&tp->connlist); VTAILQ_INIT(&tp->killlist); VTAILQ_INSERT_HEAD(&pools, tp, list); + tp->timeout = 60; + tp->waiter = Wait_New(tcp_handle, &tp->timeout); return (tp); } @@ -150,17 +213,21 @@ VBT_Rel(struct tcp_pool **tpp) VTAILQ_FOREACH_SAFE(vbc, &tp->connlist, list, vbc2) { VTAILQ_REMOVE(&tp->connlist, vbc, list); tp->n_conn--; + vbc->in_waiter = VBC_W_STOLEN; VTCP_close(&vbc->fd); FREE_OBJ(vbc); } VTAILQ_FOREACH_SAFE(vbc, &tp->killlist, list, vbc2) { VTAILQ_REMOVE(&tp->killlist, vbc, list); tp->n_kill--; + assert(vbc->in_waiter == VBC_W_STOLEN); // XXX ? VTCP_close(&vbc->fd); FREE_OBJ(vbc); } AZ(tp->n_conn); AZ(tp->n_kill); + Wait_Destroy(&tp->waiter); + FREE_OBJ(tp); } @@ -197,10 +264,13 @@ VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa) * Recycle a connection. */ +#include "vtim.h" + void VBT_Recycle(struct tcp_pool *tp, struct vbc **vbcp) { struct vbc *vbc; + int i = 0; CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); vbc = *vbcp; @@ -208,11 +278,59 @@ VBT_Recycle(struct tcp_pool *tp, struct vbc **vbcp) CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); Lck_Lock(&tp->mtx); - vbc->recycled = 1; - VTAILQ_INSERT_HEAD(&tp->connlist, vbc, list); - tp->n_conn++; + assert(vbc->fd > 0); tp->n_used--; + +VSL(SLT_Debug, 0, "------> Recycle fd %d in_w %d", vbc->fd, vbc->in_waiter); + switch (vbc->in_waiter) { + case VBC_W_NEW: + case VBC_W_NOWAIT: + vbc->in_waiter = VBC_W_INWAIT; + INIT_OBJ(vbc->waited, WAITED_MAGIC); + vbc->waited->ptr = vbc; + vbc->waited->fd = vbc->fd; + vbc->waited->idle = VTIM_real(); +VSL(SLT_Debug, 0, "------> Recycle fd %d Enter", vbc->fd); + if (Wait_Enter(tp->waiter, vbc->waited)) { + VTCP_close(&vbc->fd); + FREE_OBJ(vbc); + } else { + VTAILQ_INSERT_HEAD(&tp->connlist, vbc, list); + tp->n_conn++; + vbc->recycled = 1; + } + break; + case VBC_W_STOLEN: + /* + * We stole the fd from the waiter and it hasn't noticed + * this yet. + */ +VSL(SLT_Debug, 0, "------> Recycle fd %d Still Stolen -> Pending", vbc->fd); + vbc->in_waiter = VBC_W_PENDING; + VTAILQ_INSERT_HEAD(&tp->pendlist, vbc, list); + tp->n_pend++; + i = 1; + break; + default: + WRONG("Wrong vbc in_wait state"); + } Lck_Unlock(&tp->mtx); + if (i && DO_DEBUG(DBG_VTC_MODE)) { + /* + * In varnishtest we do not have the luxury of using + * multiple backend connections, so whenever we end up + * in the "pending" case, take a short nap to let the + * waiter catch up and put the vbc back into circulations. + * + * In particular ESI:include related tests suffer random + * failures without this. + * + * In normal operation, the only effect is that we will + * have N+1 backend connections rather than N, which is + * entirely harmless. + */ + (void)usleep(10000); + } } /*-------------------------------------------------------------------- @@ -230,9 +348,22 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp) CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); VTCP_close(&vbc->fd); - FREE_OBJ(vbc); + Lck_Lock(&tp->mtx); tp->n_used--; + switch (vbc->in_waiter) { + case VBC_W_NEW: + case VBC_W_NOWAIT: + FREE_OBJ(vbc); + break; + case VBC_W_STOLEN: + vbc->in_waiter = VBC_W_KILL; + VTAILQ_INSERT_HEAD(&tp->killlist, vbc, list); + tp->n_kill++; + break; + default: + WRONG("Wrong vbc in_waiter state"); + } Lck_Unlock(&tp->mtx); } @@ -246,7 +377,6 @@ VBT_Get(struct tcp_pool *tp, double tmo) struct vbc *vbc; struct pollfd pfd; - (void)tmo; CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); Lck_Lock(&tp->mtx); @@ -254,42 +384,42 @@ VBT_Get(struct tcp_pool *tp, double tmo) if (vbc != NULL) { CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); + assert(vbc->in_waiter == VBC_W_INWAIT); + vbc->in_waiter = VBC_W_STOLEN; pfd.fd = vbc->fd; pfd.events = POLLIN; pfd.revents = 0; - if (poll(&pfd, 1, 0)) { + if (0 && poll(&pfd, 1, 0)) { // XXX /* * If this vbc is dead assume the rest of the list * has also been chopped from the other end. + * XXX: Not sure if this makes any sense with waiter */ VSC_C_main->backend_toolate++; do { VTAILQ_REMOVE(&tp->connlist, vbc, list); tp->n_conn--; -#if 0 + VTCP_close(&vbc->fd); + vbc->in_waiter = VBC_W_KILL; VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); tp->n_kill++; -#else - VTCP_close(&vbc->fd); - FREE_OBJ(vbc); -#endif vbc = VTAILQ_FIRST(&tp->connlist); } while (vbc != NULL); } else { VTAILQ_REMOVE(&tp->connlist, vbc, list); tp->n_conn--; - tp->n_used++; VSC_C_main->backend_reuse += 1; } } - if (vbc == NULL) - tp->n_used++; // Opening mostly works + tp->n_used++; // Opening mostly works Lck_Unlock(&tp->mtx); if (vbc != NULL) return (vbc); ALLOC_OBJ(vbc, VBC_MAGIC); + AN(vbc); + vbc->in_waiter = VBC_W_NEW; if (vbc != NULL) { vbc->fd = VBT_Open(tp, tmo, &vbc->addr); if (vbc->fd < 0) @@ -297,7 +427,7 @@ VBT_Get(struct tcp_pool *tp, double tmo) } if (vbc == NULL) { Lck_Lock(&tp->mtx); - tp->n_used--; + tp->n_used--; // Nope, didn't work after all. Lck_Unlock(&tp->mtx); } return (vbc); From phk at FreeBSD.org Fri Jan 23 09:15:25 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 10:15:25 +0100 Subject: [master] 0828ff5 Try to work around the epoll waiters weird policy of keeping listening. Message-ID: commit 0828ff5e54e73dfe59d882fbe9ff1cc5364e16f7 Author: Poul-Henning Kamp Date: Fri Jan 23 09:14:59 2015 +0000 Try to work around the epoll waiters weird policy of keeping listening. diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 23ada15..a622193 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -286,7 +286,6 @@ VSL(SLT_Debug, 0, "------> Recycle fd %d in_w %d", vbc->fd, vbc->in_waiter); case VBC_W_NEW: case VBC_W_NOWAIT: vbc->in_waiter = VBC_W_INWAIT; - INIT_OBJ(vbc->waited, WAITED_MAGIC); vbc->waited->ptr = vbc; vbc->waited->fd = vbc->fd; vbc->waited->idle = VTIM_real(); @@ -419,6 +418,7 @@ VBT_Get(struct tcp_pool *tp, double tmo) ALLOC_OBJ(vbc, VBC_MAGIC); AN(vbc); + INIT_OBJ(vbc->waited, WAITED_MAGIC); vbc->in_waiter = VBC_W_NEW; if (vbc != NULL) { vbc->fd = VBT_Open(tp, tmo, &vbc->addr); From phk at FreeBSD.org Fri Jan 23 09:30:49 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 10:30:49 +0100 Subject: [master] 1c406a2 Disable the epoll waiter temporarily to see if things work at least a little bit on Linux. Message-ID: commit 1c406a2252f412535f4948a6580a8d37d39283d5 Author: Poul-Henning Kamp Date: Fri Jan 23 09:30:28 2015 +0000 Disable the epoll waiter temporarily to see if things work at least a little bit on Linux. diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 18e370c..efa5942 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -43,7 +43,7 @@ static const struct waiter_impl *const waiter_impls[] = { &waiter_kqueue, #endif #if defined(HAVE_EPOLL_CTL) - &waiter_epoll, +// &waiter_epoll, #endif #if defined(HAVE_PORT_CREATE) &waiter_ports, From phk at FreeBSD.org Fri Jan 23 11:49:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 12:49:00 +0100 Subject: [master] 4d9f776 Convert pointers to uintptr_t before sticking them in the pipe. Message-ID: commit 4d9f776abfda4714fb1d1e5c060ef9a3c52bc2b5 Author: Poul-Henning Kamp Date: Fri Jan 23 10:36:52 2015 +0000 Convert pointers to uintptr_t before sticking them in the pipe. diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index ec8aebb..ab07081 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -182,6 +182,7 @@ int Wait_Enter(const struct waiter *w, struct waited *wp) { ssize_t written; + uintptr_t up; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); @@ -193,10 +194,12 @@ Wait_Enter(const struct waiter *w, struct waited *wp) assert(w->pipes[1] > 0); - written = write(w->pipes[1], &wp, sizeof wp); - if (written != sizeof wp && (errno == EAGAIN || errno == EWOULDBLOCK)) + up = (uintptr_t)wp; + AZ(up & 1); + written = write(w->pipes[1], &up, sizeof up); + if (written != sizeof up && (errno == EAGAIN || errno == EWOULDBLOCK)) return (-1); - assert (written == sizeof wp); + assert (written == sizeof up); return (0); } @@ -220,7 +223,8 @@ wait_updidle(struct waiter *w, double now) void Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) { - struct waited *ss[NEV], *wp2; + uintptr_t ss[NEV]; + struct waited *wp2; int i, j, dotimer = 0; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); @@ -245,15 +249,17 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) return; for (j = 0; i >= sizeof ss[0]; j++, i -= sizeof ss[0]) { - CHECK_OBJ_ORNULL(ss[j], WAITED_MAGIC); - if (ss[j] == NULL) { + if (ss[j] == 0) { AN(w->dismantle); - } else if (ss[j] == w->pipe_w) { + continue; + } + CAST_OBJ_NOTNULL(wp2, (void*)ss[j], WAITED_MAGIC); + if (wp2 == w->pipe_w) { dotimer = 1; } else { - assert(ss[j]->fd >= 0); - VTAILQ_INSERT_TAIL(&w->waithead, ss[j], list); - w->impl->inject(w, ss[j]); + assert(wp2->fd >= 0); + VTAILQ_INSERT_TAIL(&w->waithead, wp2, list); + w->impl->inject(w, wp2); } } AZ(i); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 81763a1..355ab38 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -88,6 +88,7 @@ vwp_inject(const struct waiter *w, struct waited *wp) CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); fd = wp->fd; +VSL(SLT_Debug, 0, "POLL Inject %d", fd); assert(fd >= 0); vwp_pollspace(vwp, (unsigned)fd); assert(fd < vwp->npoll); @@ -111,6 +112,7 @@ vwp_evict(const struct waiter *w, struct waited *wp) CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); fd = wp->fd; +VSL(SLT_Debug, 0, "POLL Evict %d", fd); assert(fd >= 0); assert(fd < vwp->npoll); vwp_pollspace(vwp, (unsigned)fd); @@ -151,6 +153,7 @@ vwp_main(void *priv) break; CHECK_OBJ_NOTNULL(sp, WAITED_MAGIC); fd = sp->fd; +VSL(SLT_Debug, 0, "POLL Handle %d %x", fd, vwp->pollfd[fd].revents); assert(fd >= 0); assert(fd <= vwp->hpoll); assert(fd < vwp->npoll); From phk at FreeBSD.org Fri Jan 23 11:49:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 12:49:00 +0100 Subject: [master] 6a04b34 Tell the waiter (if necessary) that we steal a filedescriptor, not all of them find out on their own. Message-ID: commit 6a04b34eb544d7f547de93d8c1700d6dd56fc031 Author: Poul-Henning Kamp Date: Fri Jan 23 11:48:31 2015 +0000 Tell the waiter (if necessary) that we steal a filedescriptor, not all of them find out on their own. diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index a622193..cf7110e 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -384,6 +384,8 @@ VBT_Get(struct tcp_pool *tp, double tmo) CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); assert(vbc->in_waiter == VBC_W_INWAIT); +VSL(SLT_Debug, 0, "------> Steal fd %d", vbc->fd); + Wait_Steal(tp->waiter, vbc->waited); vbc->in_waiter = VBC_W_STOLEN; pfd.fd = vbc->fd; pfd.events = POLLIN; diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index ab07081..f609b06 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -203,6 +203,36 @@ Wait_Enter(const struct waiter *w, struct waited *wp) return (0); } +int +Wait_Steal(const struct waiter *w, struct waited *wp) +{ + ssize_t written; + uintptr_t up; + + CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); + CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); + assert(wp->fd > 0); // stdin never comes here + AZ(w->dismantle); + + if (w->impl->pass != NULL) { + INCOMPL(); + } + + assert(w->pipes[1] > 0); + + if (w->impl->evict == NULL) + return (0); + + up = (uintptr_t)wp; + AZ(up & 1); + up |= 1; + written = write(w->pipes[1], &up, sizeof up); + if (written != sizeof up && (errno == EAGAIN || errno == EWOULDBLOCK)) + return (-1); + assert (written == sizeof up); + return (0); +} + static void wait_updidle(struct waiter *w, double now) { @@ -226,6 +256,7 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) uintptr_t ss[NEV]; struct waited *wp2; int i, j, dotimer = 0; + int steal; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); @@ -253,9 +284,17 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) AN(w->dismantle); continue; } + steal = ss[j] & 1; + ss[j] &= ~1; CAST_OBJ_NOTNULL(wp2, (void*)ss[j], WAITED_MAGIC); if (wp2 == w->pipe_w) { dotimer = 1; + } else if (steal) { + assert(wp2->fd >= 0); + VTAILQ_REMOVE(&w->waithead, wp2, list); + AN (w->impl->evict); + w->impl->evict(w, wp2); + w->func(wp2, WAITER_ACTION, now); } else { assert(wp2->fd >= 0); VTAILQ_INSERT_TAIL(&w->waithead, wp2, list); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index d371d7e..0e4b263 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -99,6 +99,17 @@ vwk_inject(const struct waiter *w, struct waited *wp) vwk_kq_sess(vwk, wp, EV_ADD | EV_ONESHOT); } +#if 0 +static void +vwk_evict(const struct waiter *w, struct waited *wp) +{ + struct vwk *vwk; + + CAST_OBJ_NOTNULL(vwk, w->priv, VWK_MAGIC); + vwk_kq_sess(vwk, wp, EV_DELETE); +} +#endif + /*--------------------------------------------------------------------*/ static void @@ -193,6 +204,7 @@ const struct waiter_impl waiter_kqueue = { .init = vwk_init, .fini = vwk_fini, .inject = vwk_inject, + // .evict = vwk_evict, .size = sizeof(struct vwk), }; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 953df8e..31923d7 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -58,6 +58,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now); /* cache_waiter.c */ int Wait_Enter(const struct waiter *, struct waited *); +int Wait_Steal(const struct waiter *, struct waited *); struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout); void Wait_Destroy(struct waiter **); const char *Wait_GetName(void); From phk at FreeBSD.org Fri Jan 23 12:15:16 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 23 Jan 2015 13:15:16 +0100 Subject: [master] dcf2a20 Remove unwarranted asserts. Message-ID: commit dcf2a20614716f76a8ed2b0dc61aa418f32f4373 Author: Poul-Henning Kamp Date: Fri Jan 23 12:15:04 2015 +0000 Remove unwarranted asserts. diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 355ab38..bcdf797 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -117,10 +117,6 @@ VSL(SLT_Debug, 0, "POLL Evict %d", fd); assert(fd < vwp->npoll); vwp_pollspace(vwp, (unsigned)fd); - assert(vwp->pollfd[fd].fd == fd); - assert(vwp->pollfd[fd].events == POLLIN); - AZ(vwp->pollfd[fd].revents); - vwp->pollfd[fd].fd = -1; vwp->pollfd[fd].events = 0; } From arianna.aondio at varnish-software.com Fri Jan 23 12:20:42 2015 From: arianna.aondio at varnish-software.com (arianna-aondio) Date: Fri, 23 Jan 2015 13:20:42 +0100 Subject: [master] e819618 Varnishncsa logs the first value if on request side and uses the last entry if on delivery side. Message-ID: commit e819618961324937a1c8b6d45db36d2287a5ffa9 Author: arianna-aondio Date: Fri Jan 23 13:19:16 2015 +0100 Varnishncsa logs the first value if on request side and uses the last entry if on delivery side. Fixes #1462 diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index d61a421..69e4129 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -699,7 +699,7 @@ isprefix(const char *str, const char *prefix, const char *end, } static void -frag_fields(const char *b, const char *e, ...) +frag_fields(int force, const char *b, const char *e, ...) { va_list ap; const char *p, *q; @@ -726,7 +726,7 @@ frag_fields(const char *b, const char *e, ...) q++; if (field == n) { - if (frag->gen != CTX.gen) { + if (frag->gen != CTX.gen || !force) { /* We only grab the same matching field once */ frag->gen = CTX.gen; frag->b = p; @@ -742,10 +742,10 @@ frag_fields(const char *b, const char *e, ...) } static void -frag_line(const char *b, const char *e, struct fragment *f) +frag_line(int force, const char *b, const char *e, struct fragment *f) { - if (f->gen == CTX.gen) + if (f->gen == CTX.gen && !force) /* We only grab the same matching record once */ return; @@ -770,7 +770,7 @@ process_hdr(const struct watch_head *head, const char *b, const char *e) VTAILQ_FOREACH(w, head, list) { if (strncasecmp(b, w->key, w->keylen)) continue; - frag_line(b + w->keylen, e, &w->frag); + frag_line(0, b + w->keylen, e, &w->frag); } } @@ -783,7 +783,6 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], const char *b, *e, *p; struct watch *w; int i, skip; - (void)vsl; (void)priv; @@ -810,32 +809,34 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], skip = 1; break; case SLT_PipeAcct: - frag_fields(b, e, + frag_fields(0, b, e, 3, &CTX.frag[F_I], 4, &CTX.frag[F_O], 0, NULL); break; case SLT_ReqStart: - frag_fields(b, e, 1, &CTX.frag[F_h], 0, NULL); + frag_fields(0, b, e, + 1, &CTX.frag[F_h], + 0, NULL); break; case SLT_ReqMethod: - frag_line(b, e, &CTX.frag[F_m]); + frag_line(0, b, e, &CTX.frag[F_m]); break; case SLT_ReqURL: p = memchr(b, '?', e - b); if (p == NULL) p = e; - frag_line(b, p, &CTX.frag[F_U]); - frag_line(p, e, &CTX.frag[F_q]); + frag_line(0, b, p, &CTX.frag[F_U]); + frag_line(0, p, e, &CTX.frag[F_q]); break; case SLT_ReqProtocol: - frag_line(b, e, &CTX.frag[F_H]); + frag_line(0, b, e, &CTX.frag[F_H]); break; case SLT_RespStatus: - frag_line(b, e, &CTX.frag[F_s]); + frag_line(1, b, e, &CTX.frag[F_s]); break; case SLT_ReqAcct: - frag_fields(b, e, + frag_fields(0, b, e, 3, &CTX.frag[F_I], 5, &CTX.frag[F_b], 6, &CTX.frag[F_O], @@ -843,26 +844,26 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], break; case SLT_Timestamp: if (isprefix(b, "Start:", e, &p)) { - frag_fields(p, e, 1, + frag_fields(0, p, e, 1, &CTX.frag[F_tstart], 0, NULL); } else if (isprefix(b, "Resp:", e, &p) || isprefix(b, "PipeSess:", e, &p)) { - frag_fields(p, e, 1, + frag_fields(0, p, e, 1, &CTX.frag[F_tend], 0, NULL); } else if (isprefix(b, "Process:", e, &p) || isprefix(b, "Pipe:", e, &p)) { - frag_fields(p, e, 2, + frag_fields(0, p, e, 2, &CTX.frag[F_ttfb], 0, NULL); } break; case SLT_ReqHeader: if (isprefix(b, "Host:", e, &p)) - frag_line(p, e, &CTX.frag[F_host]); + frag_line(0, p, e, &CTX.frag[F_host]); else if (isprefix(b, "Authorization:", e, &p) && isprefix(p, "basic", e, &p)) - frag_line(p, e, &CTX.frag[F_auth]); + frag_line(0, p, e, &CTX.frag[F_auth]); break; case SLT_VCL_call: if (!strcasecmp(b, "recv")) { @@ -896,7 +897,6 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], default: break; } - if (tag == SLT_VCL_Log) { VTAILQ_FOREACH(w, &CTX.watch_vcl_log, list) { CHECK_OBJ_NOTNULL(w, WATCH_MAGIC); @@ -908,7 +908,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], p++; if (p > e) continue; - frag_line(p, e, &w->frag); + frag_line(0, p, e, &w->frag); } } if (tag == SLT_ReqHeader) From martin at varnish-software.com Mon Jan 26 09:40:42 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 26 Jan 2015 10:40:42 +0100 Subject: [master] e8d8934 Fix logic in frag_fields Message-ID: commit e8d89346031864ab3221bccd9538f711a134bd04 Author: Martin Blix Grydeland Date: Mon Jan 26 10:40:39 2015 +0100 Fix logic in frag_fields diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 69e4129..f6f9bc8 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -726,7 +726,7 @@ frag_fields(int force, const char *b, const char *e, ...) q++; if (field == n) { - if (frag->gen != CTX.gen || !force) { + if (frag->gen != CTX.gen || force) { /* We only grab the same matching field once */ frag->gen = CTX.gen; frag->b = p; From phk at FreeBSD.org Mon Jan 26 15:06:53 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 26 Jan 2015 16:06:53 +0100 Subject: [master] ef03e1c Try another strategy to marry waiters to backend connection pools. Message-ID: commit ef03e1c40707fc0bd15dee63d6550897b1be944d Author: Poul-Henning Kamp Date: Mon Jan 26 15:06:26 2015 +0000 Try another strategy to marry waiters to backend connection pools. diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index ff3b187..339e19a 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -84,15 +84,6 @@ struct backend { /* -------------------------------------------------------------------*/ -enum vbc_waiter { - VBC_W_NEW, - VBC_W_INWAIT, - VBC_W_STOLEN, - VBC_W_NOWAIT, - VBC_W_PENDING, - VBC_W_KILL, -}; - /* Backend connection */ struct vbc { unsigned magic; @@ -101,7 +92,12 @@ struct vbc { int fd; const struct suckaddr *addr; uint8_t recycled; - enum vbc_waiter in_waiter; + uint8_t state; +#define VBC_STATE_AVAIL (1<<0) +#define VBC_STATE_USED (1<<1) +#define VBC_STATE_CLEANUP (1<<2) + uint8_t in_waiter; + uint8_t stolen; struct waited waited[1]; struct backend *backend; diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index cf7110e..644068b 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -47,6 +47,8 @@ #include "vtcp.h" #include "vsa.h" #include "waiter/waiter.h" +#include "vtim.h" + struct tcp_pool { unsigned magic; @@ -69,9 +71,6 @@ struct tcp_pool { VTAILQ_HEAD(, vbc) killlist; int n_kill; - VTAILQ_HEAD(, vbc) pendlist; - int n_pend; - int n_used; }; @@ -94,42 +93,44 @@ tcp_handle(struct waited *w, enum wait_event ev, double now) tp = vbc->backend->tcp_pool; // NB: Incestous Lck_Lock(&tp->mtx); - switch (vbc->in_waiter) { - case VBC_W_KILL: -VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d KILL", - vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); + AN(vbc->in_waiter); +VSL(SLT_Debug, 0, "------> Handler fd %d in_w %d state %d ev %d stolen %d", vbc->fd, vbc->in_waiter, vbc->state, ev, vbc->stolen); + + switch(vbc->state) { + case VBC_STATE_AVAIL: + if (ev != WAITER_ACTION || !vbc->stolen) { +VSL(SLT_Debug, 0, "------> Handler avail + !action -> close"); + VTCP_close(&vbc->fd); + VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; + FREE_OBJ(vbc); + } else { +VSL(SLT_Debug, 0, "------> Handler avail + action -> re-wait"); + vbc->stolen = 0; + if (Wait_Enter(tp->waiter, vbc->waited)) { +VSL(SLT_Debug, 0, "------> Handler avail + !timeout -> re-wait failed"); + VTCP_close(&vbc->fd); + VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; + FREE_OBJ(vbc); + } + } + break; + case VBC_STATE_USED: +VSL(SLT_Debug, 0, "------> Handler used"); + vbc->in_waiter = 0; + break; + case VBC_STATE_CLEANUP: +VSL(SLT_Debug, 0, "------> Handler cleanup"); assert(vbc->fd < 0); tp->n_kill--; VTAILQ_REMOVE(&tp->killlist, vbc, list); FREE_OBJ(vbc); break; - case VBC_W_PENDING: -VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d PENDING", - vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); - vbc->in_waiter = VBC_W_NOWAIT; - VTAILQ_REMOVE(&tp->pendlist, vbc, list); - tp->n_pend--; - break; - case VBC_W_STOLEN: -VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d STOLEN", - vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); - vbc->in_waiter = VBC_W_NOWAIT; - vbc = NULL; - break; - case VBC_W_INWAIT: -VSL(SLT_Debug, 0, "==========> Handle %s fd %d iw %d ev %d INWAIT", - vbc->backend->vcl_name, vbc->fd, vbc->in_waiter, ev); - VTCP_close(&vbc->fd); - VTAILQ_REMOVE(&tp->connlist, vbc, list); - tp->n_conn--; - FREE_OBJ(vbc); - break; default: - WRONG("Wrong vbc in_wait state"); + WRONG("Wrong vbc state"); } Lck_Unlock(&tp->mtx); - if (vbc != NULL) - VBT_Recycle(tp, &vbc); } /*-------------------------------------------------------------------- @@ -209,21 +210,26 @@ VBT_Rel(struct tcp_pool **tpp) free(tp->name); free(tp->ip4); free(tp->ip6); - Lck_Delete(&tp->mtx); + Lck_Lock(&tp->mtx); VTAILQ_FOREACH_SAFE(vbc, &tp->connlist, list, vbc2) { VTAILQ_REMOVE(&tp->connlist, vbc, list); tp->n_conn--; - vbc->in_waiter = VBC_W_STOLEN; + vbc->state = VBC_STATE_CLEANUP; VTCP_close(&vbc->fd); - FREE_OBJ(vbc); + if (vbc->in_waiter) { + VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); + tp->n_kill++; + } else { + FREE_OBJ(vbc); + } } - VTAILQ_FOREACH_SAFE(vbc, &tp->killlist, list, vbc2) { - VTAILQ_REMOVE(&tp->killlist, vbc, list); - tp->n_kill--; - assert(vbc->in_waiter == VBC_W_STOLEN); // XXX ? - VTCP_close(&vbc->fd); - FREE_OBJ(vbc); + while (tp->n_kill) { + Lck_Unlock(&tp->mtx); + (void)usleep(20000); + Lck_Lock(&tp->mtx); } + Lck_Unlock(&tp->mtx); + Lck_Delete(&tp->mtx); AZ(tp->n_conn); AZ(tp->n_kill); Wait_Destroy(&tp->waiter); @@ -264,8 +270,6 @@ VBT_Open(struct tcp_pool *tp, double tmo, const struct suckaddr **sa) * Recycle a connection. */ -#include "vtim.h" - void VBT_Recycle(struct tcp_pool *tp, struct vbc **vbcp) { @@ -277,41 +281,33 @@ VBT_Recycle(struct tcp_pool *tp, struct vbc **vbcp) *vbcp = NULL; CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); - Lck_Lock(&tp->mtx); + assert(vbc->state == VBC_STATE_USED); assert(vbc->fd > 0); + + Lck_Lock(&tp->mtx); tp->n_used--; VSL(SLT_Debug, 0, "------> Recycle fd %d in_w %d", vbc->fd, vbc->in_waiter); - switch (vbc->in_waiter) { - case VBC_W_NEW: - case VBC_W_NOWAIT: - vbc->in_waiter = VBC_W_INWAIT; + + if (!vbc->in_waiter) { + vbc->in_waiter = 1; vbc->waited->ptr = vbc; vbc->waited->fd = vbc->fd; vbc->waited->idle = VTIM_real(); -VSL(SLT_Debug, 0, "------> Recycle fd %d Enter", vbc->fd); +VSL(SLT_Debug, 0, "------> Recycle fd %d Wait_Enter", vbc->fd); if (Wait_Enter(tp->waiter, vbc->waited)) { VTCP_close(&vbc->fd); FREE_OBJ(vbc); - } else { - VTAILQ_INSERT_HEAD(&tp->connlist, vbc, list); - tp->n_conn++; - vbc->recycled = 1; } - break; - case VBC_W_STOLEN: - /* - * We stole the fd from the waiter and it hasn't noticed - * this yet. - */ -VSL(SLT_Debug, 0, "------> Recycle fd %d Still Stolen -> Pending", vbc->fd); - vbc->in_waiter = VBC_W_PENDING; - VTAILQ_INSERT_HEAD(&tp->pendlist, vbc, list); - tp->n_pend++; i = 1; - break; - default: - WRONG("Wrong vbc in_wait state"); + } + + if (vbc != NULL) { + vbc->state = VBC_STATE_AVAIL; + vbc->stolen = 1; + VTAILQ_INSERT_HEAD(&tp->connlist, vbc, list); + tp->n_conn++; + vbc->recycled = 1; } Lck_Unlock(&tp->mtx); if (i && DO_DEBUG(DBG_VTC_MODE)) { @@ -346,22 +342,19 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp) *vbcp = NULL; CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); - VTCP_close(&vbc->fd); + assert(vbc->state == VBC_STATE_USED); + assert(vbc->fd > 0); +VSL(SLT_Debug, 0, "------> Close fd %d in_w %d", vbc->fd, vbc->in_waiter); + VTCP_close(&vbc->fd); Lck_Lock(&tp->mtx); tp->n_used--; - switch (vbc->in_waiter) { - case VBC_W_NEW: - case VBC_W_NOWAIT: - FREE_OBJ(vbc); - break; - case VBC_W_STOLEN: - vbc->in_waiter = VBC_W_KILL; + if (vbc->in_waiter) { + vbc->state = VBC_STATE_CLEANUP; VTAILQ_INSERT_HEAD(&tp->killlist, vbc, list); tp->n_kill++; - break; - default: - WRONG("Wrong vbc in_waiter state"); + } else { + FREE_OBJ(vbc); } Lck_Unlock(&tp->mtx); } @@ -374,7 +367,6 @@ struct vbc * VBT_Get(struct tcp_pool *tp, double tmo) { struct vbc *vbc; - struct pollfd pfd; CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC); @@ -383,34 +375,13 @@ VBT_Get(struct tcp_pool *tp, double tmo) if (vbc != NULL) { CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); - assert(vbc->in_waiter == VBC_W_INWAIT); + assert(vbc->state == VBC_STATE_AVAIL); VSL(SLT_Debug, 0, "------> Steal fd %d", vbc->fd); - Wait_Steal(tp->waiter, vbc->waited); - vbc->in_waiter = VBC_W_STOLEN; - pfd.fd = vbc->fd; - pfd.events = POLLIN; - pfd.revents = 0; - if (0 && poll(&pfd, 1, 0)) { // XXX - /* - * If this vbc is dead assume the rest of the list - * has also been chopped from the other end. - * XXX: Not sure if this makes any sense with waiter - */ - VSC_C_main->backend_toolate++; - do { - VTAILQ_REMOVE(&tp->connlist, vbc, list); - tp->n_conn--; - VTCP_close(&vbc->fd); - vbc->in_waiter = VBC_W_KILL; - VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); - tp->n_kill++; - vbc = VTAILQ_FIRST(&tp->connlist); - } while (vbc != NULL); - } else { - VTAILQ_REMOVE(&tp->connlist, vbc, list); - tp->n_conn--; - VSC_C_main->backend_reuse += 1; - } + + VTAILQ_REMOVE(&tp->connlist, vbc, list); + tp->n_conn--; + VSC_C_main->backend_reuse += 1; + vbc->state = VBC_STATE_USED; } tp->n_used++; // Opening mostly works Lck_Unlock(&tp->mtx); @@ -421,16 +392,16 @@ VSL(SLT_Debug, 0, "------> Steal fd %d", vbc->fd); ALLOC_OBJ(vbc, VBC_MAGIC); AN(vbc); INIT_OBJ(vbc->waited, WAITED_MAGIC); - vbc->in_waiter = VBC_W_NEW; - if (vbc != NULL) { - vbc->fd = VBT_Open(tp, tmo, &vbc->addr); - if (vbc->fd < 0) - FREE_OBJ(vbc); - } + vbc->state = VBC_STATE_USED; + vbc->fd = VBT_Open(tp, tmo, &vbc->addr); + if (vbc->fd < 0) + FREE_OBJ(vbc); if (vbc == NULL) { +VSL(SLT_Debug, 0, "------> No new fd"); Lck_Lock(&tp->mtx); tp->n_used--; // Nope, didn't work after all. Lck_Unlock(&tp->mtx); - } + } else +VSL(SLT_Debug, 0, "------> New fd %d", vbc->fd); return (vbc); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index f609b06..0120d13 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -195,37 +195,6 @@ Wait_Enter(const struct waiter *w, struct waited *wp) assert(w->pipes[1] > 0); up = (uintptr_t)wp; - AZ(up & 1); - written = write(w->pipes[1], &up, sizeof up); - if (written != sizeof up && (errno == EAGAIN || errno == EWOULDBLOCK)) - return (-1); - assert (written == sizeof up); - return (0); -} - -int -Wait_Steal(const struct waiter *w, struct waited *wp) -{ - ssize_t written; - uintptr_t up; - - CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); - CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - assert(wp->fd > 0); // stdin never comes here - AZ(w->dismantle); - - if (w->impl->pass != NULL) { - INCOMPL(); - } - - assert(w->pipes[1] > 0); - - if (w->impl->evict == NULL) - return (0); - - up = (uintptr_t)wp; - AZ(up & 1); - up |= 1; written = write(w->pipes[1], &up, sizeof up); if (written != sizeof up && (errno == EAGAIN || errno == EWOULDBLOCK)) return (-1); @@ -256,24 +225,33 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) uintptr_t ss[NEV]; struct waited *wp2; int i, j, dotimer = 0; - int steal; CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); - CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - - if (wp != w->pipe_w) { - if (w->impl->evict != NULL) - w->impl->evict(w, wp); + CHECK_OBJ_ORNULL(wp, WAITED_MAGIC); + + if (wp != NULL) { + if (wp == w->pipe_w) { + w->do_pipe = 1; + VTAILQ_REMOVE(&w->waithead, w->pipe_w, list); + wp->idle = now; + VTAILQ_INSERT_TAIL(&w->waithead, w->pipe_w, list); + } else { + if (w->impl->evict != NULL) + w->impl->evict(w, wp); - VTAILQ_REMOVE(&w->waithead, wp, list); - w->func(wp, ev, now); - wait_updidle(w, now); + VTAILQ_REMOVE(&w->waithead, wp, list); + w->func(wp, ev, now); + wait_updidle(w, now); + } return; } - VTAILQ_REMOVE(&w->waithead, wp, list); - wp->idle = now; - VTAILQ_INSERT_TAIL(&w->waithead, wp, list); + AZ(wp); + + if (!w->do_pipe) + return; + + w->do_pipe = 0; i = read(w->pipes[0], ss, sizeof ss); if (i == -1 && errno == EAGAIN) @@ -284,17 +262,10 @@ Wait_Handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now) AN(w->dismantle); continue; } - steal = ss[j] & 1; ss[j] &= ~1; CAST_OBJ_NOTNULL(wp2, (void*)ss[j], WAITED_MAGIC); if (wp2 == w->pipe_w) { dotimer = 1; - } else if (steal) { - assert(wp2->fd >= 0); - VTAILQ_REMOVE(&w->waithead, wp2, list); - AN (w->impl->evict); - w->impl->evict(w, wp2); - w->func(wp2, WAITER_ACTION, now); } else { assert(wp2->fd >= 0); VTAILQ_INSERT_TAIL(&w->waithead, wp2, list); diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index f7f1edb..ef4055e 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -118,6 +118,7 @@ vwe_thread(void *priv) now = VTIM_real(); for (ep = ev, i = 0; i < n; i++, ep++) vwe_eev(vwe, ep, now); + Wait_Handle(vwe->waiter, NULL, WAITER_ACTION, now); } return (NULL); } diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 0e4b263..7fd8685 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -116,16 +116,19 @@ static void vwk_sess_ev(const struct vwk *vwk, const struct kevent *kp, double now) { struct waited *sp; + double idle; AN(kp->udata); CAST_OBJ_NOTNULL(sp, kp->udata, WAITED_MAGIC); + idle = now - *vwk->waiter->tmo; + if (kp->data > 0) { Wait_Handle(vwk->waiter, sp, WAITER_ACTION, now); - return; + } else if (sp->idle <= idle) { + Wait_Handle(vwk->waiter, sp, WAITER_TIMEOUT, now); } else if (kp->flags & EV_EOF) { Wait_Handle(vwk->waiter, sp, WAITER_REMCLOSE, now); - return; } else { WRONG("unknown kqueue state"); } @@ -160,6 +163,7 @@ vwk_thread(void *priv) assert(kp->filter == EVFILT_READ); vwk_sess_ev(vwk, kp, now); } + Wait_Handle(vwk->waiter, NULL, WAITER_ACTION, now); } NEEDLESS_RETURN(NULL); } @@ -204,7 +208,6 @@ const struct waiter_impl waiter_kqueue = { .init = vwk_init, .fini = vwk_fini, .inject = vwk_inject, - // .evict = vwk_evict, .size = sizeof(struct vwk), }; diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index bcdf797..b604ca4 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -164,6 +164,7 @@ VSL(SLT_Debug, 0, "POLL Handle %d %x", fd, vwp->pollfd[fd].revents); now); } } + Wait_Handle(vwp->waiter, NULL, WAITER_ACTION, now); } NEEDLESS_RETURN(NULL); } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 31923d7..953df8e 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -58,7 +58,6 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now); /* cache_waiter.c */ int Wait_Enter(const struct waiter *, struct waited *); -int Wait_Steal(const struct waiter *, struct waited *); struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout); void Wait_Destroy(struct waiter **); const char *Wait_GetName(void); diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index d83d369..f21e0ae 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -43,6 +43,7 @@ struct waiter { int pipes[2]; struct waited *pipe_w; double next_idle; + int do_pipe; volatile double *tmo; VTAILQ_HEAD(,waited) waithead; From phk at FreeBSD.org Mon Jan 26 15:16:42 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 26 Jan 2015 16:16:42 +0100 Subject: [master] 6924df1 Always close under the mutex Message-ID: commit 6924df1382ae4c18e7804b724fd0a49b7f6c0f24 Author: Poul-Henning Kamp Date: Mon Jan 26 15:16:33 2015 +0000 Always close under the mutex diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 644068b..24ff61b 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -346,8 +346,8 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp) assert(vbc->fd > 0); VSL(SLT_Debug, 0, "------> Close fd %d in_w %d", vbc->fd, vbc->in_waiter); - VTCP_close(&vbc->fd); Lck_Lock(&tp->mtx); + VTCP_close(&vbc->fd); tp->n_used--; if (vbc->in_waiter) { vbc->state = VBC_STATE_CLEANUP; From phk at FreeBSD.org Tue Jan 27 09:48:07 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 27 Jan 2015 10:48:07 +0100 Subject: [master] ec5a9a3 Only shutdown(SHUT_WR) sockets put on the kill list, that way the waiter still has a FD to work with. Message-ID: commit ec5a9a3d95842cafccd6ffb56419ab98bac46d63 Author: Poul-Henning Kamp Date: Tue Jan 27 09:47:46 2015 +0000 Only shutdown(SHUT_WR) sockets put on the kill list, that way the waiter still has a FD to work with. diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index 24ff61b..70ae011 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -122,7 +122,7 @@ VSL(SLT_Debug, 0, "------> Handler used"); break; case VBC_STATE_CLEANUP: VSL(SLT_Debug, 0, "------> Handler cleanup"); - assert(vbc->fd < 0); + VTCP_close(&vbc->fd); tp->n_kill--; VTAILQ_REMOVE(&tp->killlist, vbc, list); FREE_OBJ(vbc); @@ -214,12 +214,13 @@ VBT_Rel(struct tcp_pool **tpp) VTAILQ_FOREACH_SAFE(vbc, &tp->connlist, list, vbc2) { VTAILQ_REMOVE(&tp->connlist, vbc, list); tp->n_conn--; - vbc->state = VBC_STATE_CLEANUP; - VTCP_close(&vbc->fd); if (vbc->in_waiter) { + vbc->state = VBC_STATE_CLEANUP; + shutdown(vbc->fd, SHUT_WR); VTAILQ_INSERT_TAIL(&tp->killlist, vbc, list); tp->n_kill++; } else { + VTCP_close(&vbc->fd); FREE_OBJ(vbc); } } @@ -347,13 +348,14 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp) VSL(SLT_Debug, 0, "------> Close fd %d in_w %d", vbc->fd, vbc->in_waiter); Lck_Lock(&tp->mtx); - VTCP_close(&vbc->fd); tp->n_used--; if (vbc->in_waiter) { + shutdown(vbc->fd, SHUT_WR); vbc->state = VBC_STATE_CLEANUP; VTAILQ_INSERT_HEAD(&tp->killlist, vbc, list); tp->n_kill++; } else { + VTCP_close(&vbc->fd); FREE_OBJ(vbc); } Lck_Unlock(&tp->mtx); From phk at FreeBSD.org Tue Jan 27 10:19:16 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 27 Jan 2015 11:19:16 +0100 Subject: [master] 757aef1 Re-enable the epoll waiter Message-ID: commit 757aef1ff269365df51a4d8e0a1261089419e5c2 Author: Poul-Henning Kamp Date: Tue Jan 27 10:19:04 2015 +0000 Re-enable the epoll waiter diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index ef4055e..3d55bc0 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -154,7 +154,8 @@ vwe_fini(struct waiter *w) CAST_OBJ_NOTNULL(vwe, w->priv, VWE_MAGIC); AZ(pthread_join(vwe->thread, &vp)); - WRONG("Not Yet Implemented"); + AZ(close(vwe->epfd)); + FREE_OBJ(vwe); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index efa5942..18e370c 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -43,7 +43,7 @@ static const struct waiter_impl *const waiter_impls[] = { &waiter_kqueue, #endif #if defined(HAVE_EPOLL_CTL) -// &waiter_epoll, + &waiter_epoll, #endif #if defined(HAVE_PORT_CREATE) &waiter_ports, From phk at FreeBSD.org Tue Jan 27 10:32:11 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 27 Jan 2015 11:32:11 +0100 Subject: [master] 2685b98 Forgot how the waiter soft-c was allocated. Message-ID: commit 2685b989082ccaaab03ca3173a5e602a43e6a25e Author: Poul-Henning Kamp Date: Tue Jan 27 10:31:55 2015 +0000 Forgot how the waiter soft-c was allocated. diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 3d55bc0..0778d43 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -155,7 +155,6 @@ vwe_fini(struct waiter *w) AZ(pthread_join(vwe->thread, &vp)); AZ(close(vwe->epfd)); - FREE_OBJ(vwe); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Tue Jan 27 10:51:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 27 Jan 2015 11:51:29 +0100 Subject: [master] dc1059d Add a rudimentary number comparison feature, to avoid failures like: Message-ID: commit dc1059daf2c83e05468aea2f72692e6e1a63bf70 Author: Poul-Henning Kamp Date: Tue Jan 27 10:50:56 2015 +0000 Add a rudimentary number comparison feature, to avoid failures like: ---- c1 11.6 EXPECT resp.http.ageB (11.867) >= "8.000" failed diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc index a00f001..d656b84 100644 --- a/bin/varnishtest/tests/r00956.vtc +++ b/bin/varnishtest/tests/r00956.vtc @@ -36,9 +36,9 @@ client c1 { expect resp.bodylen == 40 expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo <= 8.000 + expect resp.http.foo .LE. 8.000 expect resp.http.ageA == 4.000 - expect resp.http.ageB >= 6.000 + expect resp.http.ageB .GE. 6.000 delay 2 txreq @@ -46,7 +46,7 @@ client c1 { expect resp.bodylen == 40 expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo <= 6.000 + expect resp.http.foo .LE. 6.000 expect resp.http.ageA == 4.000 - expect resp.http.ageB >= 8.000 + expect resp.http.ageB .GE. 8.000 } -run diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index c397cb7..0612397 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -279,6 +279,14 @@ cmd_http_expect(CMD_ARGS) retval = strcmp(lhs, rhs) >= 0; } else if (!strcmp(cmp, ">")) { retval = strcmp(lhs, rhs) > 0; + } else if (!strcmp(cmp, ".LT.")) { + retval = strtod(lhs, NULL) < strtod(rhs, NULL); + } else if (!strcmp(cmp, ".GT.")) { + retval = strtod(lhs, NULL) > strtod(rhs, NULL); + } else if (!strcmp(cmp, ".LE.")) { + retval = strtod(lhs, NULL) <= strtod(rhs, NULL); + } else if (!strcmp(cmp, ".GE.")) { + retval = strtod(lhs, NULL) >= strtod(rhs, NULL); } if (retval == -1) From lkarsten at varnish-software.com Tue Jan 27 12:48:24 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 13:48:24 +0100 Subject: [master] 679f823 Use install instead of cp. Message-ID: commit 679f823108abe3e9710adb8f514120eb56f0a128 Author: Lasse Karstensen Date: Tue Jan 27 13:48:01 2015 +0100 Use install instead of cp. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 0ec3328..68126c6 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -164,11 +164,11 @@ reference: BUILT_SOURCES += reference reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst - cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ + install -D $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ + install -D $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From lkarsten at varnish-software.com Tue Jan 27 12:52:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 13:52:20 +0100 Subject: [4.0] 5fd1fcb Prepare 4.0.3-rc2. Message-ID: commit 5fd1fcbea616e7bce874fd659fa9eaed5f3cf555 Author: Lasse Karstensen Date: Tue Jan 27 13:25:32 2015 +0100 Prepare 4.0.3-rc2. diff --git a/doc/changes.rst b/doc/changes.rst index ba50deb..43188cd 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,5 +1,5 @@ ================================================ -Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-22) +Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-27) ================================================ Changes since 4.0.3-rc1: From lkarsten at varnish-software.com Tue Jan 27 12:52:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 13:52:20 +0100 Subject: [4.0] 99a676a Correct forgotten references to bug reports. Message-ID: commit 99a676adff6c81491d512e27e955cdd3f6207738 Author: Lasse Karstensen Date: Tue Jan 27 13:41:52 2015 +0100 Correct forgotten references to bug reports. I will have to retag 4.0.3-rc2 because of this. diff --git a/doc/changes.rst b/doc/changes.rst index 43188cd..6c3d0d4 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -16,6 +16,14 @@ Bugs fixed - 1629_ - Ditch rest of waiting list on failure to reschedule. - 1660_ - Don't attempt range delivery on a synth response +.. _1479: https://www.varnish-cache.org/trac/ticket/1479 +.. _1616: https://www.varnish-cache.org/trac/ticket/1616 +.. _1620: https://www.varnish-cache.org/trac/ticket/1620 +.. _1621: https://www.varnish-cache.org/trac/ticket/1621 +.. _1628: https://www.varnish-cache.org/trac/ticket/1628 +.. _1629: https://www.varnish-cache.org/trac/ticket/1629 +.. _1660: https://www.varnish-cache.org/trac/ticket/1660 + ============================================ Changes from 4.0.2 to 4.0.3-rc1 (2015-01-15) From lkarsten at varnish-software.com Tue Jan 27 12:52:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 13:52:20 +0100 Subject: [4.0] 82e5615 Remove reference only valid in master. Message-ID: commit 82e5615433d4189ce2f55bc87af37e8a4bc1e683 Author: Lasse Karstensen Date: Tue Jan 27 13:46:13 2015 +0100 Remove reference only valid in master. diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index cd78355..7b38812 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -7,9 +7,6 @@ Built in subroutines Various built-in subroutines are called during processing of client- and backend requests as well as upon ``vcl.load`` and ``vcl.discard``. -See :ref:`reference-states` for a defailed graphical overview of the -states and how they relate to core code functions and VCL subroutines. - ----------- client side ----------- From lkarsten at varnish-software.com Tue Jan 27 12:52:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 13:52:20 +0100 Subject: [4.0] ac3bbf0 Use install instead of cp. Message-ID: commit ac3bbf095f9eb842b0d92714666ca5953e6afee1 Author: Lasse Karstensen Date: Tue Jan 27 13:48:01 2015 +0100 Use install instead of cp. Conflicts: doc/sphinx/Makefile.am diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index c872ddd..dbc9e49 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -148,12 +148,12 @@ reference: test -d $@ || mkdir $@ BUILT_SOURCES += reference -reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst - cp $? $@ +reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst + install -D $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst -reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - cp $? $@ +reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst + install -D $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From lkarsten at varnish-software.com Tue Jan 27 13:17:07 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 14:17:07 +0100 Subject: [4.0] 1c64de2 Update to 4.0.3-rc2 in redhat packaging file. Message-ID: commit 1c64de28f8b0be16dc0195cb5116e26bab936756 Author: Lasse Karstensen Date: Tue Jan 27 14:08:36 2015 +0100 Update to 4.0.3-rc2 in redhat packaging file. diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 44f0b93..3491bf0 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,4 +1,4 @@ -%define v_rc rc1 +%define v_rc rc2 %define vd_rc %{?v_rc:-%{?v_rc}} %define _use_internal_dependency_generator 0 %define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides From lkarsten at varnish-software.com Tue Jan 27 13:39:39 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 14:39:39 +0100 Subject: [4.0] 4e3aa51 Escape question marks in C-strings to avoid accidentally generating tri-graphs. Message-ID: commit 4e3aa514ecf174bb549e5f0daa0d46957ba196c0 Author: Poul-Henning Kamp Date: Wed Aug 27 10:01:49 2014 +0000 Escape question marks in C-strings to avoid accidentally generating tri-graphs. Fixes #1566 diff --git a/bin/varnishtest/tests/r01566.vtc b/bin/varnishtest/tests/r01566.vtc new file mode 100644 index 0000000..fdf79a4 --- /dev/null +++ b/bin/varnishtest/tests/r01566.vtc @@ -0,0 +1,9 @@ +varnishtest "escape issue in regexp" + +varnish v1 -vcl { + backend b1 { .host = "127.0.0.1"; } + + sub vcl_recv { + set req.url = regsuball(req.url, "\??(p|pi)=.*?(&|$)", ""); + } +} diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 7bc4bc2..5a47390 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -211,6 +211,7 @@ EncString(struct vsb *sb, const char *b, const char *e, int mode) VSB_cat(sb, "\""); for (; b < e; b++) { switch (*b) { + case '?': // Trigraphs case '\\': case '"': VSB_printf(sb, "\\%c", *b); From fgsch at lodoss.net Tue Jan 27 13:57:02 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 27 Jan 2015 14:57:02 +0100 Subject: [master] 0a1606e Whitespace Message-ID: commit 0a1606e6d60636b463fcb3319ec81934ef592262 Author: Federico G. Schwindt Date: Tue Jan 27 13:07:29 2015 +0000 Whitespace diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 837a95f..4dcf1f9 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -661,7 +661,7 @@ http_DoConnection(struct http *hp) #define HTTPH(a, x, c) \ if (!((c) & HTTPH_R_PASS) && \ strlen(a) == u && !strncasecmp(a, b, u)) \ - return (SC_RX_BAD); + return (SC_RX_BAD); #include "tbl/http_headers.h" #undef HTTPH /*lint -restore */ diff --git a/include/tbl/http_headers.h b/include/tbl/http_headers.h index 53cd8fe..91ea213 100644 --- a/include/tbl/http_headers.h +++ b/include/tbl/http_headers.h @@ -40,7 +40,7 @@ /*lint -save -e525 -e539 */ #ifndef HTTPH_R_PASS -#define HTTPH_R_PASS (1 << 0 ) /* Request (c->b) in pass mode */ +#define HTTPH_R_PASS (1 << 0) /* Request (c->b) in pass mode */ #define HTTPH_R_FETCH (1 << 1) /* Request (c->b) for fetch */ #define HTTPH_A_INS (1 << 2) /* Response (b->o) for insert */ #endif From fgsch at lodoss.net Tue Jan 27 13:57:02 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 27 Jan 2015 14:57:02 +0100 Subject: [master] 728fa08 Assume >, >=, <, <= only apply to numbers Message-ID: commit 728fa08e882c5ec057a20044f4a531989d15a2ff Author: Federico G. Schwindt Date: Tue Jan 27 13:39:20 2015 +0000 Assume >, >=, <, <= only apply to numbers Partially reverts dc1059da. diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc index d656b84..a00f001 100644 --- a/bin/varnishtest/tests/r00956.vtc +++ b/bin/varnishtest/tests/r00956.vtc @@ -36,9 +36,9 @@ client c1 { expect resp.bodylen == 40 expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo .LE. 8.000 + expect resp.http.foo <= 8.000 expect resp.http.ageA == 4.000 - expect resp.http.ageB .GE. 6.000 + expect resp.http.ageB >= 6.000 delay 2 txreq @@ -46,7 +46,7 @@ client c1 { expect resp.bodylen == 40 expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo .LE. 6.000 + expect resp.http.foo <= 6.000 expect resp.http.ageA == 4.000 - expect resp.http.ageB .GE. 8.000 + expect resp.http.ageB >= 8.000 } -run diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 0612397..85c3854 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -272,20 +272,12 @@ cmd_http_expect(CMD_ARGS) // fail inequality comparisons if either side is undef'ed retval = 0; } else if (!strcmp(cmp, "<")) { - retval = strcmp(lhs, rhs) < 0; - } else if (!strcmp(cmp, "<=")) { - retval = strcmp(lhs, rhs) <= 0; - } else if (!strcmp(cmp, ">=")) { - retval = strcmp(lhs, rhs) >= 0; - } else if (!strcmp(cmp, ">")) { - retval = strcmp(lhs, rhs) > 0; - } else if (!strcmp(cmp, ".LT.")) { retval = strtod(lhs, NULL) < strtod(rhs, NULL); - } else if (!strcmp(cmp, ".GT.")) { + } else if (!strcmp(cmp, ">")) { retval = strtod(lhs, NULL) > strtod(rhs, NULL); - } else if (!strcmp(cmp, ".LE.")) { + } else if (!strcmp(cmp, "<=")) { retval = strtod(lhs, NULL) <= strtod(rhs, NULL); - } else if (!strcmp(cmp, ".GE.")) { + } else if (!strcmp(cmp, ">=")) { retval = strtod(lhs, NULL) >= strtod(rhs, NULL); } From lkarsten at varnish-software.com Tue Jan 27 14:21:16 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 15:21:16 +0100 Subject: [master] b9c2c79 Revert "Use install instead of cp." Message-ID: commit b9c2c793966c9795cd2dd9d6abfb44b32f115ba0 Author: Lasse Karstensen Date: Tue Jan 27 15:20:56 2015 +0100 Revert "Use install instead of cp." This reverts commit 679f823108abe3e9710adb8f514120eb56f0a128. install -D is different on BSD systems. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 68126c6..0ec3328 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -164,11 +164,11 @@ reference: BUILT_SOURCES += reference reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst - install -D $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ + cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - install -D $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ + cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From lkarsten at varnish-software.com Tue Jan 27 14:23:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 15:23:40 +0100 Subject: [4.0] 1f31dc1 Revert part of ac3bbf09. (install / cp) Message-ID: commit 1f31dc1c1936769ebeeb1fc5352df257cb107c77 Author: Lasse Karstensen Date: Tue Jan 27 15:18:27 2015 +0100 Revert part of ac3bbf09. (install / cp) The real issue was a missing reference/, which the additional requirement should take care of. Note to future self: install -D is something entirely different on BSD systems. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index dbc9e49..31eed38 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -149,11 +149,11 @@ reference: BUILT_SOURCES += reference reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst - install -D $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ + cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - install -D $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ + cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From daghf at varnish-software.com Tue Jan 27 14:44:50 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 27 Jan 2015 15:44:50 +0100 Subject: [master] d2705d2 Make sure generate.py is only ran once also for parallel make. Message-ID: commit d2705d20db68af210d6b4de19ee97080e494ebb2 Author: Dag Haavi Finstad Date: Tue Jan 27 15:43:42 2015 +0100 Make sure generate.py is only ran once also for parallel make. diff --git a/include/Makefile.am b/include/Makefile.am index cda44ee..bda6e37 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -87,7 +87,8 @@ nobase_noinst_HEADERS = \ vut.h \ vut_options.h -tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vcl.h vrt_obj.h: $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h +tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vrt_obj.h: vcl.h +vcl.h: $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl @PYTHON@ $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir) $(top_builddir) diff --git a/lib/libvcc/Makefile.am b/lib/libvcc/Makefile.am index c7e183d..b5a6574 100644 --- a/lib/libvcc/Makefile.am +++ b/lib/libvcc/Makefile.am @@ -38,8 +38,7 @@ dist_pkgdata_SCRIPTS = \ vmodtool.py vcc_obj.c vcc_fixed_token.c vcc_token_defs.h: \ - $(srcdir)/generate.py $(top_srcdir)/include/vrt.h - @PYTHON@ $(srcdir)/generate.py $(srcdir) $(top_builddir) + $(top_builddir)/include/vcl.h CLEANFILES = $(builddir)/vcc_token_defs.h \ $(builddir)/vcc_fixed_token.c \ From lkarsten at varnish-software.com Tue Jan 27 15:15:50 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 27 Jan 2015 16:15:50 +0100 Subject: [4.0] eabea70 Bug 1566 is fixed. Message-ID: commit eabea707cc5e5bd586a760ad067354f3ff725106 Author: Lasse Karstensen Date: Tue Jan 27 16:15:47 2015 +0100 Bug 1566 is fixed. diff --git a/doc/changes.rst b/doc/changes.rst index 6c3d0d4..b7f20ab 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -10,6 +10,7 @@ Bugs fixed ---------- - 1479_ - Fix out-of-tree builds. +- 1566_ - Escape VCL string question marks. - 1616_ - Correct header file placement. - 1620_ - Fail miss properly if out of backend threads. (Also 1621_) - 1628_ - Avoid dereferencing null in VBO_DerefBusyObj(). @@ -17,6 +18,7 @@ Bugs fixed - 1660_ - Don't attempt range delivery on a synth response .. _1479: https://www.varnish-cache.org/trac/ticket/1479 +.. _1566: https://www.varnish-cache.org/trac/ticket/1578 .. _1616: https://www.varnish-cache.org/trac/ticket/1616 .. _1620: https://www.varnish-cache.org/trac/ticket/1620 .. _1621: https://www.varnish-cache.org/trac/ticket/1621 From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 5cb82e1 Drop duplicate table definitions for the counter tables. Message-ID: commit 5cb82e1ee18d1fcc350871585c7da9175f427e3a Author: Martin Blix Grydeland Date: Fri Jan 16 13:42:16 2015 +0100 Drop duplicate table definitions for the counter tables. Refer to the file with the definition instead. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 55e6fa3..87555ed 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -26,35 +26,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Definition of all shared memory statistics below. - * - * Fields (n, t, l, f, e, d): - * n - Name: Field name, in C-source and stats programs - * t - Type: C-type, uint64_t, unless marked in 'f' - * l - Local: Local counter in worker thread. - * f - Format: Semantics of the value in this field - * 'a' - Accumulator (deprecated, use 'c') - * 'b' - Bitmap - * 'c' - Counter, never decreases. - * 'g' - Gauge, goes up and down - * 'i' - Integer (deprecated, use 'g') - * e - Explanation: Short explanation of field (for screen use) - * d - Description: Long explanation of field (for doc use) - * - * Please describe Gauge variables as "Number of..." to indicate that - * this is a snapshot, and Counter variables as "Count of" to indicate - * accumulative count. - * - * ----------------------- - * NB: Cleanup in progress - * ----------------------- - * - * Insufficient attention has caused this to become a swamp of conflicting - * conventions, shorthands and general mumbo-jumbo. I'm trying to clean - * it up as I go over the code in other business. - * - * Please see the sessmem section for how it should look. + * Definition of the main shared memory statistics below. * + * See include/tbl/vsc_fields.h for the table definition. */ /*-------------------------------------------------------------------- diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 5d8a281..77b3b71 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -26,7 +26,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Definition of all shared memory statistics below. + * Definition of all shared memory statistics below (except main - see + * include/tbl/vsc_f_main.h). * * Fields (n, t, l, f, v, e, d): * n - Name: Field name, in C-source and stats programs From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 26f659f Be consistent with the parameter naming on VSC_F macro definitions Message-ID: commit 26f659f07b9d90fb0106a379ca6626625b39a6cd Author: Martin Blix Grydeland Date: Fri Jan 16 13:47:38 2015 +0100 Be consistent with the parameter naming on VSC_F macro definitions diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 015075e..5bf3608 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -93,7 +93,7 @@ pool_sumstat(const struct dstat *src) Lck_AssertHeld(&wstat_mtx); #define L0(n) #define L1(n) (VSC_C_main->n += src->n) -#define VSC_F(n, t, l, f, v, d, e) L##l(n); +#define VSC_F(n, t, l, f, v, e, d) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 @@ -132,7 +132,7 @@ pool_addstat(struct dstat *dst, struct dstat *src) dst->summs++; #define L0(n) #define L1(n) (dst->n += src->n) -#define VSC_F(n, t, l, f, v, d, e) L##l(n); +#define VSC_F(n, t, l, f, v, e, d) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 88be5d9..039f839 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -190,7 +190,7 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level); #undef VSC_TYPE_F #define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[]; -#define VSC_F(n,t,l,f,v,d,e) +#define VSC_F(n,t,l,f,v,e,d) #define VSC_DONE(U,l,t) #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index cd8bdc0..4dc7205 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -387,7 +387,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr, CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \ st = vf->fantom.b; -#define VSC_F(nn,tt,ll,ff,vv,dd,ee) \ +#define VSC_F(nn,tt,ll,ff,vv,ee,dd) \ vsc_add_pt(vsc, &st->nn, descs++, vf); #define VSC_DONE(U,l,t) \ @@ -437,7 +437,7 @@ vsc_build_pt_list(struct VSM_data *vd) CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \ if (!strcmp(vf->fantom.type, t)) \ iter_##l(vsc, VSC_desc_##l, vf); -#define VSC_F(n,t,l,f,v,d,e) +#define VSC_F(n,t,l,f,v,e,d) #define VSC_DONE(a,b,c) #include "tbl/vsc_all.h" #undef VSC_DO @@ -565,7 +565,7 @@ VSC_LevelDesc(unsigned level) #undef VSC_TYPE_F #define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { -#define VSC_F(n,t,l,f,v,d,e) {#n,#t,f,d,e,&VSC_level_desc_##v}, +#define VSC_F(n,t,l,f,v,e,d) {#n,#t,f,e,d,&VSC_level_desc_##v}, #define VSC_DONE(U,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 3c5b6ec Drop deprecated 'a' and 'i' counter formats from table definition Message-ID: commit 3c5b6ec33bcabfd6d387cecc16c7c9e4e6663d6a Author: Martin Blix Grydeland Date: Fri Jan 16 13:49:04 2015 +0100 Drop deprecated 'a' and 'i' counter formats from table definition diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 63b2e54..27ef250 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -180,7 +180,7 @@ do_once_cb(void *priv, const struct VSC_point * const pt) if (i >= op->pad) op->pad = i + 1; printf("%*.*s", op->pad - i, op->pad - i, ""); - if (pt->desc->flag == 'a' || pt->desc->flag == 'c') + if (pt->desc->flag == 'c') printf("%12ju %12.2f %s\n", (uintmax_t)val, val / op->up, pt->desc->sdesc); else diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 559e89e..b99ff53 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -317,10 +317,6 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) pt->ptr = vpt->ptr; pt->last = *pt->ptr; pt->flag = vpt->desc->flag; - if (pt->flag == 'a') - pt->flag = 'c'; - if (pt->flag == 'i') - pt->flag = 'g'; pt->ma_10.nmax = 10; pt->ma_100.nmax = 100; diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 77b3b71..f6c0bc2 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -34,11 +34,9 @@ * t - Type: C-type, uint64_t, unless marked in 'f' * l - Local: Local counter in worker thread. * f - Format: Semantics of the value in this field - * 'a' - Accumulator (deprecated, use 'c') * 'b' - Bitmap * 'c' - Counter, never decreases. * 'g' - Gauge, goes up and down - * 'i' - Integer (deprecated, use 'g') * v - Verbosity: Counter verbosity level (see vsc_levels.h) * e - Explanation: Short explanation of field (for screen use) * d - Description: Long explanation of field (for doc use) From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 52b0e59 Redo the vsc_fields.h table definition Message-ID: commit 52b0e59799ae448d3991299426c07dbc9b9f98a1 Author: Martin Blix Grydeland Date: Tue Jan 27 15:34:58 2015 +0100 Redo the vsc_fields.h table definition Use 'semantics' instead of 'format' to describe the field semantics. Switch 'description' and 'explanation' to be short and long texts respectively. Reflect this in all macro invocations diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fed05d1..d307c38 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -268,7 +268,7 @@ struct acct_bereq { #define L0(t, n) #define L1(t, n) t n; -#define VSC_F(n,t,l,f,v,e,d) L##l(t, n) +#define VSC_F(n,t,l,s,v,d,e) L##l(t, n) struct dstat { unsigned summs; #include "tbl/vsc_f_main.h" diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 5bf3608..5c1c444 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -93,7 +93,7 @@ pool_sumstat(const struct dstat *src) Lck_AssertHeld(&wstat_mtx); #define L0(n) #define L1(n) (VSC_C_main->n += src->n) -#define VSC_F(n, t, l, f, v, e, d) L##l(n); +#define VSC_F(n,t,l,s,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 @@ -132,7 +132,7 @@ pool_addstat(struct dstat *dst, struct dstat *src) dst->summs++; #define L0(n) #define L1(n) (dst->n += src->n) -#define VSC_F(n, t, l, f, v, e, d) L##l(n); +#define VSC_F(n,t,l,s,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index f6c0bc2..c7bc451 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -29,17 +29,17 @@ * Definition of all shared memory statistics below (except main - see * include/tbl/vsc_f_main.h). * - * Fields (n, t, l, f, v, e, d): + * Fields (n, t, l, s, v, d, e): * n - Name: Field name, in C-source and stats programs - * t - Type: C-type, uint64_t, unless marked in 'f' + * t - C-type: uint64_t, unless marked in 's' * l - Local: Local counter in worker thread. - * f - Format: Semantics of the value in this field + * s - Semantics: Semantics of the value in this field * 'b' - Bitmap * 'c' - Counter, never decreases. * 'g' - Gauge, goes up and down * v - Verbosity: Counter verbosity level (see vsc_levels.h) - * e - Explanation: Short explanation of field (for screen use) - * d - Description: Long explanation of field (for doc use) + * d - Description: Short description of field (for screen use) + * e - Explanation: Long explanation of field (for doc use) * * Please describe Gauge variables as "Number of..." to indicate that * this is a snapshot, and Counter variables as "Count of" to indicate diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 039f839..4a7782d 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -190,7 +190,7 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level); #undef VSC_TYPE_F #define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[]; -#define VSC_F(n,t,l,f,v,e,d) +#define VSC_F(n,t,l,s,v,d,e) #define VSC_DONE(U,l,t) #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/include/vapi/vsc_int.h b/include/vapi/vsc_int.h index dacb2f4..4a7d4a8 100644 --- a/include/vapi/vsc_int.h +++ b/include/vapi/vsc_int.h @@ -46,7 +46,7 @@ enum VSC_level_e { /* Define the vsc type structs */ #define VSC_DO(u,l,t) struct VSC_C_##l { -#define VSC_F(n,t,l,f,v,e,d) t n; +#define VSC_F(n,t,l,s,v,d,e) t n; #define VSC_DONE(u,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 4dc7205..fe8c449 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -387,7 +387,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr, CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \ st = vf->fantom.b; -#define VSC_F(nn,tt,ll,ff,vv,ee,dd) \ +#define VSC_F(nn,tt,ll,ss,vv,dd,ee) \ vsc_add_pt(vsc, &st->nn, descs++, vf); #define VSC_DONE(U,l,t) \ @@ -437,7 +437,7 @@ vsc_build_pt_list(struct VSM_data *vd) CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \ if (!strcmp(vf->fantom.type, t)) \ iter_##l(vsc, VSC_desc_##l, vf); -#define VSC_F(n,t,l,f,v,e,d) +#define VSC_F(n,t,l,s,v,d,e) #define VSC_DONE(a,b,c) #include "tbl/vsc_all.h" #undef VSC_DO @@ -565,7 +565,7 @@ VSC_LevelDesc(unsigned level) #undef VSC_TYPE_F #define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { -#define VSC_F(n,t,l,f,v,e,d) {#n,#t,f,e,d,&VSC_level_desc_##v}, +#define VSC_F(n,t,l,s,v,d,e) {#n,#t,s,d,e,&VSC_level_desc_##v}, #define VSC_DONE(U,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/man/vsc2rst.c b/man/vsc2rst.c index a9a99fd..6c00971 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -40,7 +40,7 @@ printf(x "\n", ##__VA_ARGS__) #define VSC_LEVEL_F(v,l,e,d) \ printf("%s ? %s\n\t%s\n\n", l, e, d); -#define VSC_F(n, t, l, f, v, e, d) \ +#define VSC_F(n, t, l, s, v, d, e) \ printf("%s ? %s (%s)\n\t%s\n\n", #n, e, VSC_level_##v, d); int main(int argc, char **argv) From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] f46e5c7 Add a display format field to the VSC_F table Message-ID: commit f46e5c7308a3a2ace489702c6078e9a54b4d5274 Author: Martin Blix Grydeland Date: Tue Jan 27 15:47:28 2015 +0100 Add a display format field to the VSC_F table The field describes how to best display the field. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d307c38..fccc466 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -268,7 +268,7 @@ struct acct_bereq { #define L0(t, n) #define L1(t, n) t n; -#define VSC_F(n,t,l,s,v,d,e) L##l(t, n) +#define VSC_F(n,t,l,s,f,v,d,e) L##l(t, n) struct dstat { unsigned summs; #include "tbl/vsc_f_main.h" diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 5c1c444..95e3e75 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -93,7 +93,7 @@ pool_sumstat(const struct dstat *src) Lck_AssertHeld(&wstat_mtx); #define L0(n) #define L1(n) (VSC_C_main->n += src->n) -#define VSC_F(n,t,l,s,v,d,e) L##l(n); +#define VSC_F(n,t,l,s,f,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 @@ -132,7 +132,7 @@ pool_addstat(struct dstat *dst, struct dstat *src) dst->summs++; #define L0(n) #define L1(n) (dst->n += src->n) -#define VSC_F(n,t,l,s,v,d,e) L##l(n); +#define VSC_F(n,t,l,s,f,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" #undef VSC_F #undef L0 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 87555ed..6bd68c1 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -35,7 +35,7 @@ * Globals, not related to traffic */ -VSC_F(uptime, uint64_t, 0, 'c', info, +VSC_F(uptime, uint64_t, 0, 'c', 'i', info, "Child process uptime", "How long the child process has been running." ) @@ -45,56 +45,56 @@ VSC_F(uptime, uint64_t, 0, 'c', info, * Sessions */ -VSC_F(sess_conn, uint64_t, 1, 'c', info, +VSC_F(sess_conn, uint64_t, 1, 'c', 'i', info, "Sessions accepted", "Count of sessions successfully accepted" ) -VSC_F(sess_drop, uint64_t, 1, 'c', info, +VSC_F(sess_drop, uint64_t, 1, 'c', 'i', info, "Sessions dropped", "Count of sessions silently dropped due to lack of worker thread." ) -VSC_F(sess_fail, uint64_t, 1, 'c', info, +VSC_F(sess_fail, uint64_t, 1, 'c', 'i', info, "Session accept failures", "Count of failures to accept TCP connection." " Either the client changed its mind, or the kernel ran out of" " some resource like file descriptors." ) -VSC_F(sess_pipe_overflow, uint64_t, 1, 'c', info, +VSC_F(sess_pipe_overflow, uint64_t, 1, 'c', 'i', info, "Session pipe overflow", "Count of sessions dropped due to the session pipe overflowing." ) /*---------------------------------------------------------------------*/ -VSC_F(client_req_400, uint64_t, 1, 'c', info, +VSC_F(client_req_400, uint64_t, 1, 'c', 'i', info, "Client requests received, subject to 400 errors", "400 means we couldn't make sense of the request, it was" " malformed in some drastic way." ) -VSC_F(client_req_417, uint64_t, 1, 'c', info, +VSC_F(client_req_417, uint64_t, 1, 'c', 'i', info, "Client requests received, subject to 417 errors", "417 means that something went wrong with an Expect: header." ) -VSC_F(client_req, uint64_t, 1, 'c', info, +VSC_F(client_req, uint64_t, 1, 'c', 'i', info, "Good client requests received", "The count of parseable client requests seen." ) /*---------------------------------------------------------------------*/ -VSC_F(cache_hit, uint64_t, 1, 'c', info, +VSC_F(cache_hit, uint64_t, 1, 'c', 'i', info, "Cache hits", "Count of cache hits. " " A cache hit indicates that an object has been delivered to a" " client without fetching it from a backend server." ) -VSC_F(cache_hitpass, uint64_t, 1, 'c', info, +VSC_F(cache_hitpass, uint64_t, 1, 'c', 'i', info, "Cache hits for pass", "Count of hits for pass" " A cache hit for pass indicates that Varnish is going to" @@ -103,7 +103,7 @@ VSC_F(cache_hitpass, uint64_t, 1, 'c', info, " decision is being used." ) -VSC_F(cache_miss, uint64_t, 1, 'c', info, +VSC_F(cache_miss, uint64_t, 1, 'c', 'i', info, "Cache misses", "Count of misses" " A cache miss indicates the object was fetched from the" @@ -112,34 +112,34 @@ VSC_F(cache_miss, uint64_t, 1, 'c', info, /*---------------------------------------------------------------------*/ -VSC_F(backend_conn, uint64_t, 0, 'c', info, +VSC_F(backend_conn, uint64_t, 0, 'c', 'i', info, "Backend conn. success", "How many backend connections have successfully been" " established." ) -VSC_F(backend_unhealthy, uint64_t, 0, 'c', info, +VSC_F(backend_unhealthy, uint64_t, 0, 'c', 'i', info, "Backend conn. not attempted", "" ) -VSC_F(backend_busy, uint64_t, 0, 'c', info, +VSC_F(backend_busy, uint64_t, 0, 'c', 'i', info, "Backend conn. too many", "" ) -VSC_F(backend_fail, uint64_t, 0, 'c', info, +VSC_F(backend_fail, uint64_t, 0, 'c', 'i', info, "Backend conn. failures", "" ) -VSC_F(backend_reuse, uint64_t, 0, 'c', info, +VSC_F(backend_reuse, uint64_t, 0, 'c', 'i', info, "Backend conn. reuses", "Count of backend connection reuses" " This counter is increased whenever we reuse a recycled connection." ) -VSC_F(backend_toolate, uint64_t, 0, 'c', info, +VSC_F(backend_toolate, uint64_t, 0, 'c', 'i', info, "Backend conn. was closed", "" ) -VSC_F(backend_recycle, uint64_t, 0, 'c', info, +VSC_F(backend_recycle, uint64_t, 0, 'c', 'i', info, "Backend conn. recycles", "Count of backend connection recycles" " This counter is increased whenever we have a keep-alive" @@ -147,7 +147,7 @@ VSC_F(backend_recycle, uint64_t, 0, 'c', info, " It has not yet been used, but it might be, unless the backend" " closes it." ) -VSC_F(backend_retry, uint64_t, 0, 'c', info, +VSC_F(backend_retry, uint64_t, 0, 'c', 'i', info, "Backend conn. retry", "" ) @@ -156,47 +156,47 @@ VSC_F(backend_retry, uint64_t, 0, 'c', info, * Backend fetch statistics */ -VSC_F(fetch_head, uint64_t, 1, 'c', info, +VSC_F(fetch_head, uint64_t, 1, 'c', 'i', info, "Fetch no body (HEAD)", "beresp with no body because the request is HEAD." ) -VSC_F(fetch_length, uint64_t, 1, 'c', info, +VSC_F(fetch_length, uint64_t, 1, 'c', 'i', info, "Fetch with Length", "beresp.body with Content-Length." ) -VSC_F(fetch_chunked, uint64_t, 1, 'c', info, +VSC_F(fetch_chunked, uint64_t, 1, 'c', 'i', info, "Fetch chunked", "beresp.body with Chunked." ) -VSC_F(fetch_eof, uint64_t, 1, 'c', info, +VSC_F(fetch_eof, uint64_t, 1, 'c', 'i', info, "Fetch EOF", "beresp.body with EOF." ) -VSC_F(fetch_bad, uint64_t, 1, 'c', info, +VSC_F(fetch_bad, uint64_t, 1, 'c', 'i', info, "Fetch bad T-E", "beresp.body length/fetch could not be determined." ) -VSC_F(fetch_none, uint64_t, 1, 'c', info, +VSC_F(fetch_none, uint64_t, 1, 'c', 'i', info, "Fetch no body", "beresp.body empty" ) -VSC_F(fetch_1xx, uint64_t, 1, 'c', info, +VSC_F(fetch_1xx, uint64_t, 1, 'c', 'i', info, "Fetch no body (1xx)", "beresp with no body because of 1XX response." ) -VSC_F(fetch_204, uint64_t, 1, 'c', info, +VSC_F(fetch_204, uint64_t, 1, 'c', 'i', info, "Fetch no body (204)", "beresp with no body because of 204 response." ) -VSC_F(fetch_304, uint64_t, 1, 'c', info, +VSC_F(fetch_304, uint64_t, 1, 'c', 'i', info, "Fetch no body (304)", "beresp with no body because of 304 response." ) -VSC_F(fetch_failed, uint64_t, 1, 'c', info, +VSC_F(fetch_failed, uint64_t, 1, 'c', 'i', info, "Fetch failed (all causes)", "beresp fetch failed." ) -VSC_F(fetch_no_thread, uint64_t, 1, 'c', info, +VSC_F(fetch_no_thread, uint64_t, 1, 'c', 'i', info, "Fetch failed (no thread)", "beresp fetch failed, no thread available." ) @@ -207,75 +207,75 @@ VSC_F(fetch_no_thread, uint64_t, 1, 'c', info, * */ -VSC_F(pools, uint64_t, 0, 'g', info, +VSC_F(pools, uint64_t, 0, 'g', 'i', info, "Number of thread pools", "Number of thread pools. See also parameter thread_pools." " NB: Presently pools cannot be removed once created." ) -VSC_F(threads, uint64_t, 0, 'g', info, +VSC_F(threads, uint64_t, 0, 'g', 'i', info, "Total number of threads", "Number of threads in all pools." " See also parameters thread_pools, thread_pool_min and" " thread_pool_max." ) -VSC_F(threads_limited, uint64_t, 0, 'c', info, +VSC_F(threads_limited, uint64_t, 0, 'c', 'i', info, "Threads hit max", "Number of times more threads were needed, but limit was reached" " in a thread pool." " See also parameter thread_pool_max." ) -VSC_F(threads_created, uint64_t, 0, 'c', info, +VSC_F(threads_created, uint64_t, 0, 'c', 'i', info, "Threads created", "Total number of threads created in all pools." ) -VSC_F(threads_destroyed, uint64_t, 0, 'c', info, +VSC_F(threads_destroyed, uint64_t, 0, 'c', 'i', info, "Threads destroyed", "Total number of threads destroyed in all pools." ) -VSC_F(threads_failed, uint64_t, 0, 'c', info, +VSC_F(threads_failed, uint64_t, 0, 'c', 'i', info, "Thread creation failed", "Number of times creating a thread failed." " See VSL::Debug for diagnostics." " See also parameter thread_fail_delay." ) -VSC_F(thread_queue_len, uint64_t, 0, 'g', info, +VSC_F(thread_queue_len, uint64_t, 0, 'g', 'i', info, "Length of session queue", "Length of session queue waiting for threads." " NB: Only updates once per second." " See also parameter queue_max." ) -VSC_F(busy_sleep, uint64_t, 1, 'c', info, +VSC_F(busy_sleep, uint64_t, 1, 'c', 'i', info, "Number of requests sent to sleep on busy objhdr", "Number of requests sent to sleep without a worker thread because" " they found a busy object." ) -VSC_F(busy_wakeup, uint64_t, 1, 'c', info, +VSC_F(busy_wakeup, uint64_t, 1, 'c', 'i', info, "Number of requests woken after sleep on busy objhdr", "Number of requests taken of the busy object sleep list and" " and rescheduled." ) -VSC_F(busy_killed, uint64_t, 1, 'c', info, +VSC_F(busy_killed, uint64_t, 1, 'c', 'i', info, "Number of requests killed after sleep on busy objhdr", "Number of requests killed from the busy object sleep list" " due to lack of resources." ) -VSC_F(sess_queued, uint64_t, 0, 'c', info, +VSC_F(sess_queued, uint64_t, 0, 'c', 'i', info, "Sessions queued for thread", "Number of times session was queued waiting for a thread." " See also parameter queue_max." ) -VSC_F(sess_dropped, uint64_t, 0, 'c', info, +VSC_F(sess_dropped, uint64_t, 0, 'c', 'i', info, "Sessions dropped for thread", "Number of times session was dropped because the queue were too" " long already. See also parameter queue_max." @@ -283,245 +283,245 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', info, /*---------------------------------------------------------------------*/ -VSC_F(n_object, uint64_t, 1, 'g', info, +VSC_F(n_object, uint64_t, 1, 'g', 'i', info, "object structs made", "Number of object structs made" ) -VSC_F(n_vampireobject, uint64_t, 1, 'g', diag, +VSC_F(n_vampireobject, uint64_t, 1, 'g', 'i', diag, "unresurrected objects", "Number of unresurrected objects" ) -VSC_F(n_objectcore, uint64_t, 1, 'g', info, +VSC_F(n_objectcore, uint64_t, 1, 'g', 'i', info, "objectcore structs made", "Number of objectcore structs made" ) -VSC_F(n_objecthead, uint64_t, 1, 'g', info, +VSC_F(n_objecthead, uint64_t, 1, 'g', 'i', info, "objecthead structs made", "Number of objecthead structs made" ) -VSC_F(n_waitinglist, uint64_t, 1, 'g', debug, +VSC_F(n_waitinglist, uint64_t, 1, 'g', 'i', debug, "waitinglist structs made", "Number of waitinglist structs made" ) -VSC_F(n_backend, uint64_t, 0, 'g', info, +VSC_F(n_backend, uint64_t, 0, 'g', 'i', info, "Number of backends", "Number of backends known to us." ) -VSC_F(n_expired, uint64_t, 0, 'g', info, +VSC_F(n_expired, uint64_t, 0, 'g', 'i', info, "Number of expired objects", "Number of objects that expired from cache" " because of old age." ) -VSC_F(n_lru_nuked, uint64_t, 0, 'g', info, +VSC_F(n_lru_nuked, uint64_t, 0, 'g', 'i', info, "Number of LRU nuked objects", "How many objects have been forcefully evicted" " from storage to make room for a new object." ) -VSC_F(n_lru_moved, uint64_t, 0, 'g', diag, +VSC_F(n_lru_moved, uint64_t, 0, 'g', 'i', diag, "Number of LRU moved objects", "Number of move operations done on the LRU list." ) -VSC_F(losthdr, uint64_t, 0, 'c', info, +VSC_F(losthdr, uint64_t, 0, 'c', 'i', info, "HTTP header overflows", "" ) -VSC_F(s_sess, uint64_t, 1, 'c', info, +VSC_F(s_sess, uint64_t, 1, 'c', 'i', info, "Total sessions seen", "" ) -VSC_F(s_req, uint64_t, 1, 'c', info, +VSC_F(s_req, uint64_t, 1, 'c', 'i', info, "Total requests seen", "" ) -VSC_F(s_pipe, uint64_t, 1, 'c', info, +VSC_F(s_pipe, uint64_t, 1, 'c', 'i', info, "Total pipe sessions seen", "" ) -VSC_F(s_pass, uint64_t, 1, 'c', info, +VSC_F(s_pass, uint64_t, 1, 'c', 'i', info, "Total pass-ed requests seen", "" ) -VSC_F(s_fetch, uint64_t, 1, 'c', info, +VSC_F(s_fetch, uint64_t, 1, 'c', 'i', info, "Total backend fetches initiated", "" ) -VSC_F(s_synth, uint64_t, 1, 'c', info, +VSC_F(s_synth, uint64_t, 1, 'c', 'i', info, "Total synthethic responses made", "" ) -VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', info, +VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', 'i', info, "Request header bytes", "Total request header bytes received" ) -VSC_F(s_req_bodybytes, uint64_t, 1, 'c', info, +VSC_F(s_req_bodybytes, uint64_t, 1, 'c', 'i', info, "Request body bytes", "Total request body bytes received" ) -VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', info, +VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', 'i', info, "Response header bytes", "Total response header bytes transmitted" ) -VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', info, +VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', 'i', info, "Response body bytes", "Total response body bytes transmitted" ) -VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', info, +VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', 'i', info, "Pipe request header bytes", "Total request bytes received for piped sessions" ) -VSC_F(s_pipe_in, uint64_t, 0, 'c', info, +VSC_F(s_pipe_in, uint64_t, 0, 'c', 'i', info, "Piped bytes from client", "Total number of bytes forwarded from clients in" " pipe sessions" ) -VSC_F(s_pipe_out, uint64_t, 0, 'c', info, +VSC_F(s_pipe_out, uint64_t, 0, 'c', 'i', info, "Piped bytes to client", "Total number of bytes forwarded to clients in" " pipe sessions" ) -VSC_F(sess_closed, uint64_t, 1, 'c', info, +VSC_F(sess_closed, uint64_t, 1, 'c', 'i', info, "Session Closed", "" ) -VSC_F(sess_pipeline, uint64_t, 1, 'c', info, +VSC_F(sess_pipeline, uint64_t, 1, 'c', 'i', info, "Session Pipeline", "" ) -VSC_F(sess_readahead, uint64_t, 1, 'c', info, +VSC_F(sess_readahead, uint64_t, 1, 'c', 'i', info, "Session Read Ahead", "" ) -VSC_F(sess_herd, uint64_t, 1, 'c', diag, +VSC_F(sess_herd, uint64_t, 1, 'c', 'i', diag, "Session herd", "" ) /*--------------------------------------------------------------------*/ -VSC_F(shm_records, uint64_t, 0, 'c', diag, +VSC_F(shm_records, uint64_t, 0, 'c', 'i', diag, "SHM records", "" ) -VSC_F(shm_writes, uint64_t, 0, 'c', diag, +VSC_F(shm_writes, uint64_t, 0, 'c', 'i', diag, "SHM writes", "" ) -VSC_F(shm_flushes, uint64_t, 0, 'c', diag, +VSC_F(shm_flushes, uint64_t, 0, 'c', 'i', diag, "SHM flushes due to overflow", "" ) -VSC_F(shm_cont, uint64_t, 0, 'c', diag, +VSC_F(shm_cont, uint64_t, 0, 'c', 'i', diag, "SHM MTX contention", "" ) -VSC_F(shm_cycles, uint64_t, 0, 'c', diag, +VSC_F(shm_cycles, uint64_t, 0, 'c', 'i', diag, "SHM cycles through buffer", "" ) /*--------------------------------------------------------------------*/ -VSC_F(backend_req, uint64_t, 0, 'c', info, +VSC_F(backend_req, uint64_t, 0, 'c', 'i', info, "Backend requests made", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_vcl, uint64_t, 0, 'c', info, +VSC_F(n_vcl, uint64_t, 0, 'c', 'i', info, "Number of loaded VCLs in total", "" ) -VSC_F(n_vcl_avail, uint64_t, 0, 'c', diag, +VSC_F(n_vcl_avail, uint64_t, 0, 'c', 'i', diag, "Number of VCLs available", "" ) -VSC_F(n_vcl_discard, uint64_t, 0, 'c', diag, +VSC_F(n_vcl_discard, uint64_t, 0, 'c', 'i', diag, "Number of discarded VCLs", "" ) /*--------------------------------------------------------------------*/ -VSC_F(bans, uint64_t, 0, 'g', info, +VSC_F(bans, uint64_t, 0, 'g', 'i', info, "Count of bans", "Number of all bans in system, including bans superseded" " by newer bans and bans already checked by the ban-lurker." ) -VSC_F(bans_completed, uint64_t, 0, 'g', diag, +VSC_F(bans_completed, uint64_t, 0, 'g', 'i', diag, "Number of bans marked 'completed'", "Number of bans which are no longer active, either because they" " got checked by the ban-lurker or superseded by newer identical bans." ) -VSC_F(bans_obj, uint64_t, 0, 'g', diag, +VSC_F(bans_obj, uint64_t, 0, 'g', 'i', diag, "Number of bans using obj.*", "Number of bans which use obj.* variables. These bans can possibly" " be washed by the ban-lurker." ) -VSC_F(bans_req, uint64_t, 0, 'g', diag, +VSC_F(bans_req, uint64_t, 0, 'g', 'i', diag, "Number of bans using req.*", "Number of bans which use req.* variables. These bans can not" " be washed by the ban-lurker." ) -VSC_F(bans_added, uint64_t, 0, 'c', diag, +VSC_F(bans_added, uint64_t, 0, 'c', 'i', diag, "Bans added", "Counter of bans added to ban list." ) -VSC_F(bans_deleted, uint64_t, 0, 'c', diag, +VSC_F(bans_deleted, uint64_t, 0, 'c', 'i', diag, "Bans deleted", "Counter of bans deleted from ban list." ) -VSC_F(bans_tested, uint64_t, 0, 'c', diag, +VSC_F(bans_tested, uint64_t, 0, 'c', 'i', diag, "Bans tested against objects (lookup)", "Count of how many bans and objects have been tested against" " each other during hash lookup." ) -VSC_F(bans_obj_killed, uint64_t, 0, 'c', diag, +VSC_F(bans_obj_killed, uint64_t, 0, 'c', 'i', diag, "Objects killed by bans (lookup)", "Number of objects killed by bans during object lookup." ) -VSC_F(bans_lurker_tested, uint64_t, 0, 'c', diag, +VSC_F(bans_lurker_tested, uint64_t, 0, 'c', 'i', diag, "Bans tested against objects (lurker)", "Count of how many bans and objects have been tested against" " each other by the ban-lurker." ) -VSC_F(bans_tests_tested, uint64_t, 0, 'c', diag, +VSC_F(bans_tests_tested, uint64_t, 0, 'c', 'i', diag, "Ban tests tested against objects (lookup)", "Count of how many tests and objects have been tested against" " each other during lookup." " 'ban req.url == foo && req.http.host == bar'" " counts as one in 'bans_tested' and as two in 'bans_tests_tested'" ) -VSC_F(bans_lurker_tests_tested, uint64_t, 0, 'c', diag, +VSC_F(bans_lurker_tests_tested, uint64_t, 0, 'c', 'i', diag, "Ban tests tested against objects (lurker)", "Count of how many tests and objects have been tested against" " each other by the ban-lurker." " 'ban req.url == foo && req.http.host == bar'" " counts as one in 'bans_tested' and as two in 'bans_tests_tested'" ) -VSC_F(bans_lurker_obj_killed, uint64_t, 0, 'c', diag, +VSC_F(bans_lurker_obj_killed, uint64_t, 0, 'c', 'i', diag, "Objects killed by bans (lurker)", "Number of objects killed by ban-lurker." ) -VSC_F(bans_dups, uint64_t, 0, 'c', diag, +VSC_F(bans_dups, uint64_t, 0, 'c', 'i', diag, "Bans superseded by other bans", "Count of bans replaced by later identical bans." ) -VSC_F(bans_lurker_contention, uint64_t, 0, 'c', diag, +VSC_F(bans_lurker_contention, uint64_t, 0, 'c', 'i', diag, "Lurker gave way for lookup", "Number of times the ban-lurker had to wait for lookups." ) -VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', diag, +VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', 'i', diag, "Bytes used by the persisted ban lists", "Number of bytes used by the persisted ban lists." ) -VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', diag, +VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', 'i', diag, "Extra bytes in persisted ban lists due to fragmentation", "Number of extra bytes accumulated through dropped and" " completed bans in the persistent ban lists." @@ -529,100 +529,100 @@ VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', diag, /*--------------------------------------------------------------------*/ -VSC_F(n_purges, uint64_t, 0, 'g', info, +VSC_F(n_purges, uint64_t, 0, 'g', 'i', info, "Number of purge operations executed", "" ) -VSC_F(n_obj_purged, uint64_t, 0, 'g', info, +VSC_F(n_obj_purged, uint64_t, 0, 'g', 'i', info, "Number of purged objects", "" ) /*--------------------------------------------------------------------*/ -VSC_F(exp_mailed, uint64_t, 0, 'c', diag, +VSC_F(exp_mailed, uint64_t, 0, 'c', 'i', diag, "Number of objects mailed to expiry thread", "Number of objects mailed to expiry thread for handling." ) -VSC_F(exp_received, uint64_t, 0, 'c', diag, +VSC_F(exp_received, uint64_t, 0, 'c', 'i', diag, "Number of objects received by expiry thread", "Number of objects received by expiry thread for handling." ) /*--------------------------------------------------------------------*/ -VSC_F(hcb_nolock, uint64_t, 1, 'c', debug, +VSC_F(hcb_nolock, uint64_t, 1, 'c', 'i', debug, "HCB Lookups without lock", "" ) -VSC_F(hcb_lock, uint64_t, 0, 'c', debug, +VSC_F(hcb_lock, uint64_t, 0, 'c', 'i', debug, "HCB Lookups with lock", "" ) -VSC_F(hcb_insert, uint64_t, 0, 'c', debug, +VSC_F(hcb_insert, uint64_t, 0, 'c', 'i', debug, "HCB Inserts", "" ) /*--------------------------------------------------------------------*/ -VSC_F(esi_errors, uint64_t, 0, 'c', diag, +VSC_F(esi_errors, uint64_t, 0, 'c', 'i', diag, "ESI parse errors (unlock)", "" ) -VSC_F(esi_warnings, uint64_t, 0, 'c', diag, +VSC_F(esi_warnings, uint64_t, 0, 'c', 'i', diag, "ESI parse warnings (unlock)", "" ) /*--------------------------------------------------------------------*/ -VSC_F(vmods, uint64_t, 0, 'g', info, +VSC_F(vmods, uint64_t, 0, 'g', 'i', info, "Loaded VMODs", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_gzip, uint64_t, 0, 'c', info, +VSC_F(n_gzip, uint64_t, 0, 'c', 'i', info, "Gzip operations", "" ) -VSC_F(n_gunzip, uint64_t, 0, 'c', info, +VSC_F(n_gunzip, uint64_t, 0, 'c', 'i', info, "Gunzip operations", "" ) /*--------------------------------------------------------------------*/ -VSC_F(vsm_free, uint64_t, 0, 'g', diag, +VSC_F(vsm_free, uint64_t, 0, 'g', 'i', diag, "Free VSM space", "Number of bytes free in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_used, uint64_t, 0, 'g', diag, +VSC_F(vsm_used, uint64_t, 0, 'g', 'i', diag, "Used VSM space", "Number of bytes used in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_cooling, uint64_t, 0, 'g', debug, +VSC_F(vsm_cooling, uint64_t, 0, 'g', 'i', debug, "Cooling VSM space", "Number of bytes which will soon (max 1 minute) be freed" " in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_overflow, uint64_t, 0, 'g', diag, +VSC_F(vsm_overflow, uint64_t, 0, 'g', 'i', diag, "Overflow VSM space", "Number of bytes which does not fit" " in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_overflowed, uint64_t, 0, 'c', diag, +VSC_F(vsm_overflowed, uint64_t, 0, 'c', 'i', diag, "Overflowed VSM space", "Total number of bytes which did not fit" " in the shared memory used to communicate" diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index c7bc451..0cdb51f 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -29,7 +29,7 @@ * Definition of all shared memory statistics below (except main - see * include/tbl/vsc_f_main.h). * - * Fields (n, t, l, s, v, d, e): + * Fields (n, t, l, s, f, v, d, e): * n - Name: Field name, in C-source and stats programs * t - C-type: uint64_t, unless marked in 's' * l - Local: Local counter in worker thread. @@ -37,6 +37,9 @@ * 'b' - Bitmap * 'c' - Counter, never decreases. * 'g' - Gauge, goes up and down + * f - Format: Display format for the field + * 'b' - Bitmap + * 'i' - Integer * v - Verbosity: Counter verbosity level (see vsc_levels.h) * d - Description: Short description of field (for screen use) * e - Explanation: Long explanation of field (for doc use) @@ -61,32 +64,32 @@ #ifdef VSC_DO_MGT -VSC_F(uptime, uint64_t, 0, 'c', info, +VSC_F(uptime, uint64_t, 0, 'c', 'i', info, "Management process uptime", "Uptime in seconds of the management process" ) -VSC_F(child_start, uint64_t, 0, 'c', diag, +VSC_F(child_start, uint64_t, 0, 'c', 'i', diag, "Child process started", "Number of times the child process has been started" ) -VSC_F(child_exit, uint64_t, 0, 'c', diag, +VSC_F(child_exit, uint64_t, 0, 'c', 'i', diag, "Child process normal exit", "Number of times the child process has been cleanly stopped" ) -VSC_F(child_stop, uint64_t, 0, 'c', diag, +VSC_F(child_stop, uint64_t, 0, 'c', 'i', diag, "Child process unexpected exit", "Number of times the child process has exited with an unexpected" " return code" ) -VSC_F(child_died, uint64_t, 0, 'c', diag, +VSC_F(child_died, uint64_t, 0, 'c', 'i', diag, "Child process died (signal)", "Number of times the child process has died due to signals" ) -VSC_F(child_dump, uint64_t, 0, 'c', diag, +VSC_F(child_dump, uint64_t, 0, 'c', 'i', diag, "Child process core dumped", "Number of times the child process has produced core dumps" ) -VSC_F(child_panic, uint64_t, 0, 'c', diag, +VSC_F(child_panic, uint64_t, 0, 'c', 'i', diag, "Child process panic", "Number of times the management process has caught a child panic" ) @@ -97,15 +100,15 @@ VSC_F(child_panic, uint64_t, 0, 'c', diag, #ifdef VSC_DO_LCK -VSC_F(creat, uint64_t, 0, 'c', debug, +VSC_F(creat, uint64_t, 0, 'c', 'i', debug, "Created locks", "" ) -VSC_F(destroy, uint64_t, 0, 'c', debug, +VSC_F(destroy, uint64_t, 0, 'c', 'i', debug, "Destroyed locks", "" ) -VSC_F(locks, uint64_t, 0, 'c', debug, +VSC_F(locks, uint64_t, 0, 'c', 'i', debug, "Lock Operations", "" ) @@ -117,31 +120,31 @@ VSC_F(locks, uint64_t, 0, 'c', debug, */ #if defined(VSC_DO_SMA) || defined (VSC_DO_SMF) -VSC_F(c_req, uint64_t, 0, 'c', info, +VSC_F(c_req, uint64_t, 0, 'c', 'i', info, "Allocator requests", "" ) -VSC_F(c_fail, uint64_t, 0, 'c', info, +VSC_F(c_fail, uint64_t, 0, 'c', 'i', info, "Allocator failures", "" ) -VSC_F(c_bytes, uint64_t, 0, 'c', info, +VSC_F(c_bytes, uint64_t, 0, 'c', 'i', info, "Bytes allocated", "" ) -VSC_F(c_freed, uint64_t, 0, 'c', info, +VSC_F(c_freed, uint64_t, 0, 'c', 'i', info, "Bytes freed", "" ) -VSC_F(g_alloc, uint64_t, 0, 'g', info, +VSC_F(g_alloc, uint64_t, 0, 'g', 'i', info, "Allocations outstanding", "" ) -VSC_F(g_bytes, uint64_t, 0, 'g', info, +VSC_F(g_bytes, uint64_t, 0, 'g', 'i', info, "Bytes outstanding", "" ) -VSC_F(g_space, uint64_t, 0, 'g', info, +VSC_F(g_space, uint64_t, 0, 'g', 'i', info, "Bytes available", "" ) @@ -157,15 +160,15 @@ VSC_F(g_space, uint64_t, 0, 'g', info, /**********************************************************************/ #ifdef VSC_DO_SMF -VSC_F(g_smf, uint64_t, 0, 'g', info, +VSC_F(g_smf, uint64_t, 0, 'g', 'i', info, "N struct smf", "" ) -VSC_F(g_smf_frag, uint64_t, 0, 'g', info, +VSC_F(g_smf_frag, uint64_t, 0, 'g', 'i', info, "N small free smf", "" ) -VSC_F(g_smf_large, uint64_t, 0, 'g', info, +VSC_F(g_smf_large, uint64_t, 0, 'g', 'i', info, "N large free smf", "" ) @@ -175,49 +178,49 @@ VSC_F(g_smf_large, uint64_t, 0, 'g', info, #ifdef VSC_DO_VBE -VSC_F(vcls, uint64_t, 0, 'g', debug, +VSC_F(vcls, uint64_t, 0, 'g', 'i', debug, "VCL references", "" ) -VSC_F(happy, uint64_t, 0, 'b', info, +VSC_F(happy, uint64_t, 0, 'b', 'b', info, "Happy health probes", "" ) -VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', info, +VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', 'i', info, "Request header bytes", "Total backend request header bytes sent" ) -VSC_F(bereq_bodybytes, uint64_t, 0, 'c', info, +VSC_F(bereq_bodybytes, uint64_t, 0, 'c', 'i', info, "Request body bytes", "Total backend request body bytes sent" ) -VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', info, +VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', 'i', info, "Response header bytes", "Total backend response header bytes received" ) -VSC_F(beresp_bodybytes, uint64_t, 0, 'c', info, +VSC_F(beresp_bodybytes, uint64_t, 0, 'c', 'i', info, "Response body bytes", "Total backend response body bytes received" ) -VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', info, +VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', 'i', info, "Pipe request header bytes", "Total request bytes sent for piped sessions" ) -VSC_F(pipe_out, uint64_t, 0, 'c', info, +VSC_F(pipe_out, uint64_t, 0, 'c', 'i', info, "Piped bytes to backend", "Total number of bytes forwarded to backend in" " pipe sessions" ) -VSC_F(pipe_in, uint64_t, 0, 'c', info, +VSC_F(pipe_in, uint64_t, 0, 'c', 'i', info, "Piped bytes from backend", "Total number of bytes forwarded from backend in" " pipe sessions" ) -VSC_F(conn, uint64_t, 0, 'g', info, +VSC_F(conn, uint64_t, 0, 'g', 'i', info, "Concurrent connections to backend", "" ) -VSC_F(req, uint64_t, 0, 'c', info, +VSC_F(req, uint64_t, 0, 'c', 'i', info, "Backend requests sent", "" ) @@ -227,47 +230,47 @@ VSC_F(req, uint64_t, 0, 'c', info, /**********************************************************************/ #ifdef VSC_DO_MEMPOOL -VSC_F(live, uint64_t, 0, 'g', debug, +VSC_F(live, uint64_t, 0, 'g', 'i', debug, "In use", "" ) -VSC_F(pool, uint64_t, 0, 'g', debug, +VSC_F(pool, uint64_t, 0, 'g', 'i', debug, "In Pool", "" ) -VSC_F(sz_wanted, uint64_t, 0, 'g', debug, +VSC_F(sz_wanted, uint64_t, 0, 'g', 'i', debug, "Size requested", "" ) -VSC_F(sz_needed, uint64_t, 0, 'g', debug, +VSC_F(sz_needed, uint64_t, 0, 'g', 'i', debug, "Size allocated", "" ) -VSC_F(allocs, uint64_t, 0, 'c', debug, +VSC_F(allocs, uint64_t, 0, 'c', 'i', debug, "Allocations", "" ) -VSC_F(frees, uint64_t, 0, 'c', debug, +VSC_F(frees, uint64_t, 0, 'c', 'i', debug, "Frees", "" ) -VSC_F(recycle, uint64_t, 0, 'c', debug, +VSC_F(recycle, uint64_t, 0, 'c', 'i', debug, "Recycled from pool", "" ) -VSC_F(timeout, uint64_t, 0, 'c', debug, +VSC_F(timeout, uint64_t, 0, 'c', 'i', debug, "Timed out from pool", "" ) -VSC_F(toosmall, uint64_t, 0, 'c', debug, +VSC_F(toosmall, uint64_t, 0, 'c', 'i', debug, "Too small to recycle", "" ) -VSC_F(surplus, uint64_t, 0, 'c', debug, +VSC_F(surplus, uint64_t, 0, 'c', 'i', debug, "Too many for pool", "" ) -VSC_F(randry, uint64_t, 0, 'c', debug, +VSC_F(randry, uint64_t, 0, 'c', 'i', debug, "Pool ran dry", "" ) diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 4a7782d..e653579 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -190,7 +190,7 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level); #undef VSC_TYPE_F #define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[]; -#define VSC_F(n,t,l,s,v,d,e) +#define VSC_F(n,t,l,s,f,v,d,e) #define VSC_DONE(U,l,t) #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/include/vapi/vsc_int.h b/include/vapi/vsc_int.h index 4a7d4a8..376a755 100644 --- a/include/vapi/vsc_int.h +++ b/include/vapi/vsc_int.h @@ -46,7 +46,7 @@ enum VSC_level_e { /* Define the vsc type structs */ #define VSC_DO(u,l,t) struct VSC_C_##l { -#define VSC_F(n,t,l,s,v,d,e) t n; +#define VSC_F(n,t,l,s,f,v,d,e) t n; #define VSC_DONE(u,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index fe8c449..69c39e6 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -387,7 +387,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr, CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \ st = vf->fantom.b; -#define VSC_F(nn,tt,ll,ss,vv,dd,ee) \ +#define VSC_F(nn,tt,ll,ss,ff,vv,dd,ee) \ vsc_add_pt(vsc, &st->nn, descs++, vf); #define VSC_DONE(U,l,t) \ @@ -437,7 +437,7 @@ vsc_build_pt_list(struct VSM_data *vd) CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \ if (!strcmp(vf->fantom.type, t)) \ iter_##l(vsc, VSC_desc_##l, vf); -#define VSC_F(n,t,l,s,v,d,e) +#define VSC_F(n,t,l,s,f,v,d,e) #define VSC_DONE(a,b,c) #include "tbl/vsc_all.h" #undef VSC_DO @@ -565,7 +565,7 @@ VSC_LevelDesc(unsigned level) #undef VSC_TYPE_F #define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { -#define VSC_F(n,t,l,s,v,d,e) {#n,#t,s,d,e,&VSC_level_desc_##v}, +#define VSC_F(n,t,l,s,f,v,d,e) {#n,#t,s,d,e,&VSC_level_desc_##v}, #define VSC_DONE(U,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO diff --git a/man/vsc2rst.c b/man/vsc2rst.c index 6c00971..4e62917 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -40,7 +40,7 @@ printf(x "\n", ##__VA_ARGS__) #define VSC_LEVEL_F(v,l,e,d) \ printf("%s ? %s\n\t%s\n\n", l, e, d); -#define VSC_F(n, t, l, s, v, d, e) \ +#define VSC_F(n, t, l, s, f, v, d, e) \ printf("%s ? %s (%s)\n\t%s\n\n", #n, e, VSC_level_##v, d); int main(int argc, char **argv) From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 96f5919 Add the presentation field to the structures in libvarnishapi. *This breaks the API* Message-ID: commit 96f5919e56f4a5895c53e9bfc98cf643c4ea0ca6 Author: Martin Blix Grydeland Date: Tue Jan 27 16:50:58 2015 +0100 Add the presentation field to the structures in libvarnishapi. *This breaks the API* As the API breaks because of this commit, also fix up some structure member name inconsistencies to match the table definition. Add the display format to the json/XML varnishstat output, but do not change the output field names to stay script compatible. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 27ef250..a65597e 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -55,7 +55,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) (void)priv; if (pt == NULL) return (0); - AZ(strcmp(pt->desc->fmt, "uint64_t")); + AZ(strcmp(pt->desc->ctype, "uint64_t")); val = *(const volatile uint64_t*)pt->ptr; sec = pt->section; @@ -66,7 +66,8 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) printf("\t\t%s\n", sec->fantom->ident); printf("\t\t%s\n", pt->desc->name); printf("\t\t%ju\n", (uintmax_t)val); - printf("\t\t%c\n", pt->desc->flag); + printf("\t\t%c\n", pt->desc->semantics); + printf("\t\t%c\n", pt->desc->format); printf("\t\t%s\n", pt->desc->sdesc); printf("\t\n"); return (0); @@ -100,7 +101,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) return (0); jp = priv; - AZ(strcmp(pt->desc->fmt, "uint64_t")); + AZ(strcmp(pt->desc->ctype, "uint64_t")); val = *(const volatile uint64_t*)pt->ptr; sec = pt->section; @@ -121,7 +122,8 @@ do_json_cb(void *priv, const struct VSC_point * const pt) if (strcmp(sec->fantom->ident, "")) printf("\"ident\": \"%s\", ", sec->fantom->ident); printf("\"value\": %ju, ", (uintmax_t)val); - printf("\"flag\": \"%c\", ", pt->desc->flag); + printf("\"flag\": \"%c\", ", pt->desc->semantics); + printf("\"format\": \"%c\", ", pt->desc->format); printf("\"description\": \"%s\"", pt->desc->sdesc); printf("}"); @@ -168,7 +170,7 @@ do_once_cb(void *priv, const struct VSC_point * const pt) if (pt == NULL) return (0); op = priv; - AZ(strcmp(pt->desc->fmt, "uint64_t")); + AZ(strcmp(pt->desc->ctype, "uint64_t")); val = *(const volatile uint64_t*)pt->ptr; sec = pt->section; i = 0; @@ -180,7 +182,7 @@ do_once_cb(void *priv, const struct VSC_point * const pt) if (i >= op->pad) op->pad = i + 1; printf("%*.*s", op->pad - i, op->pad - i, ""); - if (pt->desc->flag == 'c') + if (pt->desc->semantics == 'c') printf("%12ju %12.2f %s\n", (uintmax_t)val, val / op->up, pt->desc->sdesc); else diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index b99ff53..4294999 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -79,7 +79,7 @@ struct pt { char *key; char *name; - int flag; + int semantics; const volatile uint64_t *ptr; char seen; @@ -273,7 +273,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) CAST_OBJ_NOTNULL(pt_priv, priv, PT_PRIV_MAGIC); - AZ(strcmp(vpt->desc->fmt, "uint64_t")); + AZ(strcmp(vpt->desc->ctype, "uint64_t")); snprintf(buf, sizeof buf, "%s.%s.%s", vpt->section->type, vpt->section->ident, vpt->desc->name); buf[sizeof buf - 1] = '\0'; @@ -316,7 +316,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) pt->ptr = vpt->ptr; pt->last = *pt->ptr; - pt->flag = vpt->desc->flag; + pt->semantics = vpt->desc->semantics; pt->ma_10.nmax = 10; pt->ma_100.nmax = 100; @@ -384,12 +384,12 @@ sample_points(void) pt->chg = ((intmax_t)pt->cur - (intmax_t)pt->last) / (pt->t_cur - pt->t_last); - if (pt->flag == 'g') { + if (pt->semantics == 'g') { pt->avg = 0.; update_ma(&pt->ma_10, pt->cur); update_ma(&pt->ma_100, pt->cur); update_ma(&pt->ma_1000, pt->cur); - } else if (pt->flag == 'c') { + } else if (pt->semantics == 'c') { if (VSC_C_main != NULL && VSC_C_main->uptime) pt->avg = pt->cur / VSC_C_main->uptime; else @@ -692,7 +692,7 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) AN(w); AN(pt); - assert(pt->flag == 'b'); + assert(pt->semantics == 'b'); col = 0; while (col < COL_LAST) { @@ -737,7 +737,7 @@ draw_line(WINDOW *w, int y, struct pt *pt) mvwprintw(w, y, x, "%.*s", colw_name, pt->name); x += colw_name; - if (pt->flag == 'b') + if (pt->semantics == 'b') draw_line_bitmap(w, y, x, X, pt); else draw_line_default(w, y, x, X, pt); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 2506093..fbe59f8 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -761,7 +761,7 @@ do_stat_cb(void *priv, const struct VSC_point * const pt) if (strcmp(pt->desc->name, p)) return (0); - AZ(strcmp(pt->desc->fmt, "uint64_t")); + AZ(strcmp(pt->desc->ctype, "uint64_t")); sp->val = *(const volatile uint64_t*)pt->ptr; return (1); } diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 8dd00eb..ea62918 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -151,7 +151,8 @@ When using the -x option, the output is:: FIELD IDENT FIELD NAME FIELD VALUE - FIELD FORMAT + FIELD SEMANTICS + FIELD DISPLAY FORMAT FIELD DESCRIPTION [..] @@ -164,7 +165,7 @@ With -j the output format is:: { "timestamp": "YYYY-MM-DDTHH:mm:SS", - "FIELD NAME": {"type": "FIELD TYPE", "ident": "FIELD IDENT", "value": FIELD VALUE, "flag": "FIELD FORMAT", "description": "FIELD DESCRIPTION"}, + "FIELD NAME": {"type": "FIELD TYPE", "ident": "FIELD IDENT", "value": FIELD VALUE, "flag": "FIELD SEMANTICS", "format": "FIELD DISPLAY FORMAT", "description": "FIELD DESCRIPTION"}, [..] } diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index e653579..1247deb 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -126,13 +126,15 @@ struct VSC_section { struct VSM_fantom *fantom; }; +/* See include/tbl/vsc_fields.h for descriptions */ struct VSC_desc { const char *name; /* field name */ - const char *fmt; /* field format ("uint64_t") */ - int flag; /* 'c' = counter, 'g' = gauge */ + const char *ctype; /* C-type */ + int semantics; /* semantics */ + int format; /* display format */ + const struct VSC_level_desc *level; /* verbosity level */ const char *sdesc; /* short description */ const char *ldesc; /* long description */ - const struct VSC_level_desc *level; }; struct VSC_point { diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 69c39e6..38dd5fb 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -565,7 +565,7 @@ VSC_LevelDesc(unsigned level) #undef VSC_TYPE_F #define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { -#define VSC_F(n,t,l,s,f,v,d,e) {#n,#t,s,d,e,&VSC_level_desc_##v}, +#define VSC_F(n,t,l,s,f,v,d,e) {#n,#t,s,f,&VSC_level_desc_##v,d,e}, #define VSC_DONE(U,l,t) }; #include "tbl/vsc_all.h" #undef VSC_DO From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] bd35552 Use the presentation mode for controlling the way a field is rendered in varnishstat Message-ID: commit bd3555260e4f148fa6c76a63697996a9bdcd7454 Author: Martin Blix Grydeland Date: Fri Jan 16 15:55:17 2015 +0100 Use the presentation mode for controlling the way a field is rendered in varnishstat diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 4294999..48ae7fe 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -80,6 +80,7 @@ struct pt { char *key; char *name; int semantics; + int format; const volatile uint64_t *ptr; char seen; @@ -317,6 +318,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) pt->ptr = vpt->ptr; pt->last = *pt->ptr; pt->semantics = vpt->desc->semantics; + pt->format = vpt->desc->format; pt->ma_10.nmax = 10; pt->ma_100.nmax = 100; @@ -692,7 +694,7 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) AN(w); AN(pt); - assert(pt->semantics == 'b'); + assert(pt->format == 'b'); col = 0; while (col < COL_LAST) { @@ -737,7 +739,7 @@ draw_line(WINDOW *w, int y, struct pt *pt) mvwprintw(w, y, x, "%.*s", colw_name, pt->name); x += colw_name; - if (pt->semantics == 'b') + if (pt->format == 'b') draw_line_bitmap(w, y, x, X, pt); else draw_line_default(w, y, x, X, pt); From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 9863f3e Increase column with by 1 to allow space for a scaling factor Message-ID: commit 9863f3e7bd7c61d1d055931b3b9b80c6629678d4 Author: Martin Blix Grydeland Date: Mon Jan 19 11:28:48 2015 +0100 Increase column with by 1 to allow space for a scaling factor diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 48ae7fe..a623d46 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -62,7 +62,7 @@ #define LINES_POINTS_MIN 3 #define N_COL 6 -#define COLW 13 +#define COLW 14 #define COLW_NAME_MIN 24 struct ma { From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] ac96796 Add a 'e' key binding in varnishstat to disable/enable scaling of values Message-ID: commit ac9679684578808198329402cc22df99cf4cdbc3 Author: Martin Blix Grydeland Date: Mon Jan 19 11:30:02 2015 +0100 Add a 'e' key binding in varnishstat to disable/enable scaling of values diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index a623d46..0fbed92 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -125,6 +125,7 @@ static int current = 0; static int rebuild = 0; static int redraw = 0; static int sample = 0; +static int scale = 1; static double t_sample = 0.; static double interval = 1.; @@ -869,6 +870,10 @@ handle_keypress(int ch) hide_unseen = 1 - hide_unseen; rebuild = 1; break; + case 'e': + scale = 1 - scale; + rebuild = 1; + break; case 'g': current = 0; page_start = 0; diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index ea62918..036b268 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -124,6 +124,9 @@ The following keys control the interactive display: counters are those that has been zero for the entire runtime of varnishstat. Defaults to hide unseen counters. + + Toggle scaling of values. + Go to the top of the counter list. From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 3e01fce Add a new display mode for 'B' (bytes) presentation type counter values Message-ID: commit 3e01fceda7a78b9c3cd7189d76dff9fbed347f95 Author: Martin Blix Grydeland Date: Tue Jan 27 17:06:34 2015 +0100 Add a new display mode for 'B' (bytes) presentation type counter values diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 0fbed92..26fe520 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "vas.h" #include "miniobj.h" @@ -683,6 +684,87 @@ draw_line_default(WINDOW *w, int y, int x, int X, struct pt *pt) } } +static double +scale_bytes(double val, char *q) +{ + const char *p; + + for (p = " KMGTPEZY"; *p; p++) { + if (fabs(val) < 1024.) + break; + val /= 1024.; + } + *q = *p; + return (val); +} + +static void +print_bytes(WINDOW *w, double val) +{ + char q = ' '; + + if (scale) + val = scale_bytes(val, &q); + wprintw(w, " %12.2f%c", val, q); +} + +static void +draw_line_bytes(WINDOW *w, int y, int x, int X, struct pt *pt) +{ + enum { + COL_CUR, + COL_CHG, + COL_AVG, + COL_MA10, + COL_MA100, + COL_MA1000, + COL_LAST + } col; + + AN(w); + AN(pt); + + col = 0; + while (col < COL_LAST) { + if (X - x < COLW) + break; + wmove(w, y, x); + switch (col) { + case COL_CUR: + if (scale && pt->cur > 1024) + print_bytes(w, (double)pt->cur); + else + wprintw(w, " %12ju", (uintmax_t)pt->cur); + break; + case COL_CHG: + if (pt->t_last) + print_bytes(w, pt->chg); + else + wprintw(w, " %12s", ". "); + break; + case COL_AVG: + if (pt->avg) + print_bytes(w, pt->avg); + else + wprintw(w, " %12s", ". "); + break; + case COL_MA10: + print_bytes(w, pt->ma_10.acc); + break; + case COL_MA100: + print_bytes(w, pt->ma_100.acc); + break; + case COL_MA1000: + print_bytes(w, pt->ma_1000.acc); + break; + default: + break; + } + x += COLW; + col++; + } +} + static void draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) { @@ -740,10 +822,17 @@ draw_line(WINDOW *w, int y, struct pt *pt) mvwprintw(w, y, x, "%.*s", colw_name, pt->name); x += colw_name; - if (pt->format == 'b') + switch (pt->format) { + case 'b': draw_line_bitmap(w, y, x, X, pt); - else + break; + case 'B': + draw_line_bytes(w, y, x, X, pt); + break; + default: draw_line_default(w, y, x, X, pt); + break; + } } static void From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] ca16533 Change presentation from 'i' (integer) to 'B' (bytes) for VSM counters representing bytes. Message-ID: commit ca16533cc4a6f346e4e96efbe4630f8c9322b4c8 Author: Martin Blix Grydeland Date: Mon Jan 19 11:39:50 2015 +0100 Change presentation from 'i' (integer) to 'B' (bytes) for VSM counters representing bytes. Fixes: #1653 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 6bd68c1..c40867c 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -353,32 +353,32 @@ VSC_F(s_synth, uint64_t, 1, 'c', 'i', info, "Total synthethic responses made", "" ) -VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', 'i', info, +VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', 'B', info, "Request header bytes", "Total request header bytes received" ) -VSC_F(s_req_bodybytes, uint64_t, 1, 'c', 'i', info, +VSC_F(s_req_bodybytes, uint64_t, 1, 'c', 'B', info, "Request body bytes", "Total request body bytes received" ) -VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', 'i', info, +VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', 'B', info, "Response header bytes", "Total response header bytes transmitted" ) -VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', 'i', info, +VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', 'B', info, "Response body bytes", "Total response body bytes transmitted" ) -VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', 'i', info, +VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, "Pipe request header bytes", "Total request bytes received for piped sessions" ) -VSC_F(s_pipe_in, uint64_t, 0, 'c', 'i', info, +VSC_F(s_pipe_in, uint64_t, 0, 'c', 'B', info, "Piped bytes from client", "Total number of bytes forwarded from clients in" " pipe sessions" ) -VSC_F(s_pipe_out, uint64_t, 0, 'c', 'i', info, +VSC_F(s_pipe_out, uint64_t, 0, 'c', 'B', info, "Piped bytes to client", "Total number of bytes forwarded to clients in" " pipe sessions" @@ -517,11 +517,11 @@ VSC_F(bans_lurker_contention, uint64_t, 0, 'c', 'i', diag, "Lurker gave way for lookup", "Number of times the ban-lurker had to wait for lookups." ) -VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', 'i', diag, +VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', 'B', diag, "Bytes used by the persisted ban lists", "Number of bytes used by the persisted ban lists." ) -VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', 'i', diag, +VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', 'B', diag, "Extra bytes in persisted ban lists due to fragmentation", "Number of extra bytes accumulated through dropped and" " completed bans in the persistent ban lists." @@ -596,33 +596,33 @@ VSC_F(n_gunzip, uint64_t, 0, 'c', 'i', info, /*--------------------------------------------------------------------*/ -VSC_F(vsm_free, uint64_t, 0, 'g', 'i', diag, +VSC_F(vsm_free, uint64_t, 0, 'g', 'B', diag, "Free VSM space", "Number of bytes free in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_used, uint64_t, 0, 'g', 'i', diag, +VSC_F(vsm_used, uint64_t, 0, 'g', 'B', diag, "Used VSM space", "Number of bytes used in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_cooling, uint64_t, 0, 'g', 'i', debug, +VSC_F(vsm_cooling, uint64_t, 0, 'g', 'B', debug, "Cooling VSM space", "Number of bytes which will soon (max 1 minute) be freed" " in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_overflow, uint64_t, 0, 'g', 'i', diag, +VSC_F(vsm_overflow, uint64_t, 0, 'g', 'B', diag, "Overflow VSM space", "Number of bytes which does not fit" " in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_overflowed, uint64_t, 0, 'c', 'i', diag, +VSC_F(vsm_overflowed, uint64_t, 0, 'c', 'B', diag, "Overflowed VSM space", "Total number of bytes which did not fit" " in the shared memory used to communicate" diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 0cdb51f..1a7dfd8 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -128,11 +128,11 @@ VSC_F(c_fail, uint64_t, 0, 'c', 'i', info, "Allocator failures", "" ) -VSC_F(c_bytes, uint64_t, 0, 'c', 'i', info, +VSC_F(c_bytes, uint64_t, 0, 'c', 'B', info, "Bytes allocated", "" ) -VSC_F(c_freed, uint64_t, 0, 'c', 'i', info, +VSC_F(c_freed, uint64_t, 0, 'c', 'B', info, "Bytes freed", "" ) @@ -140,11 +140,11 @@ VSC_F(g_alloc, uint64_t, 0, 'g', 'i', info, "Allocations outstanding", "" ) -VSC_F(g_bytes, uint64_t, 0, 'g', 'i', info, +VSC_F(g_bytes, uint64_t, 0, 'g', 'B', info, "Bytes outstanding", "" ) -VSC_F(g_space, uint64_t, 0, 'g', 'i', info, +VSC_F(g_space, uint64_t, 0, 'g', 'B', info, "Bytes available", "" ) @@ -186,32 +186,32 @@ VSC_F(happy, uint64_t, 0, 'b', 'b', info, "Happy health probes", "" ) -VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', 'i', info, +VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', 'B', info, "Request header bytes", "Total backend request header bytes sent" ) -VSC_F(bereq_bodybytes, uint64_t, 0, 'c', 'i', info, +VSC_F(bereq_bodybytes, uint64_t, 0, 'c', 'B', info, "Request body bytes", "Total backend request body bytes sent" ) -VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', 'i', info, +VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', 'B', info, "Response header bytes", "Total backend response header bytes received" ) -VSC_F(beresp_bodybytes, uint64_t, 0, 'c', 'i', info, +VSC_F(beresp_bodybytes, uint64_t, 0, 'c', 'B', info, "Response body bytes", "Total backend response body bytes received" ) -VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', 'i', info, +VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, "Pipe request header bytes", "Total request bytes sent for piped sessions" ) -VSC_F(pipe_out, uint64_t, 0, 'c', 'i', info, +VSC_F(pipe_out, uint64_t, 0, 'c', 'B', info, "Piped bytes to backend", "Total number of bytes forwarded to backend in" " pipe sessions" ) -VSC_F(pipe_in, uint64_t, 0, 'c', 'i', info, +VSC_F(pipe_in, uint64_t, 0, 'c', 'B', info, "Piped bytes from backend", "Total number of bytes forwarded from backend in" " pipe sessions" @@ -238,11 +238,11 @@ VSC_F(pool, uint64_t, 0, 'g', 'i', debug, "In Pool", "" ) -VSC_F(sz_wanted, uint64_t, 0, 'g', 'i', debug, +VSC_F(sz_wanted, uint64_t, 0, 'g', 'B', debug, "Size requested", "" ) -VSC_F(sz_needed, uint64_t, 0, 'g', 'i', debug, +VSC_F(sz_needed, uint64_t, 0, 'g', 'B', debug, "Size allocated", "" ) From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] bafe805 Add a 'd' duration presentation type to VSM counters Message-ID: commit bafe80500827c15d014991187ab1e5fe02ac02bb Author: Martin Blix Grydeland Date: Mon Jan 19 14:07:55 2015 +0100 Add a 'd' duration presentation type to VSM counters Mark the two uptime counters as duration diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index c40867c..94444d3 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -35,7 +35,7 @@ * Globals, not related to traffic */ -VSC_F(uptime, uint64_t, 0, 'c', 'i', info, +VSC_F(uptime, uint64_t, 0, 'c', 'd', info, "Child process uptime", "How long the child process has been running." ) diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 1a7dfd8..7b06a8c 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -40,6 +40,7 @@ * f - Format: Display format for the field * 'b' - Bitmap * 'i' - Integer + * 'd' - Duration * v - Verbosity: Counter verbosity level (see vsc_levels.h) * d - Description: Short description of field (for screen use) * e - Explanation: Long explanation of field (for doc use) @@ -64,7 +65,7 @@ #ifdef VSC_DO_MGT -VSC_F(uptime, uint64_t, 0, 'c', 'i', info, +VSC_F(uptime, uint64_t, 0, 'c', 'd', info, "Management process uptime", "Uptime in seconds of the management process" ) From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 5b3568c Show duration as time value when scaling Message-ID: commit 5b3568c8a1b929ed0a4a631594cfe0557cfe7db6 Author: Martin Blix Grydeland Date: Mon Jan 19 14:08:24 2015 +0100 Show duration as time value when scaling diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 26fe520..fbb5b42 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -538,6 +538,14 @@ make_windows(void) } static void +print_duration(WINDOW *w, time_t t) +{ + + wprintw(w, "%4d+%02d:%02d:%02d", + t / 86400, (t % 86400) / 3600, (t % 3600) / 60, t % 60); +} + +static void draw_status(void) { time_t up_mgt = 0; @@ -553,12 +561,10 @@ draw_status(void) if (VSC_C_main != NULL) up_chld = VSC_C_main->uptime; - mvwprintw(w_status, 0, 0, "Uptime mgt: %d+%02d:%02d:%02d", - up_mgt / 86400, (up_mgt % 86400) / 3600, (up_mgt % 3600) / 60, - up_mgt % 60); - mvwprintw(w_status, 1, 0, "Uptime child: %d+%02d:%02d:%02d", - up_chld / 86400, (up_chld % 86400) / 3600, (up_chld % 3600) / 60, - up_chld % 60); + mvwprintw(w_status, 0, 0, "Uptime mgt: "); + print_duration(w_status, up_mgt); + mvwprintw(w_status, 1, 0, "Uptime child:"); + print_duration(w_status, up_chld); if (VSC_C_mgt == NULL) mvwprintw(w_status, 0, COLS - strlen(discon), discon); @@ -809,6 +815,37 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) } static void +draw_line_duration(WINDOW *w, int y, int x, int X, struct pt *pt) +{ + enum { + COL_DUR, + COL_LAST + } col; + + AN(w); + AN(pt); + + col = 0; + while (col < COL_LAST) { + if (X - x < COLW) + break; + switch (col) { + case COL_DUR: + wmove(w, y, x); + if (scale) + print_duration(w, pt->cur); + else + wprintw(w, " %12ju", (uintmax_t)pt->cur); + break; + default: + break; + } + x += COLW; + col++; + } +} + +static void draw_line(WINDOW *w, int y, struct pt *pt) { int x, X; @@ -829,6 +866,9 @@ draw_line(WINDOW *w, int y, struct pt *pt) case 'B': draw_line_bytes(w, y, x, X, pt); break; + case 'd': + draw_line_duration(w, y, x, X, pt); + break; default: draw_line_default(w, y, x, X, pt); break; From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 29e361e Make the arrows showing more data more prominent Message-ID: commit 29e361ee81dc5ada18aff4613af7a3363e1dad79 Author: Martin Blix Grydeland Date: Mon Jan 19 14:25:19 2015 +0100 Make the arrows showing more data more prominent diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index fbb5b42..560561f 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -600,10 +600,10 @@ draw_bar_t(void) x = 0; werase(w_bar_t); if (page_start > 0) - mvwaddch(w_bar_t, 0, x, ACS_UARROW); - x += 2; - mvwprintw(w_bar_t, 0, x, "%.*s", colw_name - 2, "NAME"); - x += colw_name - 2; + mvwprintw(w_bar_t, 0, x, "^^^"); + x += 4; + mvwprintw(w_bar_t, 0, x, "%.*s", colw_name - 4, "NAME"); + x += colw_name - 4; col = 0; while (col < COL_LAST) { if (X - x < COLW) @@ -925,8 +925,8 @@ draw_bar_b(void) X = getmaxx(w_bar_b); werase(w_bar_b); if (page_start + l_points < n_ptarray) - mvwaddch(w_bar_b, 0, x, ACS_DARROW); - x += 2; + mvwprintw(w_bar_b, 0, x, "vvv"); + x += 4; if (current < n_ptarray - 1) mvwprintw(w_bar_b, 0, x, "%s", ptarray[current]->name); From martin at varnish-software.com Tue Jan 27 16:17:56 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 27 Jan 2015 17:17:56 +0100 Subject: [master] 42083b8 Add a a-b/n point total in the bottom status bar Message-ID: commit 42083b8b26f79c3b2fdb440cd8d6e30c72ab5e11 Author: Martin Blix Grydeland Date: Mon Jan 19 15:04:55 2015 +0100 Add a a-b/n point total in the bottom status bar diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 560561f..381621a 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -918,6 +918,7 @@ draw_bar_b(void) { int x, X; const struct VSC_level_desc *level; + char buf[64]; AN(w_bar_b); @@ -930,12 +931,23 @@ draw_bar_b(void) if (current < n_ptarray - 1) mvwprintw(w_bar_b, 0, x, "%s", ptarray[current]->name); + snprintf(buf, sizeof(buf) - 1, "%d-%d/%d", page_start + 1, + page_start + l_points < n_ptarray ? + page_start + l_points : n_ptarray, + n_ptarray); + mvwprintw(w_bar_b, 0, X - strlen(buf), buf); + X -= strlen(buf) + 2; + level = VSC_LevelDesc(verbosity); - if (level != NULL) - mvwprintw(w_bar_b, 0, X - 7, "%7s", level->label); - X -= 7; - if (!hide_unseen) - mvwprintw(w_bar_b, 0, X - 6, "%6s", "UNSEEN"); + if (level != NULL) { + mvwprintw(w_bar_b, 0, X - strlen(level->label), "%s", + level->label); + X -= strlen(level->label) + 2; + } + if (!hide_unseen) { + mvwprintw(w_bar_b, 0, X - 6, "%s", "UNSEEN"); + X -= 8; + } wnoutrefresh(w_bar_b); } From phk at FreeBSD.org Wed Jan 28 10:16:06 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 28 Jan 2015 11:16:06 +0100 Subject: [master] 60018c5 Strip paths in backtraces. Message-ID: commit 60018c5add7e6b3b9af27bdef44970179623b5ec Author: Poul-Henning Kamp Date: Wed Jan 28 10:15:50 2015 +0000 Strip paths in backtraces. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 85a0c45..a5c2ce6 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -458,6 +458,8 @@ pan_backtrace(void) void *array[10]; size_t size; size_t i; + char **strings; + char *p; size = backtrace (array, 10); if (size == 0) @@ -466,13 +468,17 @@ pan_backtrace(void) for (i = 0; i < size; i++) { VSB_printf (pan_vsp, " "); if (Symbol_Lookup(pan_vsp, array[i]) < 0) { - char **strings; strings = backtrace_symbols(&array[i], 1); - if (strings != NULL && strings[0] != NULL) - VSB_printf(pan_vsp, - "%p: %s", array[i], strings[0]); - else + if (strings == NULL || strings[0] == NULL) { VSB_printf(pan_vsp, "%p: (?)", array[i]); + } else { + p = strrchr(strings[0], '/'); + if (p == NULL) + p = strings[0]; + else + p++; + VSB_printf(pan_vsp, "%p: %s", array[i], p); + } } VSB_printf (pan_vsp, "\n"); } From phk at FreeBSD.org Wed Jan 28 10:49:36 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 28 Jan 2015 11:49:36 +0100 Subject: [master] 7aee4eb Switch to the POSIX.2 "standard" nm output format, hoping for better portability of our backtrace hack. Message-ID: commit 7aee4eb42d60c8d52cfc34b7759b54df573677ca Author: Poul-Henning Kamp Date: Wed Jan 28 10:49:03 2015 +0000 Switch to the POSIX.2 "standard" nm output format, hoping for better portability of our backtrace hack. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 10b037e..1a46837 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -214,6 +214,7 @@ cli_check(const struct cli *cli) struct symbols { uintptr_t a; + uintptr_t l; char *n; VTAILQ_ENTRY(symbols) list; }; @@ -229,15 +230,13 @@ Symbol_Lookup(struct vsb *vsb, void *ptr) pp = (uintptr_t)ptr; s0 = NULL; VTAILQ_FOREACH(s, &symbols, list) { - if (s->a > pp) + if (s->a > pp || s->a + s->l < pp) continue; - if (s0 == NULL || s->a > s0->a) + if (s0 == NULL || s->l < s0->l) s0 = s; } if (s0 == NULL) return (-1); - if (!strcmp(s0->n, "_end")) - return (-1); VSB_printf(vsb, "%p: %s+0x%jx", ptr, s0->n, (uintmax_t)pp - s0->a); return (0); } @@ -245,43 +244,28 @@ Symbol_Lookup(struct vsb *vsb, void *ptr) static void Symbol_hack(const char *a0) { - char buf[BUFSIZ], *p, *e; + char buf[BUFSIZ]; FILE *fi; - uintptr_t a; struct symbols *s; + uintmax_t aa, ll; + char type[10]; + char name[100]; + int i; - bprintf(buf, "nm -an %s 2>/dev/null", a0); + bprintf(buf, "nm -t x -n -P %s 2>/dev/null", a0); fi = popen(buf, "r"); if (fi == NULL) return; while (fgets(buf, sizeof buf, fi)) { - if (buf[0] == ' ') - continue; - p = NULL; - a = strtoul(buf, &p, 16); - if (p == NULL) - continue; - if (a == 0) - continue; - if (*p++ != ' ') - continue; - if (*p == '-') - continue; - p++; - if (*p++ != ' ') - continue; - if (*p <= ' ') + i = sscanf(buf, "%99s\t%9s\t%jx\t%jx\n", name, type, &aa, &ll); + if (i != 4) continue; - e = strchr(p, '\0'); - AN(e); - while (e > p && isspace(e[-1])) - e--; - *e = '\0'; - s = malloc(sizeof *s + strlen(p) + 1); + s = malloc(sizeof *s + strlen(name) + 1); AN(s); - s->a = a; + s->a = aa; + s->l = ll; s->n = (void*)(s + 1); - strcpy(s->n, p); + strcpy(s->n, name); VTAILQ_INSERT_TAIL(&symbols, s, list); } (void)pclose(fi); From phk at FreeBSD.org Wed Jan 28 11:15:31 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 28 Jan 2015 12:15:31 +0100 Subject: [master] 7d9bf68 Attempt to teach the Solaris/Ports waiter how to quit Message-ID: commit 7d9bf6823a1f4f48d211c7ef532f5c26c0f613a9 Author: Poul-Henning Kamp Date: Wed Jan 28 11:14:54 2015 +0000 Attempt to teach the Solaris/Ports waiter how to quit diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 91ddf48..bcf3ea9 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -145,9 +145,6 @@ vws_thread(void *priv) struct timespec ts; struct timespec *timeout; - vws->dport = port_create(); - assert(vws->dport >= 0); - timeout = &max_ts; while (!vws->waiter->dismantle) { @@ -182,6 +179,12 @@ vws_thread(void *priv) ret = port_getn(vws->dport, ev, MAX_EVENTS, &nevents, timeout); now = VTIM_real(); + if (ret < 0 && errno == EBADF) { + /* Our stop signal */ + AN(vws->waiter->dismantle); + break; + } + if (ret < 0) assert((errno == EINTR) || (errno == ETIME)); @@ -258,6 +261,8 @@ vws_init(struct waiter *w) vws = w->priv; INIT_OBJ(vws, VWS_MAGIC); vws->waiter = w; + vws->dport = port_create(); + assert(vws->dport >= 0); AZ(pthread_create(&vws->thread, NULL, vws_thread, vws)); } @@ -271,8 +276,8 @@ vws_fini(struct waiter *w) void *vp; CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC); + AZ(close(vws->dport)); AZ(pthread_join(vws->thread, &vp)); - WRONG("Not Yet Implemented"); } /*--------------------------------------------------------------------*/ From lkarsten at varnish-software.com Wed Jan 28 12:11:05 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 28 Jan 2015 13:11:05 +0100 Subject: [master] e4965f0 Package up moved header files. Message-ID: commit e4965f006483c9620b3d2e79c9d18b91ba8d37be Author: Lasse Karstensen Date: Wed Jan 28 13:10:45 2015 +0100 Package up moved header files. diff --git a/libvarnishapi-dev.install b/libvarnishapi-dev.install index 3fe4930..dcfb93e 100644 --- a/libvarnishapi-dev.install +++ b/libvarnishapi-dev.install @@ -1,6 +1,5 @@ -usr/include +usr/include/varnish usr/share/aclocal -usr/share/varnish/include/* /usr/include/varnish usr/share/varnish/vmodtool.py -/usr/lib/*/libvarnishapi.so -/usr/lib/*/pkgconfig/*.pc +/usr/lib/libvarnishapi.so +/usr/lib/pkgconfig/*.pc diff --git a/libvarnishapi1.install b/libvarnishapi1.install index d6a64d3..eeaf559 100644 --- a/libvarnishapi1.install +++ b/libvarnishapi1.install @@ -1 +1 @@ -/usr/lib/*/lib*.so.* +/usr/lib/lib*.so.* From lkarsten at varnish-software.com Wed Jan 28 12:18:40 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 28 Jan 2015 13:18:40 +0100 Subject: [master] dac42e4 Walk back libvarnishapi1 part of e4965f006. Message-ID: commit dac42e42a5fd5af94bfc0cc07c04022193c9144e Author: Lasse Karstensen Date: Wed Jan 28 13:16:10 2015 +0100 Walk back libvarnishapi1 part of e4965f006. So our current make install places libvarnishapi1 at /usr/lib/libvarnishapi1.so.1.0.0, but the Debian build process intermediate step does not. diff --git a/libvarnishapi1.install b/libvarnishapi1.install index eeaf559..d6a64d3 100644 --- a/libvarnishapi1.install +++ b/libvarnishapi1.install @@ -1 +1 @@ -/usr/lib/lib*.so.* +/usr/lib/*/lib*.so.* From lkarsten at varnish-software.com Wed Jan 28 12:32:05 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 28 Jan 2015 13:32:05 +0100 Subject: [master] 6a94991 Walk back more *.so changes. Message-ID: commit 6a94991c415283a1ca47b08cda62125dd1ae898d Author: Lasse Karstensen Date: Wed Jan 28 13:31:01 2015 +0100 Walk back more *.so changes. At some point we should simplify our packaging setup so it isn't necessary to run a full jenkins build to catch these. diff --git a/libvarnishapi-dev.install b/libvarnishapi-dev.install index dcfb93e..f4466f5 100644 --- a/libvarnishapi-dev.install +++ b/libvarnishapi-dev.install @@ -1,5 +1,5 @@ usr/include/varnish usr/share/aclocal usr/share/varnish/vmodtool.py -/usr/lib/libvarnishapi.so -/usr/lib/pkgconfig/*.pc +/usr/lib/*/libvarnishapi.so +/usr/lib/*/pkgconfig/*.pc From lkarsten at varnish-software.com Wed Jan 28 12:56:08 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 28 Jan 2015 13:56:08 +0100 Subject: [4.0] 1b96340 Prepare 4.0.3-rc2 (proper). Message-ID: commit 1b96340a51141193f7a20795050ed7bad3b4c61d Author: Lasse Karstensen Date: Wed Jan 28 13:56:03 2015 +0100 Prepare 4.0.3-rc2 (proper). diff --git a/doc/changes.rst b/doc/changes.rst index b7f20ab..669e3b7 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,5 +1,5 @@ ================================================ -Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-27) +Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-28) ================================================ Changes since 4.0.3-rc1: From phk at FreeBSD.org Thu Jan 29 08:53:12 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 29 Jan 2015 09:53:12 +0100 Subject: [master] ffc2b8e Try to make this test a tad more robust Message-ID: commit ffc2b8e249a387e65d5f4f9d6e5154bc5654456e Author: Poul-Henning Kamp Date: Thu Jan 29 08:52:59 2015 +0000 Try to make this test a tad more robust diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc index 8f776b7..c4926e0 100644 --- a/bin/varnishtest/tests/v00014.vtc +++ b/bin/varnishtest/tests/v00014.vtc @@ -41,11 +41,13 @@ client c1 { expect resp.status == 500 } -run +server s1 -wait + server s1 { rxreq expect req.url == "/" txresp -body "slash" -} -start +} -start -wait server s1 { rxreq From daghf at varnish-software.com Fri Jan 30 19:28:30 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Fri, 30 Jan 2015 20:28:30 +0100 Subject: [master] a281a10 Fix vmod priv doc typo. Message-ID: commit a281a1063fd32b695aea363894b9487d9fcefede Author: Dag Haavi Finstad Date: Fri Jan 30 20:27:38 2015 +0100 Fix vmod priv doc typo. Spotted by: gquintard diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 70f287e..9209c4c 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -283,7 +283,7 @@ malloc would look like this:: if (priv->priv == NULL) { priv->priv = calloc(sizeof(struct myfoo), 1); AN(priv->priv); - priv->priv = free; /* free(3) */ + priv->free = free; /* free(3) */ mystate = priv->priv; mystate->foo = 21; ...