From phk at FreeBSD.org Mon Nov 3 10:06:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Nov 2014 11:06:30 +0100 Subject: [master] 0659213 Remove layer-breaking up-calls to VDI_Finish() and make VBE Do The Right Thing instead. Message-ID: commit 0659213076e177bfba810f316d2b7abfb07541e5 Author: Poul-Henning Kamp Date: Mon Nov 3 10:05:31 2014 +0000 Remove layer-breaking up-calls to VDI_Finish() and make VBE Do The Right Thing instead. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 0befb29..8454f56 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -384,6 +384,39 @@ vbe_dir_healthy(const struct director *d, const struct busyobj *bo, return (VBE_Healthy(be, changed)); } +static void __match_proto__(vdi_finish_f) +vbe_dir_finish(const struct director *d, struct worker *wrk, + struct busyobj *bo) +{ + struct backend *bp; + + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); + if (bo->htc->vbc == NULL) + return; + bp = bo->htc->vbc->backend; + 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); + 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); + Lck_Lock(&bp->mtx); + VSC_C_main->backend_recycle++; + VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list); + VBE_DropRefLocked(bp, &bo->acct); + } + bo->htc->vbc = NULL; + bo->htc = NULL; +} + static int __match_proto__(vdi_gethdrs_f) vbe_dir_gethdrs(const struct director *d, struct worker *wrk, struct busyobj *bo) @@ -408,6 +441,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, * Do a single retry in that case. */ if (i == 1) { + vbe_dir_finish(d, wrk, bo); AZ(bo->htc); VSC_C_main->backend_retry++; bo->doclose = SC_NULL; @@ -421,6 +455,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, i = V1F_fetch_hdr(wrk, bo); } if (i != 0) { + vbe_dir_finish(d, wrk, bo); bo->doclose = SC_NULL; AZ(bo->htc); } else { @@ -442,39 +477,6 @@ vbe_dir_getbody(const struct director *d, struct worker *wrk, return (0); } -static void __match_proto__(vdi_finish_f) -vbe_dir_finish(const struct director *d, struct worker *wrk, - struct busyobj *bo) -{ - struct backend *bp; - - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - - CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - if (bo->htc->vbc == NULL) - return; - bp = bo->htc->vbc->backend; - 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); - 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); - Lck_Lock(&bp->mtx); - VSC_C_main->backend_recycle++; - VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list); - VBE_DropRefLocked(bp, &bo->acct); - } - bo->htc->vbc = NULL; - bo->htc = NULL; -} - static struct suckaddr * __match_proto__(vdi_suckaddr_f) vbe_dir_suckaddr(const struct director *d, struct worker *wrk, struct busyobj *bo) diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 0df939e..3a1961a 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -100,6 +100,7 @@ VDI_GetBody(const struct director *d, struct worker *wrk, struct busyobj *bo) AZ(d->resolve); AN(d->getbody); + assert(bo->director_state == DIR_S_HDRS); bo->director_state = DIR_S_BODY; return (d->getbody(d, wrk, bo)); } @@ -118,9 +119,8 @@ VDI_Finish(const struct director *d, struct worker *wrk, struct busyobj *bo) AN(d->finish); assert(bo->director_state != DIR_S_NULL); - bo->director_state = DIR_S_NULL; - d->finish(d, wrk, bo); + bo->director_state = DIR_S_NULL; } /* Get a connection --------------------------------------------------*/ diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 58175b4..ac5448c 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -141,8 +141,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) errno, strerror(errno)); VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk)); bo->doclose = SC_TX_ERROR; - VDI_Finish(bo->director_resp, bo->wrk, bo); - /* XXX: other cleanup ? */ return (retry); } VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk)); @@ -168,8 +166,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) "http %sread error: overflow", first ? "first " : ""); bo->doclose = SC_RX_OVERFLOW; - VDI_Finish(bo->director_resp, bo->wrk, bo); - /* XXX: other cleanup ? */ return (-1); } if (hs == HTTP1_ERROR_EOF) { @@ -178,8 +174,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF", first ? "first " : ""); bo->doclose = SC_RX_TIMEOUT; - VDI_Finish(bo->director_resp, bo->wrk, bo); - /* XXX: other cleanup ? */ return (retry); } if (first) { @@ -196,8 +190,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo) if (HTTP1_DissectResponse(hp, htc)) { VSLb(bo->vsl, SLT_FetchError, "http format error"); bo->doclose = SC_RX_JUNK; - VDI_Finish(bo->director_resp, bo->wrk, bo); - /* XXX: other cleanup ? */ return (-1); } From phk at FreeBSD.org Mon Nov 3 10:34:41 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Nov 2014 11:34:41 +0100 Subject: [master] 969674d 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 969674dcb3b4d430a38b7f1b1e41199b25cc8491 Author: Poul-Henning Kamp Date: Mon Nov 3 10:34:31 2014 +0000 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 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index e83d06d..f9cf52c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -957,9 +957,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_oc != NULL) + (void)HSH_DerefObjCore(wrk, &bo->ims_oc); + 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 f714e33..5b0c52d 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -228,8 +228,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 phk at FreeBSD.org Mon Nov 3 10:55:21 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Nov 2014 11:55:21 +0100 Subject: [master] bb75c9c Don't add another Connection: header if we already have one, but do insist on it being "close" if we need that. Message-ID: commit bb75c9cdda5f389adae15b68c79d2023d79ed873 Author: Poul-Henning Kamp Date: Mon Nov 3 10:54:31 2014 +0000 Don't add another Connection: header if we already have one, but do insist on it being "close" if we need that. Test case by daghf Fixes #1613 diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index bc24ff3..c0eaeca 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -142,8 +142,13 @@ V1D_Deliver(struct req *req, struct busyobj *bo) VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); - http_SetHeader(req->resp, - req->doclose ? "Connection: close" : "Connection: keep-alive"); + if (req->doclose) { + if (!http_HdrIs(req->resp, H_Connection, "close")) { + http_Unset(req->resp, H_Connection); + http_SetHeader(req->resp, "Connection: close"); + } + } else if (!http_GetHdr(req->resp, H_Connection, NULL)) + http_SetHeader(req->resp, "Connection: keep-alive"); VDP_push(req, v1d_bytes, NULL, 1); diff --git a/bin/varnishtest/tests/r01613.vtc b/bin/varnishtest/tests/r01613.vtc new file mode 100644 index 0000000..62c7213 --- /dev/null +++ b/bin/varnishtest/tests/r01613.vtc @@ -0,0 +1,32 @@ +varnishtest "Extra Connection header erroneously inserted." + +server s1 { + rxreq + txresp +} -start + +varnish v2 -vcl+backend { + sub vcl_deliver { + set resp.http.Connection = "close"; + } +} -start + +varnish v1 -vcl { + import ${vmod_std}; + + backend b { + .host = "${v2_addr}"; + .port = "${v2_port}"; + } + + sub vcl_backend_response { + std.collect(beresp.http.Connection); + set beresp.http.foo = beresp.http.Connection; + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.foo == "close" +} -run From fgsch at lodoss.net Mon Nov 3 11:23:30 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Nov 2014 12:23:30 +0100 Subject: [master] 5caf84e Fix typo Message-ID: commit 5caf84ecc7f50e40202d3c4d0a924ffca953f528 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 phk at FreeBSD.org Mon Nov 3 13:07:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Nov 2014 14:07:54 +0100 Subject: [master] cbcfce5 Remove two unused counters Message-ID: commit cbcfce5ca13ccc787ab5c7294e551bbf594a6349 Author: Poul-Henning Kamp Date: Mon Nov 3 13:07:22 2014 +0000 Remove two unused counters The sms_ counters were removed previously Fixes #1611 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 5b0c52d..adc8019 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -101,16 +101,6 @@ VSC_F(client_req_400, uint64_t, 1, 'a', info, " malformed in some drastic way." ) -VSC_F(client_req_411, uint64_t, 1, 'a', info, - "Client requests received, subject to 411 errors", - "411 means the client did not send a Content-Lenght for the req.body." -) - -VSC_F(client_req_413, uint64_t, 1, 'a', info, - "Client requests received, subject to 413 errors", - "413 means that HTTP headers exceeded length or count limits." -) - VSC_F(client_req_417, uint64_t, 1, 'a', info, "Client requests received, subject to 417 errors", "417 means that something went wrong with an Expect: header." From lkarsten at varnish-software.com Tue Nov 4 11:49:06 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 04 Nov 2014 12:49:06 +0100 Subject: [3.0] 1428ea8 Consistent use of line feeds on headlines. Message-ID: commit 1428ea8f8ee3422eabe118f08980be7aa1afe81f Author: Lasse Karstensen Date: Tue Nov 4 12:33:11 2014 +0100 Consistent use of line feeds on headlines. diff --git a/doc/changes.rst b/doc/changes.rst index 8291cee..f11c9d2 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -44,6 +44,7 @@ varnishd .. _bug #1376: http://varnish-cache.org/trac/ticket/1376 + ================================ Changes from 3.0.4 to 3.0.5 rc 1 ================================ @@ -81,6 +82,7 @@ varnishadm .. _bug #1314: http://varnish-cache.org/trac/ticket/1314 + ================================ Changes from 3.0.4 rc 1 to 3.0.4 ================================ @@ -97,6 +99,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 ================================ @@ -155,6 +158,7 @@ Other least on i386. - Make libvarnish prefer exact hits when looking for VSL tags. + =========================== Changes from 3.0.2 to 3.0.3 =========================== @@ -275,6 +279,7 @@ Other .. _bug #1003: http://varnish-cache.org/trac/ticket/1003 + ================================ Changes from 3.0.2 rc 1 to 3.0.2 ================================ @@ -305,6 +310,7 @@ Other - Some Solaris portability updates. + ================================ Changes from 3.0.1 to 3.0.2 rc 1 ================================ @@ -366,6 +372,7 @@ Other - Some Solaris portability updates. + ================================ Changes from 3.0.1 rc 1 to 3.0.1 ================================ @@ -397,6 +404,7 @@ Other - Documentation updates + ================================ Changes from 3.0.0 to 3.0.1 rc 1 ================================ @@ -473,6 +481,7 @@ Other .. _bug #961: http://varnish-cache.org/trac/ticket/961 + ================================ Changes from 3.0 beta 2 to 3.0.0 ================================ @@ -500,6 +509,7 @@ varnishadm .. _bug #935: http://varnish-cache.org/trac/ticket/935 + ===================================== Changes from 3.0 beta 1 to 3.0 beta 2 ===================================== @@ -551,6 +561,7 @@ VMODs - The std module now has proper documentation, including a manual page + ================================ Changes from 2.1.5 to 3.0 beta 1 ================================ From lkarsten at varnish-software.com Tue Nov 4 11:49:06 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 04 Nov 2014 12:49:06 +0100 Subject: [3.0] 31f54ca Correct placement of VCL truth change. Message-ID: commit 31f54ca157cc4fedbcdcef5bf1d14da91a6be312 Author: Lasse Karstensen Date: Tue Nov 4 12:37:54 2014 +0100 Correct placement of VCL truth change. During the last VDD I (hastily) added a note that the empty VCL truth value changed between 3.0.2 and 3.0.3. As Geoff found after digging into this (see varnish-misc@ yesterday), this happened between 3.0.3 and 3.0.4. diff --git a/doc/changes.rst b/doc/changes.rst index f11c9d2..e482183 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -90,6 +90,9 @@ Changes from 3.0.4 rc 1 to 3.0.4 varnishd -------- +Note: In between 3.0.3 and 3.0.4 the VCL truth value for empty strings changed. +Please see `Bug #1218` and `Bug #1406`_ for the details. + - Set the waiter pipe as non-blocking and record overflows. `Bug #1285` - Fix up a bug in the ACL compile code that could lead to false @@ -98,6 +101,7 @@ varnishd .. _bug #1285: http://varnish-cache.org/trac/ticket/1285 .. _bug #1312: http://varnish-cache.org/trac/ticket/1312 +.. _bug #1218: http://varnish-cache.org/trac/ticket/1285 ================================ @@ -163,9 +167,6 @@ Other Changes from 3.0.2 to 3.0.3 =========================== -Note: In between 3.0.2 and 3.0.3 the VCL truth value for empty strings changed. -Please see `Bug #1406`_ for the details. - Varnishd -------- From lkarsten at varnish-software.com Tue Nov 4 15:38:53 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 04 Nov 2014 16:38:53 +0100 Subject: [master] b6beb76 This should be plural. Message-ID: commit b6beb762657155b5f4ca65f940ca1a2941fa9137 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 52d25dc..ced0685 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 fgsch at lodoss.net Tue Nov 4 16:04:08 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 04 Nov 2014 17:04:08 +0100 Subject: [master] 7446b5d Unit has changed as well Message-ID: commit 7446b5d8f855cb677d5a5e4b8726a44c3c24ce6a 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 fgsch at lodoss.net Tue Nov 4 16:35:18 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 04 Nov 2014 17:35:18 +0100 Subject: [master] b4391c0 Use units consistently Message-ID: commit b4391c053ab204028f6b4b8c80d9aa5b1065665d 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 ced0685..3bcb880 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 fgsch at lodoss.net Tue Nov 4 16:54:20 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 04 Nov 2014 17:54:20 +0100 Subject: [master] 2eb85e1 More changes from varnish 3 and some specific to master Message-ID: commit 2eb85e130d800f9ecd42eb6e8dadfede1a16c991 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 Wed Nov 5 10:07:20 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 05 Nov 2014 11:07:20 +0100 Subject: [master] 0e911b8 Use parameter instead of param. Message-ID: commit 0e911b87a8672b697db1ac43c770691cf007a3c4 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 adc8019..cc43aa6 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -234,21 +234,22 @@ VSC_F(fetch_no_thread, 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, @@ -265,14 +266,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, @@ -296,14 +297,13 @@ VSC_F(busy_killed, 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 Wed Nov 5 10:07:21 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 05 Nov 2014 11:07:21 +0100 Subject: [master] 232aedf Improve the long description of counters. Message-ID: commit 232aedfa1967f5a05b8df46c1f37c02e4f59eb1d 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 cc43aa6..1a57bf3 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." ) @@ -108,7 +108,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." ) /*---------------------------------------------------------------------*/ @@ -140,7 +140,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, @@ -278,7 +279,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." ) @@ -309,42 +310,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 fgsch at lodoss.net Wed Nov 5 13:04:12 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 05 Nov 2014 14:04:12 +0100 Subject: [master] ef77c38 GC, Kristian says is no longer needed Message-ID: commit ef77c38dd6537b060dacb130d0e3614b1fe08606 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 fgsch at lodoss.net Wed Nov 5 13:10:14 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 05 Nov 2014 14:10:14 +0100 Subject: [master] 69a4711 Plural Message-ID: commit 69a4711e346f356a8dc4161aac8c6f663e91c295 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 martin at varnish-software.com Fri Nov 7 13:17:23 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:23 +0100 Subject: [4.0] 419a08f Fix a cornercase related to empty pass objects. Message-ID: commit 419a08f5362a0b9885ecae5cc443fb82e2c3c002 Author: Poul-Henning Kamp Date: Tue Oct 21 09:00:52 2014 +0000 Fix a cornercase related to empty pass objects. Fixes #1612 Testcase by: daghf Conflicts: bin/varnishd/cache/cache_http1_deliver.c diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 73aea69..9b0d51b 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -240,29 +240,36 @@ V1D_Deliver(struct req *req, struct busyobj *bo) req->res_mode = 0; + if (req->esi_level > 0) + req->res_mode |= RES_ESI_CHILD; + if (!req->disable_esi && req->obj->esidata != NULL) { /* In ESI mode, we can't know the aggregate length */ - req->res_mode &= ~RES_LEN; req->res_mode |= RES_ESI; + RFC2616_Weaken_Etag(req->resp); + } + + if (req->res_mode & (RES_ESI_CHILD|RES_ESI)) { + /* nothing */ } else if (req->resp->status == 304) { req->res_mode &= ~RES_LEN; http_Unset(req->resp, H_Content_Length); req->wantbody = 0; - } else if (bo == NULL) { - /* XXX: Not happy with this convoluted test */ + } else if (bo != NULL) { + /* Streaming, decide CHUNKED/EOF later */ + } else if ((req->obj->objcore->flags & OC_F_PASS) && !req->wantbody) { + /* + * if we pass a HEAD the C-L header may already be in the + * object and it will not match the actual storage length + * which is zero. + * Hand that C-L header back to client. + */ req->res_mode |= RES_LEN; - if (!(req->obj->objcore->flags & OC_F_PASS) || - req->obj->len != 0) { - http_Unset(req->resp, H_Content_Length); - http_PrintfHeader(req->resp, - "Content-Length: %zd", req->obj->len); - } - } - - if (req->esi_level > 0) { - /* Included ESI object, always CHUNKED or EOF */ - req->res_mode &= ~RES_LEN; - req->res_mode |= RES_ESI_CHILD; + } else { + req->res_mode |= RES_LEN; + http_Unset(req->resp, H_Content_Length); + http_PrintfHeader(req->resp, + "Content-Length: %zd", req->obj->len); } if (cache_param->http_gzip_support && req->obj->gziped && @@ -314,9 +321,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo) v1d_dorange(req, bo, r); } - if (req->res_mode & RES_ESI) - RFC2616_Weaken_Etag(req->resp); - WRW_Reserve(req->wrk, &req->sp->fd, req->vsl, req->t_prev); /* diff --git a/bin/varnishtest/tests/r00730.vtc b/bin/varnishtest/tests/r00730.vtc index bb416e8..67b9598 100644 --- a/bin/varnishtest/tests/r00730.vtc +++ b/bin/varnishtest/tests/r00730.vtc @@ -4,7 +4,7 @@ server s1 { rxreq txresp -bodylen 5 rxreq - txresp -bodylen 6 + txresp -nolen -hdr "Content-Length: 6" } -start varnish v1 -vcl+backend { diff --git a/bin/varnishtest/tests/r01612.vtc b/bin/varnishtest/tests/r01612.vtc new file mode 100644 index 0000000..e66d3ec --- /dev/null +++ b/bin/varnishtest/tests/r01612.vtc @@ -0,0 +1,52 @@ +varnishtest "Missing Content-Length/T-E on passed empty chunked responses." + +server s1 { + # Empty c-l response is OK. + rxreq + expect req.url == "/0" + txresp + + # Nonzero chunked response is OK. + rxreq + expect req.url == "/1" + send "HTTP/1.1 200 OK\n" + send "Transfer-encoding: chunked\n" + send "\n" + chunkedlen 20 + chunkedlen 0 + + # Empty chunked response is not. + rxreq + expect req.url == "/2" + send "HTTP/1.1 200 OK\n" + send "Transfer-encoding: chunked\n" + send "\n" + chunkedlen 0 +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_response { + set beresp.do_stream = false; + } +} -start + + +client c1 { + txreq -url "/0" + rxresp + expect resp.bodylen == 0 + expect resp.http.Content-Length == "0" + + txreq -url "/1" + rxresp + expect resp.bodylen == 20 + expect resp.http.Content-Length == "20" + + txreq -url "/2" + rxresp + expect resp.bodylen == 0 + expect resp.http.Content-Length == "0" +} -run From martin at varnish-software.com Fri Nov 7 13:17:23 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:23 +0100 Subject: [4.0] 7d633a3 Check for multiple Content-Length headers Message-ID: commit 7d633a389db4adf23153ed788c34baef76224ae5 Author: Poul-Henning Kamp Date: Thu Oct 30 09:40:36 2014 +0000 Check for multiple Content-Length headers diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index f2998d4..1a77ec3 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -168,6 +168,25 @@ http_find_header(char * const *hh, const char *hdr) } /********************************************************************** + * count header + */ + +static int +http_count_header(char * const *hh, const char *hdr) +{ + int n, l, r = 0; + + l = strlen(hdr); + + for (n = 3; hh[n] != NULL; n++) { + if (strncasecmp(hdr, hh[n], l) || hh[n][l] != ':') + continue; + r++; + } + return (r); +} + +/********************************************************************** * Expect */ @@ -535,6 +554,9 @@ cmd_http_rxresp(CMD_ARGS) "Unknown http rxresp spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 0); + if (http_count_header(hp->resp, "Content-Length") > 1) + vtc_log(hp->vl, 0, + "Multiple Content-Length headers.\n"); hp->body = hp->rxbuf + hp->prxbuf; if (!has_obj) return; @@ -561,6 +583,9 @@ cmd_http_rxresphdrs(CMD_ARGS) vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 0); + if (http_count_header(hp->resp, "Content-Length") > 1) + vtc_log(hp->vl, 0, + "Multiple Content-Length headers.\n"); } @@ -819,6 +844,9 @@ cmd_http_rxreq(CMD_ARGS) vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); + if (http_count_header(hp->req, "Content-Length") > 1) + vtc_log(hp->vl, 0, + "Multiple Content-Length headers.\n"); hp->body = hp->rxbuf + hp->prxbuf; http_swallow_body(hp, hp->req, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); @@ -839,6 +867,9 @@ cmd_http_rxreqhdrs(CMD_ARGS) vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); + if (http_count_header(hp->req, "Content-Length") > 1) + vtc_log(hp->vl, 0, + "Multiple Content-Length headers.\n"); } static void From martin at varnish-software.com Fri Nov 7 13:17:23 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:23 +0100 Subject: [4.0] 496d27f Make it possible to receive resphdrs and respbody separately. Message-ID: commit 496d27f0291fe4a9ec900b87cee052fb33be4c81 Author: Poul-Henning Kamp Date: Thu Oct 30 10:10:08 2014 +0000 Make it possible to receive resphdrs and respbody separately. Always interpret C-L in decimal diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 1a77ec3..4dcd69a 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -469,7 +469,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) p = http_find_header(hh, "content-length"); if (p != NULL) { hp->body = hp->rxbuf + hp->prxbuf; - l = strtoul(p, NULL, 0); + l = strtoul(p, NULL, 10); (void)http_rxchar(hp, l, 0); vtc_dump(hp->vl, 4, "body", hp->body, l); hp->bodyl = l; @@ -873,7 +873,7 @@ cmd_http_rxreqhdrs(CMD_ARGS) } static void -cmd_http_rxbody(CMD_ARGS) +cmd_http_rxreqbody(CMD_ARGS) { struct http *hp; @@ -881,7 +881,7 @@ cmd_http_rxbody(CMD_ARGS) (void)vl; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); ONLY_SERVER(hp, av); - AZ(strcmp(av[0], "rxbody")); + AZ(strcmp(av[0], "rxreqbody")); av++; for(; *av != NULL; av++) @@ -891,6 +891,24 @@ cmd_http_rxbody(CMD_ARGS) } static void +cmd_http_rxrespbody(CMD_ARGS) +{ + struct http *hp; + + (void)cmd; + (void)vl; + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + ONLY_CLIENT(hp, av); + AZ(strcmp(av[0], "rxrespbody")); + av++; + + for(; *av != NULL; av++) + vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); + http_swallow_body(hp, hp->resp, 0); + vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); +} + +static void cmd_http_rxchunk(CMD_ARGS) { struct http *hp; @@ -1224,12 +1242,13 @@ static const struct cmds http_cmds[] = { { "rxreq", cmd_http_rxreq }, { "rxreqhdrs", cmd_http_rxreqhdrs }, + { "rxreqbody", cmd_http_rxreqbody }, { "rxchunk", cmd_http_rxchunk }, - { "rxbody", cmd_http_rxbody }, { "txresp", cmd_http_txresp }, { "rxresp", cmd_http_rxresp }, { "rxresphdrs", cmd_http_rxresphdrs }, + { "rxrespbody", cmd_http_rxrespbody }, { "gunzip", cmd_http_gunzip_body }, { "expect", cmd_http_expect }, { "send", cmd_http_send }, From martin at varnish-software.com Fri Nov 7 13:17:23 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:23 +0100 Subject: [4.0] abe626a Fix a couple of bugs for the detached rx*body functions. Message-ID: commit abe626afc10bdbee86531579b76b6ddc79e4a56f Author: Poul-Henning Kamp Date: Thu Oct 30 15:49:39 2014 +0000 Fix a couple of bugs for the detached rx*body functions. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 4dcd69a..21fceed 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -465,10 +465,10 @@ http_swallow_body(struct http *hp, char * const *hh, int body) char *p; int i, l, ll; + hp->body = hp->rxbuf + hp->prxbuf; ll = 0; p = http_find_header(hh, "content-length"); if (p != NULL) { - hp->body = hp->rxbuf + hp->prxbuf; l = strtoul(p, NULL, 10); (void)http_rxchar(hp, l, 0); vtc_dump(hp->vl, 4, "body", hp->body, l); @@ -487,7 +487,6 @@ http_swallow_body(struct http *hp, char * const *hh, int body) return; } if (body) { - hp->body = hp->rxbuf + hp->prxbuf; do { i = http_rxchar(hp, 1, 1); ll += i; @@ -557,7 +556,6 @@ cmd_http_rxresp(CMD_ARGS) if (http_count_header(hp->resp, "Content-Length") > 1) vtc_log(hp->vl, 0, "Multiple Content-Length headers.\n"); - hp->body = hp->rxbuf + hp->prxbuf; if (!has_obj) return; else if (!strcmp(hp->resp[1], "200")) @@ -847,7 +845,6 @@ cmd_http_rxreq(CMD_ARGS) if (http_count_header(hp->req, "Content-Length") > 1) vtc_log(hp->vl, 0, "Multiple Content-Length headers.\n"); - hp->body = hp->rxbuf + hp->prxbuf; http_swallow_body(hp, hp->req, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } From martin at varnish-software.com Fri Nov 7 13:17:23 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:23 +0100 Subject: [4.0] 9c75071 Add a debug facility to force a WRW_Flush after the headers. Message-ID: commit 9c7507131f67dfbee919b58caf6f3217263bbf0b Author: Poul-Henning Kamp Date: Thu Oct 30 15:30:12 2014 +0000 Add a debug facility to force a WRW_Flush after the headers. Conflicts: bin/varnishd/cache/cache_http1_deliver.c diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 9b0d51b..3779238 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -329,6 +329,9 @@ V1D_Deliver(struct req *req, struct busyobj *bo) if (!(req->res_mode & RES_ESI_CHILD)) req->resp_hdrbytes += HTTP1_Write(req->wrk, req->resp, HTTP1_Resp); + if (DO_DEBUG(DBG_FLUSH_HEAD)) { + (void)WRW_Flush(req->wrk); + } if (req->res_mode & RES_CHUNKED) WRW_Chunked(req->wrk); @@ -440,6 +443,9 @@ V1D_Deliver_Synth(struct req *req) if (!(req->res_mode & RES_ESI_CHILD)) req->resp_hdrbytes += HTTP1_Write(req->wrk, req->resp, HTTP1_Resp); + if (DO_DEBUG(DBG_FLUSH_HEAD)) { + (void)WRW_Flush(req->wrk); + } if (req->res_mode & RES_CHUNKED) WRW_Chunked(req->wrk); diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 59bc64e..81d5e38 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -38,3 +38,4 @@ DEBUG_BIT(HASHEDGE, hashedge, "Edge cases in Hash") 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") From martin at varnish-software.com Fri Nov 7 13:17:24 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 07 Nov 2014 14:17:24 +0100 Subject: [4.0] 535d44b Don't needlessly throw away Content-Length from backend, but assume it is sane and pass it to streaming clients, provided we don't munge the body along the way. Message-ID: commit 535d44b8909ee88e8700a35bed79f9ca77e445a4 Author: Martin Blix Grydeland Date: Thu Nov 6 17:59:16 2014 +0100 Don't needlessly throw away Content-Length from backend, but assume it is sane and pass it to streaming clients, provided we don't munge the body along the way. The ungzip'ed length stored as attribute has not been backported to 4.0, meaning on-the-fly ungzip will be delivered chunked. Fixes: #1506 Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 699d9a8..a07d6e6 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -360,6 +360,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) AZ(bo->do_esi); if (bo->ims_obj != NULL && bo->beresp->status == 304) { + http_Unset(bo->beresp, H_Content_Length); http_Merge(bo->ims_obj->http, bo->beresp, bo->ims_obj->changed_gzip); assert(bo->beresp->status == 200); @@ -468,19 +469,23 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) { RFC2616_Weaken_Etag(bo->beresp); + http_Unset(bo->beresp, H_Content_Length); VFP_Push(bo, vfp_gunzip_pull, 0); } if (bo->do_esi && bo->do_gzip) { VFP_Push(bo, vfp_esi_gzip_pull, 0); + http_Unset(bo->beresp, H_Content_Length); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { VFP_Push(bo, vfp_esi_gzip_pull, 0); + http_Unset(bo->beresp, H_Content_Length); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi) { VFP_Push(bo, vfp_esi_pull, 0); } else if (bo->do_gzip) { VFP_Push(bo, vfp_gzip_pull, 0); + http_Unset(bo->beresp, H_Content_Length); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->is_gzip && !bo->do_gunzip) { VFP_Push(bo, vfp_testgunzip_pull, 0); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 3779238..623b07b 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -240,36 +240,23 @@ V1D_Deliver(struct req *req, struct busyobj *bo) req->res_mode = 0; + if (!req->disable_esi && req->obj->esidata != NULL) + req->res_mode |= RES_ESI; + if (req->esi_level > 0) req->res_mode |= RES_ESI_CHILD; - if (!req->disable_esi && req->obj->esidata != NULL) { + if (req->res_mode & (RES_ESI_CHILD|RES_ESI)) { /* In ESI mode, we can't know the aggregate length */ - req->res_mode |= RES_ESI; + http_Unset(req->resp, H_Content_Length); RFC2616_Weaken_Etag(req->resp); - } - - if (req->res_mode & (RES_ESI_CHILD|RES_ESI)) { - /* nothing */ } else if (req->resp->status == 304) { - req->res_mode &= ~RES_LEN; http_Unset(req->resp, H_Content_Length); req->wantbody = 0; - } else if (bo != NULL) { - /* Streaming, decide CHUNKED/EOF later */ - } else if ((req->obj->objcore->flags & OC_F_PASS) && !req->wantbody) { - /* - * if we pass a HEAD the C-L header may already be in the - * object and it will not match the actual storage length - * which is zero. - * Hand that C-L header back to client. - */ - req->res_mode |= RES_LEN; - } else { - req->res_mode |= RES_LEN; - http_Unset(req->resp, H_Content_Length); - http_PrintfHeader(req->resp, - "Content-Length: %zd", req->obj->len); + } else if (bo == NULL && + !http_GetHdr(req->resp, H_Content_Length, NULL)) { + http_PrintfHeader(req->resp, "Content-Length: %zd", + req->obj->len); } if (cache_param->http_gzip_support && req->obj->gziped && @@ -279,31 +266,25 @@ V1D_Deliver(struct req *req, struct busyobj *bo) * XXX: we could cache that, but would still deliver * XXX: with multiple writes because of the gunzip buffer */ - req->res_mode &= ~RES_LEN; req->res_mode |= RES_GUNZIP; + http_Unset(req->resp, H_Content_Encoding); + http_Unset(req->resp, H_Content_Length); } - if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { - /* We havn't chosen yet, do so */ - if (!req->wantbody) { - /* Nothing */ - } else if (req->http->protover >= 11) { + if (http_GetHdr(req->resp, H_Content_Length, NULL)) + req->res_mode |= RES_LEN; + + if (req->wantbody && !(req->res_mode & RES_LEN)) { + if (req->http->protover >= 11) { + http_SetHeader(req->resp, "Transfer-Encoding: chunked"); req->res_mode |= RES_CHUNKED; } else { req->res_mode |= RES_EOF; req->doclose = SC_TX_EOF; } } - VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); - - if (!(req->res_mode & RES_LEN)) - http_Unset(req->resp, H_Content_Length); - - if (req->res_mode & RES_GUNZIP) - http_Unset(req->resp, H_Content_Encoding); - if (req->res_mode & RES_CHUNKED) - http_SetHeader(req->resp, "Transfer-Encoding: chunked"); + VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); http_SetHeader(req->resp, req->doclose ? "Connection: close" : "Connection: keep-alive"); @@ -380,44 +361,29 @@ V1D_Deliver_Synth(struct req *req) AN(req->synth_body); req->res_mode = 0; - if (req->resp->status == 304) { - req->res_mode &= ~RES_LEN; - http_Unset(req->resp, H_Content_Length); + + http_Unset(req->resp, H_Content_Length); + if (req->esi_level > 0) { + req->res_mode |= RES_ESI_CHILD; + } else if (req->resp->status == 304) { req->wantbody = 0; } else { - req->res_mode |= RES_LEN; - http_Unset(req->resp, H_Content_Length); http_PrintfHeader(req->resp, "Content-Length: %zd", VSB_len(req->synth_body)); + req->res_mode |= RES_LEN; } - if (req->esi_level > 0) { - /* Included ESI object, always CHUNKED or EOF */ - req->res_mode &= ~RES_LEN; - req->res_mode |= RES_ESI_CHILD; - } - - if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { - /* We havn't chosen yet, do so */ - if (!req->wantbody) { - /* Nothing */ - } else if (req->http->protover >= 11) { + if (req->wantbody && !(req->res_mode & RES_LEN)) { + if (req->http->protover >= 11) { + http_SetHeader(req->resp, "Transfer-Encoding: chunked"); req->res_mode |= RES_CHUNKED; } else { req->res_mode |= RES_EOF; req->doclose = SC_TX_EOF; } } - VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); - if (!(req->res_mode & RES_LEN)) - http_Unset(req->resp, H_Content_Length); - - if (req->res_mode & RES_GUNZIP) - http_Unset(req->resp, H_Content_Encoding); - - if (req->res_mode & RES_CHUNKED) - http_SetHeader(req->resp, "Transfer-Encoding: chunked"); + VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); http_SetHeader(req->resp, req->doclose ? "Connection: close" : "Connection: keep-alive"); diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 587bf38..4df8ccd 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -25,8 +25,9 @@ varnish v1 \ sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage_hint = "invalid"; - # Unset Date header to not change the object sizes + # Unset Date and CL header to not change the object sizes unset beresp.http.Date; + unset beresp.http.Content-Length; } } -start diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 77425cb..4d715fa 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -17,8 +17,9 @@ varnish v1 \ sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage_hint = "s0"; - # Unset Date header to not change the object sizes + # Unset Date and CL header to not change the object sizes unset beresp.http.Date; + unset beresp.http.Content-Length; } } -start diff --git a/bin/varnishtest/tests/r00801.vtc b/bin/varnishtest/tests/r00801.vtc index f538d7f..ca1a567 100644 --- a/bin/varnishtest/tests/r00801.vtc +++ b/bin/varnishtest/tests/r00801.vtc @@ -13,6 +13,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } sub vcl_backend_response { set beresp.do_stream = false; + unset beresp.http.content-length; } } -start diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 11e2a72..dc4728d 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -24,6 +24,7 @@ varnish v1 -arg "-p nuke_limit=0 -p shortlived=0" \ set beresp.do_stream = false; # Unset Date header to not change the object sizes unset beresp.http.Date; + unset beresp.http.Content-Length; } } -start diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index dc6336f..194de2d 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -16,8 +16,9 @@ varnish v1 \ sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage_hint = "Transient"; - # Unset Date header to not change the object sizes + # Unset Date and CL header to not change the object sizes unset beresp.http.Date; + unset beresp.http.Content-Length; } } -start diff --git a/bin/varnishtest/tests/r01506.vtc b/bin/varnishtest/tests/r01506.vtc new file mode 100644 index 0000000..fc5b841 --- /dev/null +++ b/bin/varnishtest/tests/r01506.vtc @@ -0,0 +1,41 @@ +varnishtest "Streaming of C-L header from backend" + +server s1 { + rxreq + txresp -nolen -hdr "Content-Length: 020" + send "0123456789" + sema r1 sync 2 + send "0123456789" + + rxreq + txresp -nolen -hdr "Content-Length: 010" + sema r2 sync 2 + send "0123456789" +} -start + +varnish v1 -vcl+backend { + + sub vcl_backend_response { + if (bereq.url == "/2") { + set beresp.do_gzip = true; + } + } +} -start -cliok "param.set debug +syncvsl" -cliok "param.set debug +flush_head" + +client c1 { + txreq + rxresphdrs + expect resp.http.content-length == "020" + sema r1 sync 2 + rxrespbody + expect resp.body == "01234567890123456789" + delay .1 + + txreq -url "/2" + rxresphdrs + expect resp.http.content-length == "" + sema r2 sync 2 + rxrespbody + expect resp.body == "0123456789" + delay .1 +} -run diff --git a/include/tbl/http_headers.h b/include/tbl/http_headers.h index 26443ca..0a5395f 100644 --- a/include/tbl/http_headers.h +++ b/include/tbl/http_headers.h @@ -57,7 +57,7 @@ HTTPH("Cache-Control", H_Cache_Control, HTTPH_R_FETCH ) /* RFC2616 1 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 | HTTPH_A_INS) /* RFC2616 14.13 */ +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 */ From lkarsten at varnish-software.com Fri Nov 7 13:30:38 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 07 Nov 2014 14:30:38 +0100 Subject: [master] 1767f1b Consistent use of name, mention parameter. Message-ID: commit 1767f1bb2cc6460443365d719e6f54f282bbeaeb 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 fgsch at lodoss.net Sat Nov 8 01:50:29 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 08 Nov 2014 02:50:29 +0100 Subject: [master] 61cdf24 Install _all_ headers under ${prefix}/include/.. Message-ID: commit 61cdf24bb88a18d175c8b6e1c4dc26593728fa27 Author: Federico G. Schwindt Date: Sat Nov 8 01:47:26 2014 +0000 Install _all_ headers under ${prefix}/include/.. Fixes #1616 diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index a71e2a6..3d614c8 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -92,11 +92,9 @@ varnishd_SOURCES = \ waiter/cache_waiter_ports.c noinst_HEADERS = \ - cache/cache_backend.h \ - cache/cache_director.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 \ @@ -106,8 +104,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_filter.h \ cache/cache_backend.h \ diff --git a/include/Makefile.am b/include/Makefile.am index 09c237d..28ce8a9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -38,6 +38,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 16e27c5..75ca878 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 2 (varnish-4.0) -# Copyright (c) 2013 Varnish Software AS +# Copyright (c) 2013-2014 Varnish Software AS # All rights reserved. # # Author: Tollef Fog Heen @@ -53,10 +53,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 fgsch at lodoss.net Sun Nov 9 18:54:27 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 09 Nov 2014 19:54:27 +0100 Subject: [master] b953606 Spelling Message-ID: commit b953606d1fd13ea3c233bd9a992c54112e25a1e6 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 3bcb880..25e8427 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 fgsch at lodoss.net Sun Nov 9 18:54:27 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 09 Nov 2014 19:54:27 +0100 Subject: [master] cd23a78 Move test to (d)irectors Message-ID: commit cd23a7867087e3c844939adfd2d707216218e7a0 Author: Federico G. Schwindt Date: Sun Nov 9 18:50:07 2014 +0000 Move test to (d)irectors I'm not sure how valuable this test is but put it in the right place until it's decided. diff --git a/bin/varnishtest/tests/d00006.vtc b/bin/varnishtest/tests/d00006.vtc new file mode 100644 index 0000000..9d8ba1d --- /dev/null +++ b/bin/varnishtest/tests/d00006.vtc @@ -0,0 +1,82 @@ +varnishtest "Test vmod.directors round robin director in stacked fashion" + + +server s1 { + rxreq + txresp -body "1" +} -start + +server s2 { + rxreq + txresp -body "22" +} -start + + +server s3 { + rxreq + txresp -body "333" +} -start + +server s4 { + rxreq + txresp -body "4444" +} -start + +varnish v1 -errvcl {Names of VCL objects cannot contain '-'} { + import ${vmod_directors}; + backend b1 { .host = "127.0.0.1"; .port = "8080";} + sub vcl_init { + new rr1-xx = directors.round_robin(); + } +} + +varnish v1 -vcl+backend { + + import ${vmod_directors}; + sub vcl_init { + new rr1 = directors.round_robin(); + rr1.add_backend(s1); + rr1.add_backend(s3); + + new rr2 = directors.round_robin(); + rr2.add_backend(s2); + rr2.add_backend(s4); + + new rr3 = directors.round_robin(); + rr3.add_backend(rr1.backend()); + rr3.add_backend(rr2.backend()); + } + + sub vcl_backend_fetch { + set bereq.backend = rr3.backend(); + } +} -start + +client c1 { + timeout 3 + txreq -url "/foo1" + rxresp + expect resp.bodylen == 1 + txreq -url "/foo2" + rxresp + expect resp.bodylen == 2 + txreq -url "/foo3" + rxresp + expect resp.bodylen == 3 + txreq -url "/foo4" + rxresp + expect resp.bodylen == 4 +} -run + +server s1 -start +server s2 -start + +client c2 { + timeout 3 + txreq -url "/foo11" + rxresp + expect resp.bodylen == 1 + txreq -url "/foo22" + rxresp + expect resp.bodylen == 2 +} -run diff --git a/bin/varnishtest/tests/m00010.vtc b/bin/varnishtest/tests/m00010.vtc deleted file mode 100644 index 9d8ba1d..0000000 --- a/bin/varnishtest/tests/m00010.vtc +++ /dev/null @@ -1,82 +0,0 @@ -varnishtest "Test vmod.directors round robin director in stacked fashion" - - -server s1 { - rxreq - txresp -body "1" -} -start - -server s2 { - rxreq - txresp -body "22" -} -start - - -server s3 { - rxreq - txresp -body "333" -} -start - -server s4 { - rxreq - txresp -body "4444" -} -start - -varnish v1 -errvcl {Names of VCL objects cannot contain '-'} { - import ${vmod_directors}; - backend b1 { .host = "127.0.0.1"; .port = "8080";} - sub vcl_init { - new rr1-xx = directors.round_robin(); - } -} - -varnish v1 -vcl+backend { - - import ${vmod_directors}; - sub vcl_init { - new rr1 = directors.round_robin(); - rr1.add_backend(s1); - rr1.add_backend(s3); - - new rr2 = directors.round_robin(); - rr2.add_backend(s2); - rr2.add_backend(s4); - - new rr3 = directors.round_robin(); - rr3.add_backend(rr1.backend()); - rr3.add_backend(rr2.backend()); - } - - sub vcl_backend_fetch { - set bereq.backend = rr3.backend(); - } -} -start - -client c1 { - timeout 3 - txreq -url "/foo1" - rxresp - expect resp.bodylen == 1 - txreq -url "/foo2" - rxresp - expect resp.bodylen == 2 - txreq -url "/foo3" - rxresp - expect resp.bodylen == 3 - txreq -url "/foo4" - rxresp - expect resp.bodylen == 4 -} -run - -server s1 -start -server s2 -start - -client c2 { - timeout 3 - txreq -url "/foo11" - rxresp - expect resp.bodylen == 1 - txreq -url "/foo22" - rxresp - expect resp.bodylen == 2 -} -run From fgsch at lodoss.net Sun Nov 9 21:51:03 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 09 Nov 2014 22:51:03 +0100 Subject: [master] cef0767 Don't mention minimum values twice Message-ID: commit cef0767f4cfb8c332a37817e74f1a5b3771da4b1 Author: Federico G. Schwindt Date: Sun Nov 9 19:31:24 2014 +0000 Don't mention minimum values twice diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 96d61bd..7affacd 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -110,9 +110,7 @@ struct parspec WRK_parspec[] = { "\n" "Do not set this higher than you have to, since excess " "worker threads soak up RAM and CPU and generally just get " - "in the way of getting work done.\n" - "\n" - "Minimum is 10 threads.", + "in the way of getting work done.", DELAYED_EFFECT, "5000", "threads" }, { "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min, @@ -131,9 +129,7 @@ struct parspec WRK_parspec[] = { "Thread idle threshold.\n" "\n" "Threads in excess of thread_pool_min, which have been idle " - "for at least this long, will be destroyed.\n" - "\n" - "Minimum is 10 seconds.", + "for at least this long, will be destroyed.", EXPERIMENTAL | DELAYED_EFFECT, "300", "seconds" }, { "thread_pool_destroy_delay", @@ -141,9 +137,7 @@ struct parspec WRK_parspec[] = { "0.01", NULL, "Wait this long after destroying a thread.\n" "\n" - "This controls the decay of thread pools when idle(-ish).\n" - "\n" - "Minimum is 0.01 seconds.", + "This controls the decay of thread pools when idle(-ish).", EXPERIMENTAL | DELAYED_EFFECT, "1", "seconds" }, { "thread_pool_add_delay", From phk at FreeBSD.org Mon Nov 10 09:27:56 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Nov 2014 10:27:56 +0100 Subject: [master] 980243c Don't panic on incomplete VDP::gunzip, the backend may have abandonned us. Message-ID: commit 980243cbc53faa5f28fda402dee09bcec47c2bcf Author: Poul-Henning Kamp Date: Mon Nov 10 09:27:18 2014 +0000 Don't panic on incomplete VDP::gunzip, the backend may have abandonned us. Fixes #1624 diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1afd3cb..1762815 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -310,8 +310,8 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, AN(vg->m_buf); if (act == VDP_FINI) { + /* NB: Gunzip'ing may or may not have completed successfully. */ AZ(len); - AZ(vg->m_len); (void)VGZ_Destroy(&vg); *priv = NULL; return (0); diff --git a/bin/varnishtest/tests/r01624.vtc b/bin/varnishtest/tests/r01624.vtc new file mode 100644 index 0000000..23fefc0 --- /dev/null +++ b/bin/varnishtest/tests/r01624.vtc @@ -0,0 +1,40 @@ +varnishtest "broken gunzip delivery" + +server s1 { + rxreq + txresp -nolen \ + -hdr "Content-Encoding: gzip" \ + -hdr "Transfer-Encoding: Chunked" + send "164\r\n" + sendhex "1f 8b 08 00 f3 7e 60 54 00 03 9d 94 d1 6e 82 30" + sendhex "14 86 ef fb 14 ff 23 70 0e 28 7a 69 b2 78 61 e2" + sendhex "76 c1 92 5d a3 69 e6 12 27 a6 b3 4b f6 f6 93 a3" + sendhex "24 a5 2d 16 e9 0d f0 51 4e db bf 1f 05 52 8d 33" + sendhex "2a 54 7b b3 a9 4f b6 36 7f ce ab b5 de 99 3e da" + sendhex "d6 66 7f e8 7d be 3a 9b af 63 8f a8 6d 23 d7 39" + sendhex "28 bf 56 07 97 dd 9b 1c 94 81 4a 70 11 21 39 09" + # Truncated + delay .2 + + accept + rxreq + txresp -bodylen 7 +} -start + +varnish v1 -vcl+backend {} -start + +client c1 { + txreq + non-fatal + timeout 3 + rxresp +} -run + +delay .2 + +client c1 { + # Test varnishd is still running + txreq -url /2 + rxresp + expect resp.bodylen == 7 +} -run From fgsch at lodoss.net Mon Nov 10 13:28:28 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 10 Nov 2014 14:28:28 +0100 Subject: [master] ceb74b6 Turn bereq.uncacheable read-only Message-ID: commit ceb74b60d50eda5d5390c45fb1bd7eade598aa9d 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. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 07f386b..fe4fea8 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -204,20 +204,6 @@ VRT_r_beresp_##field(VRT_CTX) \ /*--------------------------------------------------------------------*/ -void -VRT_l_bereq_uncacheable(VRT_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(VRT_CTX) { diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index 2ac4b9d..da4476f 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 4dd6288..74e4c86 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -360,17 +360,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 fgsch at lodoss.net Mon Nov 10 13:28:28 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 10 Nov 2014 14:28:28 +0100 Subject: [master] da4d717 Make obj.uncacheable available in vcl_deliver Message-ID: commit da4d717261d93a2e39ff2371302271b6defca608 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 da4476f..ffd622b 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 74e4c86..75b1f9b 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -605,9 +605,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 martin at varnish-software.com Mon Nov 10 14:27:29 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Nov 2014 15:27:29 +0100 Subject: [master] 14a926b Use n + hist_buckets as hit flag in varnishhist bucket history Message-ID: commit 14a926bd7b51b89da7a5bc4cfe9ffbeeeb443e40 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 arianna.aondio at varnish-software.com Mon Nov 10 15:39:04 2014 From: arianna.aondio at varnish-software.com (Arianna Aondio) Date: Mon, 10 Nov 2014 16:39:04 +0100 Subject: [master] b3f15ef New counters for VBE. Message-ID: commit b3f15efc5b161e2ee0bd47b860fad2b300e1fc29 Author: Arianna Aondio Date: Wed Nov 5 10:54:03 2014 +0100 New counters for VBE. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 8454f56..4dda66b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -151,6 +151,7 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) Lck_Lock(&bp->mtx); bp->refcount++; bp->n_conn++; /* It mostly works */ + bp->vsc->conn++; Lck_Unlock(&bp->mtx); s = -1; @@ -175,6 +176,7 @@ bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vbe_dir *vs) 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; @@ -359,6 +361,7 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo) return (-1); } + vc->backend->vsc->req++; if (bo->htc == NULL) bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc); AN(bo->htc); diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 5cf077e..bc80ae5 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -150,6 +150,7 @@ VBE_DropRefConn(struct backend *b, const struct acct_bereq *acct_bereq) Lck_Lock(&b->mtx); assert(b->n_conn > 0); b->n_conn--; + b->vsc->conn--; VBE_DropRefLocked(b, acct_bereq); } diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 64e63a3..0d646a2 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -214,6 +214,14 @@ VSC_F(pipe_in, uint64_t, 0, 'a', info, "Total number of bytes forwarded from backend in" " pipe sessions" ) +VSC_F(conn, uint64_t, 0, 'g', info, + "Concurrent connections to backend", + "" +) +VSC_F(req, uint64_t, 0, 'c', info, + "Backend requests sent", + "" +) #endif From arianna.aondio at varnish-software.com Mon Nov 10 15:39:04 2014 From: arianna.aondio at varnish-software.com (Arianna Aondio) Date: Mon, 10 Nov 2014 16:39:04 +0100 Subject: [master] 93a2f06 Merge branch 'VBE' Added two counters to VBE. conn: concurrent connections to backend. req: number requests sent to backend. Message-ID: commit 93a2f0643cd95f44ed9f902e6a721f655c91a511 Merge: 980243c b3f15ef Author: Arianna Aondio Date: Mon Nov 10 13:33:04 2014 +0100 Merge branch 'VBE' Added two counters to VBE. conn: concurrent connections to backend. req: number requests sent to backend. From arianna.aondio at varnish-software.com Mon Nov 10 15:39:04 2014 From: arianna.aondio at varnish-software.com (Arianna Aondio) Date: Mon, 10 Nov 2014 16:39:04 +0100 Subject: [master] 5a1cdf9 Merge branch 'master' of git.varnish-cache.org:varnish-cache Message-ID: commit 5a1cdf9949eef1095bb34dc56572658649dc8e0b Merge: 93a2f06 14a926b Author: Arianna Aondio Date: Mon Nov 10 16:38:53 2014 +0100 Merge branch 'master' of git.varnish-cache.org:varnish-cache From martin at varnish-software.com Mon Nov 10 15:51:08 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Nov 2014 16:51:08 +0100 Subject: [4.0] 887c70e Delay HSH_Complete() until the storage sanity functions has finished. Message-ID: commit 887c70e64516136121d9a7492aab85c18054fd55 Author: Martin Blix Grydeland Date: Mon Nov 10 16:49:45 2014 +0100 Delay HSH_Complete() until the storage sanity functions has finished. This fixes a race where the client started freeing the body (which it does in the case of new hit-for-pass object being inserted) before the sanity functions were run. Fixes: #1596 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a07d6e6..d24bfff 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -829,7 +829,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) if (bo->state == BOS_FINISHED) { AZ(bo->fetch_objcore->flags & OC_F_FAILED); - HSH_Complete(bo->fetch_objcore); VSLb(bo->vsl, SLT_Length, "%zd", bo->fetch_obj->len); { /* Sanity check fetch methods accounting */ @@ -846,6 +845,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) else assert(uu == bo->fetch_obj->len); } + HSH_Complete(bo->fetch_objcore); } AZ(bo->fetch_objcore->busyobj); From phk at FreeBSD.org Tue Nov 11 09:50:07 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Nov 2014 10:50:07 +0100 Subject: [master] 2f407d8 Constify most stevedore pointers. Message-ID: commit 2f407d890766870218508e535d12a5b5f3bc6c02 Author: Poul-Henning Kamp Date: Tue Nov 11 09:49:31 2014 +0000 Constify most stevedore pointers. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fb17acc..9edd6f8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -382,7 +382,7 @@ struct lru { struct storeobj { unsigned magic; #define STOREOBJ_MAGIC 0x6faed850 - struct stevedore *stevedore; + const struct stevedore *stevedore; void *priv; uintptr_t priv2; }; @@ -1092,7 +1092,7 @@ void RFC2616_Vary_AE(struct http *hp); /* stevedore.c */ int STV_NewObject(struct objcore *, struct worker *, const char *hint, unsigned len); -struct storage *STV_alloc(struct stevedore *, size_t size); +struct storage *STV_alloc(const struct stevedore *, size_t size); void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); void STV_open(void); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 73eff9c..217f0df 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -214,7 +214,7 @@ ObjIterEnd(struct objcore *oc, void **oix) */ static struct storage * -objallocwithnuke(struct stevedore *stv, struct worker *wrk, size_t size) +objallocwithnuke(const struct stevedore *stv, struct worker *wrk, size_t size) { struct storage *st = NULL; unsigned fail; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 30d8422..57e9102 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -154,7 +154,7 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) /*-------------------------------------------------------------------*/ struct storage * -STV_alloc(struct stevedore *stv, size_t size) +STV_alloc(const struct stevedore *stv, size_t size) { struct storage *st; @@ -190,7 +190,7 @@ STV_alloc(struct stevedore *stv, size_t size) */ struct object * -STV_MkObject(struct stevedore *stv, struct objcore *oc, void *ptr) +STV_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) { struct object *o; @@ -218,7 +218,8 @@ STV_MkObject(struct stevedore *stv, struct objcore *oc, void *ptr) */ int -stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot) +stv_default_allocobj(const struct stevedore *stv, struct objcore *oc, + unsigned ltot) { struct object *o; struct storage *st; diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 311f6a6..befd942 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -48,7 +48,7 @@ struct storage { VTAILQ_ENTRY(storage) list; - struct stevedore *stevedore; + const struct stevedore *stevedore; void *priv; unsigned char *ptr; @@ -132,10 +132,10 @@ struct storeobj_methods { typedef void storage_init_f(struct stevedore *, int ac, char * const *av); typedef void storage_open_f(const struct stevedore *); -typedef struct storage *storage_alloc_f(struct stevedore *, size_t size); +typedef struct storage *storage_alloc_f(const struct stevedore *, size_t size); typedef void storage_trim_f(struct storage *, size_t size, int move_ok); typedef void storage_free_f(struct storage *); -typedef int storage_allocobj_f(struct stevedore *, struct objcore *, +typedef int storage_allocobj_f(const struct stevedore *, struct objcore *, unsigned ltot); typedef void storage_close_f(const struct stevedore *); typedef void storage_signal_close_f(const struct stevedore *); @@ -196,7 +196,8 @@ extern struct stevedore *stv_transient; int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx); uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx); -struct object *STV_MkObject(struct stevedore *, struct objcore *, void *ptr); +struct object *STV_MkObject(const struct stevedore *, struct objcore *, + void *ptr); struct lru *LRU_Alloc(void); void LRU_Free(struct lru *lru); diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 5c94e28..0402df5 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -438,7 +438,7 @@ smf_open(const struct stevedore *st) /*--------------------------------------------------------------------*/ static struct storage * -smf_alloc(struct stevedore *st, size_t size) +smf_alloc(const struct stevedore *st, size_t size) { struct smf *smf; struct smf_sc *sc; diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 9549281..77dbca4 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -57,7 +57,7 @@ struct sma { }; static struct storage * -sma_alloc(struct stevedore *st, size_t size) +sma_alloc(const struct stevedore *st, size_t size) { struct sma_sc *sma_sc; struct sma *sma = NULL; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 2565052..25a5109 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -423,7 +423,7 @@ smp_close(const struct stevedore *st) */ static struct storage * -smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, +smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size, struct smp_object **so, unsigned *idx, struct smp_seg **ssg) { struct smp_sc *sc; @@ -504,7 +504,7 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, */ static int -smp_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot) +smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot) { struct object *o; struct storage *st; @@ -557,7 +557,7 @@ smp_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot) */ static struct storage * -smp_alloc(struct stevedore *st, size_t size) +smp_alloc(const struct stevedore *st, size_t size) { return (smp_allocx(st, diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index 1e93598..eb194aa 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -51,7 +51,7 @@ struct smu { }; static struct storage * -smu_alloc(struct stevedore *st, size_t size) +smu_alloc(const struct stevedore *st, size_t size) { struct smu *smu; From phk at FreeBSD.org Tue Nov 11 10:10:55 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Nov 2014 11:10:55 +0100 Subject: [master] 9bdc3e0 Eliminate the per-struct-storage stevedore pointer Message-ID: commit 9bdc3e0bbc2adb53eca9f2c80236d978f8a6e12e Author: Poul-Henning Kamp Date: Tue Nov 11 10:10:40 2014 +0000 Eliminate the per-struct-storage stevedore pointer diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9edd6f8..d8007c8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1093,8 +1093,9 @@ void RFC2616_Vary_AE(struct http *hp); int STV_NewObject(struct objcore *, struct worker *, const char *hint, unsigned len); struct storage *STV_alloc(const struct stevedore *, size_t size); -void STV_trim(struct storage *st, size_t size, int move_ok); -void STV_free(struct storage *st); +void STV_trim(const struct stevedore *, struct storage *, size_t size, + int move_ok); +void STV_free(const struct stevedore *, struct storage *st); void STV_open(void); void STV_close(void); int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 217f0df..2e54300 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -377,9 +377,9 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc) return; if (st->len == 0) { VTAILQ_REMOVE(&o->list, st, list); - STV_free(st); + STV_free(stv, st); } else if (st->len < st->space) { - STV_trim(st, st->len, 1); + STV_trim(stv, st, st->len, 1); } } @@ -393,6 +393,7 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc) void ObjSlim(struct worker *wrk, struct objcore *oc) { + const struct stevedore *stv; struct object *o; struct storage *st, *stn; const struct storeobj_methods *om = obj_getmethods(oc); @@ -404,17 +405,19 @@ ObjSlim(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); o = obj_getobj(wrk, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->esidata != NULL) { - STV_free(o->esidata); + STV_free(stv, o->esidata); o->esidata = NULL; } VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); VTAILQ_REMOVE(&o->list, st, list); - STV_free(st); + STV_free(stv, st); } } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 57e9102..6a9fbb6 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -70,11 +70,11 @@ default_oc_freeobj(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); ObjSlim(wrk, oc); CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); - oc->stobj->priv = NULL; - oc->stobj->stevedore = NULL; o->magic = 0; - STV_free(o->objstore); + STV_free(oc->stobj->stevedore, o->objstore); + + memset(oc->stobj, 0, sizeof oc->stobj); wrk->stats->n_object--; } @@ -291,23 +291,23 @@ STV_NewObject(struct objcore *oc, struct worker *wrk, /*-------------------------------------------------------------------*/ void -STV_trim(struct storage *st, size_t size, int move_ok) +STV_trim(const struct stevedore *stv, struct storage *st, size_t size, + int move_ok) { + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - AN(st->stevedore); - if (st->stevedore->trim) - st->stevedore->trim(st, size, move_ok); -} + if (stv->trim) + stv->trim(st, size, move_ok); } void -STV_free(struct storage *st) +STV_free(const struct stevedore *stv, struct storage *st) { + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - AN(st->stevedore); - AN(st->stevedore->free); - st->stevedore->free(st); + AN(stv->free); + stv->free(st); } void diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index befd942..5c5bdfb 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -48,7 +48,6 @@ struct storage { VTAILQ_ENTRY(storage) list; - const struct stevedore *stevedore; void *priv; unsigned char *ptr; diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 0402df5..3886e9c 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -468,7 +468,6 @@ smf_alloc(const struct stevedore *st, size_t size) smf->s.priv = smf; smf->s.ptr = smf->ptr; smf->s.len = 0; - smf->s.stevedore = st; return (&smf->s); } diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 77dbca4..445afab 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -117,7 +117,6 @@ sma_alloc(const struct stevedore *st, size_t size) sma->s.priv = sma; sma->s.len = 0; sma->s.space = size; - sma->s.stevedore = st; sma->s.magic = STORAGE_MAGIC; return (&sma->s); } diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 25a5109..a4648fc 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -493,7 +493,6 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size, ss->ptr = PRNUP(sc, ss + 1); ss->space = max_size; ss->priv = sc; - ss->stevedore = st; if (ssg != NULL) *ssg = sg; return (ss); From phk at FreeBSD.org Tue Nov 11 10:18:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Nov 2014 11:18:42 +0100 Subject: [master] a5b3340 Use the direct stevedore pointer and drop the priv2 hack Message-ID: commit a5b3340de717acd09598fcddbd965c65ba2539a6 Author: Poul-Henning Kamp Date: Tue Nov 11 10:18:29 2014 +0000 Use the direct stevedore pointer and drop the priv2 hack diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 6a9fbb6..6762c34 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -82,9 +82,10 @@ default_oc_freeobj(struct worker *wrk, struct objcore *oc) static struct lru * __match_proto__(getlru_f) default_oc_getlru(const struct objcore *oc) { - struct stevedore *stv; + const struct stevedore *stv; - CAST_OBJ_NOTNULL(stv, (void *)oc->stobj->priv2, STEVEDORE_MAGIC); + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); return (stv->lru); } @@ -208,7 +209,6 @@ STV_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) oc->stobj->stevedore = stv; AN(stv->methods); oc->stobj->priv = o; - oc->stobj->priv2 = (uintptr_t)stv; return (o); } From phk at FreeBSD.org Tue Nov 11 10:38:02 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Nov 2014 11:38:02 +0100 Subject: [master] 5b2af36 Set a OA_flag to indicate ESI processing. Message-ID: commit 5b2af362207af5890789a2f4951f5dd1e832026a Author: Poul-Henning Kamp Date: Tue Nov 11 10:37:43 2014 +0000 Set a OA_flag to indicate ESI processing. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f9cf52c..cede109 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -590,6 +590,9 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(V1L_IsReleased(wrk)); + if (bo->do_esi) + ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_ESIPROC, 1); + if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_GZIPED, 1); @@ -604,10 +607,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc->body_status != BS_NONE) AZ(VDI_GetBody(bo->director_resp, bo->wrk, bo)); - /* - * Ready to fetch the body - */ - assert(bo->refcount >= 1); assert (bo->state == BOS_REQ_DONE); diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index b121793..d0f281e 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -46,6 +46,7 @@ OBJ_ATTR(LASTMODIFIED, lastmodified) OBJ_FLAG(GZIPED, gziped, (1<<1)) OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) OBJ_FLAG(IMSCAND, imscand, (1<<3)) +OBJ_FLAG(ESIPROC, esiproc, (1<<4)) #endif /*lint -restore */ From fgsch at lodoss.net Tue Nov 11 23:12:12 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 12 Nov 2014 00:12:12 +0100 Subject: [master] 2e9e32a Doc applies to both backend.list and backend.set_health Message-ID: commit 2e9e32ac88344c992305725ee7515a6ad8efbba8 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 fgsch at lodoss.net Tue Nov 11 23:15:02 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 12 Nov 2014 00:15:02 +0100 Subject: [master] 9062477 Update description Message-ID: commit 90624773a05236b3fdc55e32b36333fe44a98eb2 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 bc80ae5..1a35dd8 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -288,8 +288,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) { @@ -344,8 +344,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); @@ -355,7 +355,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 || @@ -366,9 +366,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); @@ -473,11 +471,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 fgsch at lodoss.net Tue Nov 11 23:35:31 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 12 Nov 2014 00:35:31 +0100 Subject: [master] 82b29b1 White space nit Message-ID: commit 82b29b11e14dd7c4df78029d1dee3e4cdb42c486 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 1a35dd8..db45f75 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -256,11 +256,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 fgsch at lodoss.net Wed Nov 12 17:04:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 12 Nov 2014 18:04:51 +0100 Subject: [master] 49fc365 Fix example Message-ID: commit 49fc3653b92fd9e0c83114df8c82977bee8a5990 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 phk at FreeBSD.org Thu Nov 13 09:49:00 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Nov 2014 10:49:00 +0100 Subject: [master] fac6316 We never start the main request FSM with an error code. Message-ID: commit fac6316cb1cc37b5a8c75f8a51186c2f392c5800 Author: Poul-Henning Kamp Date: Thu Nov 13 09:48:41 2014 +0000 We never start the main request FSM with an error code. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 6b7a9db..d328872 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -566,6 +566,7 @@ cnt_recv(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); + AZ(req->err_code); AZ(isnan(req->t_first)); AZ(isnan(req->t_prev)); @@ -591,11 +592,6 @@ cnt_recv(struct worker *wrk, struct req *req) } } - if (req->err_code) { - req->req_step = R_STP_SYNTH; - return (REQ_FSM_MORE); - } - req->doclose = http_DoConnection(req->http); /* By default we use the first backend */ From phk at FreeBSD.org Thu Nov 13 10:13:15 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Nov 2014 11:13:15 +0100 Subject: [master] a221996 Connection: is now firmly a HTTP1 thing. Message-ID: commit a2219961b7c137a1f3248a7195fe699f70eab9f8 Author: Poul-Henning Kamp Date: Thu Nov 13 10:12:52 2014 +0000 Connection: is now firmly a HTTP1 thing. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index d328872..040f50d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -592,8 +592,6 @@ cnt_recv(struct worker *wrk, struct req *req) } } - req->doclose = http_DoConnection(req->http); - /* By default we use the first backend */ AZ(req->director_hint); req->director_hint = req->vcl->director[0]; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 1737e65..a7ca699 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -303,6 +303,8 @@ 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); + assert(req->req_body_status != REQ_BODY_INIT); HTTP_Copy(req->http0, req->http); // For ESI & restart From phk at FreeBSD.org Fri Nov 14 12:44:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 14 Nov 2014 13:44:31 +0100 Subject: [master] b62cc4a Better coverage of VCL related cli Message-ID: commit b62cc4a14847bfe20bea48d12cb3c87c348f5fee Author: Poul-Henning Kamp Date: Fri Nov 14 07:49:49 2014 +0000 Better coverage of VCL related cli diff --git a/bin/varnishtest/tests/b00032.vtc b/bin/varnishtest/tests/b00032.vtc index ced05bb..2ed7183 100644 --- a/bin/varnishtest/tests/b00032.vtc +++ b/bin/varnishtest/tests/b00032.vtc @@ -7,6 +7,24 @@ server s1 { txresp } -start -varnish v1 -vcl+backend {} -start +varnish v1 -vcl+backend {} +varnish v1 -vcl+backend {} + +varnish v1 -cliok vcl.list + +varnish v1 -cliok start varnish v1 -cliok debug.sizeof + +varnish v1 -cliok "vcl.use vcl1" + +varnish v1 -clierr 106 "vcl.discard vcl1" + +varnish v1 -clierr 106 "vcl.discard vcl0" + +varnish v1 -clierr 106 {vcl.inline vcl2 "vcl 4.0; backend foo {.host = \"127.0.0.1\";} "} + +varnish v1 -clierr 106 {vcl.load vcl3 ./nonexistent.vcl} + +varnish v1 -cliok "vcl.discard vcl2" + From fgsch at lodoss.net Sat Nov 15 10:14:29 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 15 Nov 2014 11:14:29 +0100 Subject: [master] c614d62 Test case for #1627 Message-ID: commit c614d62e2c75429d48e4a404a67679f2a4d3d018 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 fgsch at lodoss.net Mon Nov 17 12:55:05 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Nov 2014 13:55:05 +0100 Subject: [master] e74fd16 Ensure bo is set should we panic in VBO_DerefBusyObj Message-ID: commit e74fd16c06894238992eb03be612d4c7bee2d026 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 cede109..3fae2bf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -973,6 +973,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 040f50d..1078d34 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -516,8 +516,8 @@ cnt_pipe(struct worker *wrk, struct req *req) V1P_Process(req, bo); http_Teardown(bo->bereq); - THR_SetBusyobj(NULL); VBO_DerefBusyObj(wrk, &bo); + THR_SetBusyobj(NULL); return (REQ_FSM_DONE); } From apj at mutt.dk Tue Nov 18 07:50:47 2014 From: apj at mutt.dk (Andreas Plesner) Date: Tue, 18 Nov 2014 08:50:47 +0100 Subject: [master] fccf956 Add info about X-F-F Message-ID: commit fccf95614e6e3bf2c16293fc0760b9c3b7bad8c3 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 martin at varnish-software.com Tue Nov 18 12:32:31 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 18 Nov 2014 13:32:31 +0100 Subject: [master] 7746e30 Keep the fetch thread busyobj pointer-ref separate from the client thread pointer-ref, and deref it on thread scheduling failure. Message-ID: commit 7746e30e2c53cf55f0f2525bb3f49c9ee83e9611 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 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 3fae2bf..08f253f 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -904,7 +904,7 @@ void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e mode) { - struct busyobj *bo; + struct busyobj *bo, *bo_fetch; const char *how; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -927,6 +927,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, THR_SetBusyobj(bo); + bo_fetch = bo; bo->refcount = 2; oc->busyobj = bo; @@ -953,7 +954,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)) { @@ -961,17 +962,21 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, (void)vbf_stp_fail(req->wrk, bo); if (bo->ims_oc != NULL) (void)HSH_DerefObjCore(wrk, &bo->ims_oc); - 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 Tue Nov 25 10:18:36 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 11:18:36 +0100 Subject: [master] 658d378 Prepatory work for optional arguments Message-ID: commit 658d37859386af32d045bc32338b0da47dc3a2a5 Author: Poul-Henning Kamp Date: Tue Nov 25 09:03:27 2014 +0000 Prepatory work for optional arguments diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index bff415a..3da3fd4 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -556,6 +556,7 @@ class Arg(object): self.nam = nam self.typ = typ self.det = det + self.val = None def __repr__(self): return "" % (self.nam, self.typ, str(self.det)) @@ -593,6 +594,44 @@ def parse_enum2(tl): s += "\\0" return Arg("ENUM", det=s) +def parse_arg(tl, al): + t = tl.get_token() + assert t != None + + if t.str == ")": + return t + + if t.str == "ENUM": + al.append(parse_enum2(tl)) + elif t.str in ctypes: + al.append(Arg(t.str)) + else: + raise Exception("ARG? %s", t.str) + + t = tl.get_token() + if t.str == "," or t.str == ")": + return t + + if not is_c_name(t.str): + raise ParseError( + 'Expected ")", "," or argument name, not "%s"' % t.str) + + al[-1].nam = t.str + t = tl.get_token() + + if t.str == "," or t.str == ")": + return t + + if t.str != "=": + raise ParseError( + 'Expected ")", "," or "=", not "%s"' % t.str) + + t = tl.get_token() + al[-1].val = t.str + + t = tl.get_token() + return t + ####################################################################### # # @@ -630,33 +669,13 @@ def parse_func(tl, rt_type=None, pobj=None): if t.str != "(": raise ParseError("Expected \"(\" got \"%s\"", t.str) - t = None while True: - if t == None: - t = tl.get_token() - assert t != None - - if t.str == "ENUM": - al.append(parse_enum2(tl)) - elif t.str in ctypes: - al.append(Arg(t.str)) - elif t.str == ")": - break - else: - raise Exception("ARG? %s", t.str) - t = tl.get_token() - if is_c_name(t.str): - al[-1].nam = t.str - t = tl.get_token() - if t.str == ",": - t = None - elif t.str == ")": + t = parse_arg(tl, al) + if t.str == ")": break - else: - raise ParseError( - "Expected \")\" or \",\" not \"%s\"" % t.str) - if t.str != ")": - raise ParseError("End Of Input looking for ')'") + if t.str != ",": + raise ParseError("End Of Input looking for ')' or ','") + f = Func(fname, rt_type, al) return f From phk at FreeBSD.org Tue Nov 25 10:18:36 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 11:18:36 +0100 Subject: [master] 50de179 Encode and ignore vmod argument names and default values Message-ID: commit 50de1790fd64814ef747d1efdc61f444fab811cb Author: Poul-Henning Kamp Date: Tue Nov 25 10:16:55 2014 +0000 Encode and ignore vmod argument names and default values diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 32e544c..2eb9e73 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -532,15 +532,50 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, const struct symbol *sym) /*-------------------------------------------------------------------- */ +static struct expr * +vcc_priv_arg(struct vcc *tl, const char *p, const char *name) +{ + const char *r; + struct expr *e2; + char buf[32]; + struct inifin *ifp; + + if (!strcmp(p, "PRIV_VCL")) { + r = strchr(name, '.'); + AN(r); + e2 = vcc_mk_expr(VOID, "&vmod_priv_%.*s", + (int) (r - name), name); + } else if (!strcmp(p, "PRIV_CALL")) { + bprintf(buf, "vmod_priv_%u", tl->unique++); + ifp = New_IniFin(tl); + Fh(tl, 0, "static struct vmod_priv %s;\n", buf); + VSB_printf(ifp->fin, "\tVRT_priv_fini(&%s);", buf); + e2 = vcc_mk_expr(VOID, "&%s", buf); + } else if (!strcmp(p, "PRIV_REQ")) { + r = strchr(name, '.'); + AN(r); + e2 = vcc_mk_expr(VOID, + "VRT_priv_req(ctx, &VGC_vmod_%.*s)", + (int) (r - name), name); + } else if (!strcmp(p, "PRIV_SESS")) { + r = strchr(name, '.'); + AN(r); + e2 = vcc_mk_expr(VOID, + "VRT_priv_sess(ctx, &VGC_vmod_%.*s)", + (int) (r - name), name); + } else { + WRONG("Wrong PRIV_ type"); + } + return (e2); +} + static void vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, const char *extra, const char *name, const char *args) { const char *p, *r; struct expr *e1, *e2; - struct inifin *ifp; enum var_type fmt; - char buf[32]; AN(cfunc); AN(args); @@ -553,34 +588,14 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, while (*p != '\0') { e2 = NULL; fmt = vcc_arg_type(&p); - if (fmt == VOID && !strcmp(p, "PRIV_VCL")) { - r = strchr(name, '.'); - AN(r); - e2 = vcc_mk_expr(VOID, "&vmod_priv_%.*s", - (int) (r - name), name); - p += strlen(p) + 1; - } else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) { - bprintf(buf, "vmod_priv_%u", tl->unique++); - ifp = New_IniFin(tl); - Fh(tl, 0, "static struct vmod_priv %s;\n", buf); - VSB_printf(ifp->fin, "\tVRT_priv_fini(&%s);", buf); - e2 = vcc_mk_expr(VOID, "&%s", buf); - p += strlen(p) + 1; - } else if (fmt == VOID && !strcmp(p, "PRIV_REQ")) { - r = strchr(name, '.'); - AN(r); - e2 = vcc_mk_expr(VOID, - "VRT_priv_req(ctx, &VGC_vmod_%.*s)", - (int) (r - name), name); - p += strlen(p) + 1; - } else if (fmt == VOID && !strcmp(p, "PRIV_SESS")) { - r = strchr(name, '.'); - AN(r); - e2 = vcc_mk_expr(VOID, - "VRT_priv_sess(ctx, &VGC_vmod_%.*s)", - (int) (r - name), name); + if (!memcmp(p, "PRIV_", 5)) { + assert(fmt == VOID); + e2 = vcc_priv_arg(tl, p, name); + e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, e2); p += strlen(p) + 1; - } else if (fmt == ENUM) { + continue; + } + if (fmt == ENUM) { ExpectErr(tl, ID); ERRCHK(tl); r = p; @@ -604,8 +619,6 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, p += strlen(p) + 1; p++; SkipToken(tl, ID); - if (*p != '\0') /*lint !e448 */ - SkipToken(tl, ','); } else { vcc_expr0(tl, &e2, fmt); ERRCHK(tl); @@ -624,10 +637,20 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, "\v+\n\v1,\nvrt_magic_string_end\v-", e2, NULL); } - if (*p != '\0') - SkipToken(tl, ','); } e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, e2); + + /* XXX: ignore argument name and default value for now */ + if (*p == '\1') { + /* Argument name */ + p = strchr(p, '\0') + 1; + if (*p == '\2') { + /* Argument default value */ + p = strchr(p, '\0') + 1; + } + } + if (*p != '\0') /*lint !e448 */ + SkipToken(tl, ','); } SkipToken(tl, ')'); e1 = vcc_expr_edit(e1->fmt, "\v1\n)\v-", e1, NULL); diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 3da3fd4..2d335fc 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -103,6 +103,15 @@ def lwrap(s, w=72): l.append(p + s) return l +def quote(s): + t = "" + for i in s: + if i == '"': + t += '\\"' + else: + t += i + return t + ####################################################################### def is_c_name(s): @@ -563,10 +572,14 @@ class Arg(object): def c_strspec(self): if self.det == None: - return self.typ + "\\0" + s = self.typ + "\\0" else: - return self.det - return "??" + s = self.det + if self.nam != None: + s += '"\n\t\t "\\1' + self.nam + '\\0' + if self.val != None: + s += '"\n\t\t\t"\\2' + quote(self.val) + "\\0" + return s ####################################################################### # From phk at FreeBSD.org Tue Nov 25 13:50:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 14:50:43 +0100 Subject: [master] 1ba4d05 Build arglist from spec and walk it as separate steps. Message-ID: commit 1ba4d053d98956056eefa3cce29916f29bbf6823 Author: Poul-Henning Kamp Date: Tue Nov 25 12:15:59 2014 +0000 Build arglist from spec and walk it as separate steps. diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 2eb9e73..54c113a 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -569,13 +569,24 @@ vcc_priv_arg(struct vcc *tl, const char *p, const char *name) return (e2); } +struct func_arg { + enum var_type type; + const char *enum_bits; + const char *name; + const char *val; + struct expr *result; + VTAILQ_ENTRY(func_arg) list; +}; + static void vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, const char *extra, const char *name, const char *args) { const char *p, *r; struct expr *e1, *e2; - enum var_type fmt; + struct func_arg *fa, *fa2; + enum var_type rfmt; + VTAILQ_HEAD(,func_arg) head; AN(cfunc); AN(args); @@ -584,21 +595,43 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, p = args; if (extra == NULL) extra = ""; - e1 = vcc_mk_expr(vcc_arg_type(&p), "%s(ctx%s\v+", cfunc, extra); + rfmt = vcc_arg_type(&p); + VTAILQ_INIT(&head); while (*p != '\0') { - e2 = NULL; - fmt = vcc_arg_type(&p); - if (!memcmp(p, "PRIV_", 5)) { - assert(fmt == VOID); - e2 = vcc_priv_arg(tl, p, name); - e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, e2); + fa = calloc(sizeof *fa, 1); + AN(fa); + VTAILQ_INSERT_TAIL(&head, fa, list); + fa->type = vcc_arg_type(&p); + if (fa->type == VOID && !memcmp(p, "PRIV_", 5)) { + fa->result = vcc_priv_arg(tl, p, name); + fa->name = ""; p += strlen(p) + 1; continue; } - if (fmt == ENUM) { + if (fa->type == ENUM) { + fa->enum_bits = p; + while (*p != '\0') + p += strlen(p) + 1; + p += strlen(p) + 1; + } + if (*p == '\1') { + fa->name = p + 1; + p = strchr(p, '\0') + 1; + if (*p == '\2') { + fa->val = p + 1; + p = strchr(p, '\0') + 1; + } + } + } + + VTAILQ_FOREACH(fa, &head, list) { + if (fa->result != NULL) + continue; + e2 = NULL; + if (fa->type == ENUM) { ExpectErr(tl, ID); ERRCHK(tl); - r = p; + r = p = fa->enum_bits; do { if (vcc_IdIs(tl->t, p)) break; @@ -614,45 +647,39 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, vcc_ErrWhere(tl, tl->t); return; } - e2 = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); - while (*p != '\0') - p += strlen(p) + 1; - p++; + fa->result = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); SkipToken(tl, ID); } else { - vcc_expr0(tl, &e2, fmt); + vcc_expr0(tl, &e2, fa->type); ERRCHK(tl); - if (e2->fmt != fmt) { + if (e2->fmt != fa->type) { VSB_printf(tl->sb, "Wrong argument type."); VSB_printf(tl->sb, " Expected %s.", - vcc_Type(fmt)); + vcc_Type(fa->type)); VSB_printf(tl->sb, " Got %s.\n", vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, e2->t1, tl->t); return; } - assert(e2->fmt == fmt); + assert(e2->fmt == fa->type); if (e2->fmt == STRING_LIST) { e2 = vcc_expr_edit(STRING_LIST, "\v+\n\v1,\nvrt_magic_string_end\v-", e2, NULL); } + fa->result = e2; } - e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, e2); - - /* XXX: ignore argument name and default value for now */ - if (*p == '\1') { - /* Argument name */ - p = strchr(p, '\0') + 1; - if (*p == '\2') { - /* Argument default value */ - p = strchr(p, '\0') + 1; - } - } - if (*p != '\0') /*lint !e448 */ + if (VTAILQ_NEXT(fa, list) != NULL) SkipToken(tl, ','); } SkipToken(tl, ')'); + + e1 = vcc_mk_expr(rfmt, "%s(ctx%s\v+", cfunc, extra); + VTAILQ_FOREACH_SAFE(fa, &head, list, fa2) { + AN(fa->result); + e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, fa->result); + free(fa); + } e1 = vcc_expr_edit(e1->fmt, "\v1\n)\v-", e1, NULL); *e = e1; } From phk at FreeBSD.org Tue Nov 25 13:50:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 14:50:43 +0100 Subject: [master] 9bad265 Insert a space to break the \2 escape sequence Message-ID: commit 9bad265349757abdb0125a52fa8292a6afc4a13b Author: Poul-Henning Kamp Date: Tue Nov 25 12:50:17 2014 +0000 Insert a space to break the \2 escape sequence diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2d335fc..6f81206 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -578,7 +578,9 @@ class Arg(object): if self.nam != None: s += '"\n\t\t "\\1' + self.nam + '\\0' if self.val != None: - s += '"\n\t\t\t"\\2' + quote(self.val) + "\\0" + # The space before the value is important to + # terminate the \2 escape sequence + s += '"\n\t\t\t"\\2 ' + quote(self.val) + "\\0" return s ####################################################################### From phk at FreeBSD.org Tue Nov 25 13:50:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 14:50:43 +0100 Subject: [master] 955fe07 Implement sparse/named arguments to VMOD functions. Message-ID: commit 955fe0755b6626641ae4a45bf8ed5728eda8e851 Author: Poul-Henning Kamp Date: Tue Nov 25 13:49:32 2014 +0000 Implement sparse/named arguments to VMOD functions. For now it probably only works with things like STRING and REAL. diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc new file mode 100644 index 0000000..6dd8722 --- /dev/null +++ b/bin/varnishtest/tests/m00019.vtc @@ -0,0 +1,57 @@ +varnishtest "Test var args" + +server s1 { + rxreq + txresp -bodylen 6 +} -start + +varnish v1 -vcl+backend { + import ${vmod_debug}; + + sub vcl_deliver { + set resp.http.foo1 = debug.argtest("1", 2.0, "3"); + set resp.http.foo2 = debug.argtest("1", two = 2.0, three = "3"); + set resp.http.foo3 = debug.argtest("1", three = "3", two = 2.0); + set resp.http.foo4 = debug.argtest("1", 2.0, three = "3"); + set resp.http.foo5 = debug.argtest("1", 2.0); + set resp.http.foo6 = debug.argtest("1"); + } +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == "6" + expect resp.http.foo1 == "1 2 3" + expect resp.http.foo2 == "1 2 3" + expect resp.http.foo3 == "1 2 3" + expect resp.http.foo4 == "1 2 3" + expect resp.http.foo5 == "1 2 3" + expect resp.http.foo6 == "1 2 3" +} -run + +delay .1 + +varnish v1 -errvcl {Argument 'one' already used} { + import ${vmod_debug}; + backend b1 {.host = "127.0.0.1";} + sub vcl_deliver { + set resp.http.foo5 = debug.argtest("1", one = "1"); + } +} + +varnish v1 -errvcl {Argument 'one' missing} { + import ${vmod_debug}; + backend b1 {.host = "127.0.0.1";} + sub vcl_deliver { + set resp.http.foo5 = debug.argtest(two = 2.0, three = "3"); + } +} + +varnish v1 -errvcl {Unknown argument 'four'} { + import ${vmod_debug}; + backend b1 {.host = "127.0.0.1";} + sub vcl_deliver { + set resp.http.foo5 = debug.argtest("1", two = 2.0, four = "3"); + } +} diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 54c113a..4c0f5ac 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -579,14 +579,64 @@ struct func_arg { }; static void +vcc_do_arg(struct vcc *tl, struct func_arg *fa) +{ + const char *p, *r; + struct expr *e2; + + if (fa->type == ENUM) { + ExpectErr(tl, ID); + ERRCHK(tl); + r = p = fa->enum_bits; + do { + if (vcc_IdIs(tl->t, p)) + break; + p += strlen(p) + 1; + } while (*p != '\0'); + if (*p == '\0') { + VSB_printf(tl->sb, "Wrong enum value."); + VSB_printf(tl->sb, " Expected one of:\n"); + do { + VSB_printf(tl->sb, "\t%s\n", r); + r += strlen(r) + 1; + } while (*r != '\0'); + vcc_ErrWhere(tl, tl->t); + return; + } + fa->result = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); + SkipToken(tl, ID); + } else { + vcc_expr0(tl, &e2, fa->type); + ERRCHK(tl); + if (e2->fmt != fa->type) { + VSB_printf(tl->sb, "Wrong argument type."); + VSB_printf(tl->sb, " Expected %s.", + vcc_Type(fa->type)); + VSB_printf(tl->sb, " Got %s.\n", + vcc_Type(e2->fmt)); + vcc_ErrWhere2(tl, e2->t1, tl->t); + return; + } + assert(e2->fmt == fa->type); + if (e2->fmt == STRING_LIST) { + e2 = vcc_expr_edit(STRING_LIST, + "\v+\n\v1,\nvrt_magic_string_end\v-", + e2, NULL); + } + fa->result = e2; + } +} + +static void vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, const char *extra, const char *name, const char *args) { - const char *p, *r; - struct expr *e1, *e2; + const char *p; + struct expr *e1; struct func_arg *fa, *fa2; enum var_type rfmt; VTAILQ_HEAD(,func_arg) head; + struct token *t1; AN(cfunc); AN(args); @@ -625,63 +675,68 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, } VTAILQ_FOREACH(fa, &head, list) { + if (tl->t->tok == ')') + break; if (fa->result != NULL) continue; - e2 = NULL; - if (fa->type == ENUM) { - ExpectErr(tl, ID); - ERRCHK(tl); - r = p = fa->enum_bits; - do { - if (vcc_IdIs(tl->t, p)) - break; - p += strlen(p) + 1; - } while (*p != '\0'); - if (*p == '\0') { - VSB_printf(tl->sb, "Wrong enum value."); - VSB_printf(tl->sb, " Expected one of:\n"); - do { - VSB_printf(tl->sb, "\t%s\n", r); - r += strlen(r) + 1; - } while (*r != '\0'); - vcc_ErrWhere(tl, tl->t); - return; - } - fa->result = vcc_mk_expr(VOID, "\"%.*s\"", PF(tl->t)); - SkipToken(tl, ID); - } else { - vcc_expr0(tl, &e2, fa->type); - ERRCHK(tl); - if (e2->fmt != fa->type) { - VSB_printf(tl->sb, "Wrong argument type."); - VSB_printf(tl->sb, " Expected %s.", - vcc_Type(fa->type)); - VSB_printf(tl->sb, " Got %s.\n", - vcc_Type(e2->fmt)); - vcc_ErrWhere2(tl, e2->t1, tl->t); - return; - } - assert(e2->fmt == fa->type); - if (e2->fmt == STRING_LIST) { - e2 = vcc_expr_edit(STRING_LIST, - "\v+\n\v1,\nvrt_magic_string_end\v-", - e2, NULL); - } - fa->result = e2; + if (tl->t->tok == ID) { + t1 = VTAILQ_NEXT(tl->t, list); + if (t1->tok == '=') + break; } - if (VTAILQ_NEXT(fa, list) != NULL) - SkipToken(tl, ','); + vcc_do_arg(tl, fa); + ERRCHK(tl); + if (tl->t->tok == ')') + break; + SkipToken(tl, ','); + } + while (tl->t->tok == ID) { + VTAILQ_FOREACH(fa, &head, list) { + if (fa->name == NULL) + continue; + if (vcc_IdIs(tl->t, fa->name)) + break; + } + if (fa == NULL) { + VSB_printf(tl->sb, "Unknown argument '%.*s'\n", + PF(tl->t)); + vcc_ErrWhere(tl, tl->t); + return; + } + if (fa->result != NULL) { + VSB_printf(tl->sb, "Argument '%s' already used\n", + fa->name); + vcc_ErrWhere(tl, tl->t); + return; + } + vcc_NextToken(tl); + SkipToken(tl, '='); + vcc_do_arg(tl, fa); + ERRCHK(tl); + if (tl->t->tok == ')') + break; + SkipToken(tl, ','); } - SkipToken(tl, ')'); e1 = vcc_mk_expr(rfmt, "%s(ctx%s\v+", cfunc, extra); VTAILQ_FOREACH_SAFE(fa, &head, list, fa2) { - AN(fa->result); - e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", e1, fa->result); + if (fa->result == NULL && fa->val != NULL) + fa->result = vcc_mk_expr(fa->type, "%s", fa->val); + if (fa->result != NULL) + e1 = vcc_expr_edit(e1->fmt, "\v1,\n\v2", + e1, fa->result); + else { + VSB_printf(tl->sb, "Argument '%s' missing\n", + fa->name); + vcc_ErrWhere(tl, tl->t); + } free(fa); } e1 = vcc_expr_edit(e1->fmt, "\v1\n)\v-", e1, NULL); *e = e1; + + SkipToken(tl, ')'); + } /*-------------------------------------------------------------------- diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 468fc51..902f724 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -39,7 +39,7 @@ $Function VOID panic(STRING_LIST) Don't. -$Function STRING author(ENUM { phk, des, kristian, mithrandir } person) +$Function STRING author(ENUM { phk, des, kristian, mithrandir } person = "phk") Test function for ENUM arguments @@ -59,7 +59,7 @@ $Function STRING test_priv_sess(PRIV_SESS, STRING) Test function for SESS private pointers -$Function BLOB str2blob(STRING src) +$Function BLOB str2blob(STRING src = "foo") Turn a string into a blob @@ -89,7 +89,9 @@ $Method TIME .date() You never know when you need a date. -$Function VOID rot52(HTTP) +$Function VOID rot52(HTTP hdr) 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") diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 08b5aa8..fba8d52 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -171,3 +171,12 @@ vmod_rot52(VRT_CTX, VCL_HTTP hp) http_PrintfHeader(hp, "Encrypted: ROT52"); } + +VCL_STRING +vmod_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three) +{ + char buf[100]; + + bprintf(buf, "%s %g %s", one, two, three); + return WS_Copy(ctx->ws, buf, -1); +} From phk at FreeBSD.org Tue Nov 25 18:34:09 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Nov 2014 19:34:09 +0100 Subject: [master] 6bf2322 Cater to fgs' PEP8-OCD :-) Message-ID: commit 6bf232292ba63233bb10f68f9e12b002a1a7db91 Author: Poul-Henning Kamp Date: Tue Nov 25 18:33:45 2014 +0000 Cater to fgs' PEP8-OCD :-) diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc index 6dd8722..f7b2386 100644 --- a/bin/varnishtest/tests/m00019.vtc +++ b/bin/varnishtest/tests/m00019.vtc @@ -10,9 +10,9 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.foo1 = debug.argtest("1", 2.0, "3"); - set resp.http.foo2 = debug.argtest("1", two = 2.0, three = "3"); - set resp.http.foo3 = debug.argtest("1", three = "3", two = 2.0); - set resp.http.foo4 = debug.argtest("1", 2.0, three = "3"); + set resp.http.foo2 = debug.argtest("1", two=2.0, three="3"); + set resp.http.foo3 = debug.argtest("1", three="3", two=2.0); + set resp.http.foo4 = debug.argtest("1", 2.0, three="3"); set resp.http.foo5 = debug.argtest("1", 2.0); set resp.http.foo6 = debug.argtest("1"); } @@ -36,7 +36,7 @@ varnish v1 -errvcl {Argument 'one' already used} { import ${vmod_debug}; backend b1 {.host = "127.0.0.1";} sub vcl_deliver { - set resp.http.foo5 = debug.argtest("1", one = "1"); + set resp.http.foo5 = debug.argtest("1", one="1"); } } @@ -44,7 +44,7 @@ varnish v1 -errvcl {Argument 'one' missing} { import ${vmod_debug}; backend b1 {.host = "127.0.0.1";} sub vcl_deliver { - set resp.http.foo5 = debug.argtest(two = 2.0, three = "3"); + set resp.http.foo5 = debug.argtest(two=2.0, three="3"); } } @@ -52,6 +52,6 @@ varnish v1 -errvcl {Unknown argument 'four'} { import ${vmod_debug}; backend b1 {.host = "127.0.0.1";} sub vcl_deliver { - set resp.http.foo5 = debug.argtest("1", two = 2.0, four = "3"); + set resp.http.foo5 = debug.argtest("1", two=2.0, four="3"); } } From phk at FreeBSD.org Thu Nov 27 10:07:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 27 Nov 2014 11:07:31 +0100 Subject: [master] b7a9b03 White space fix Message-ID: commit b7a9b03532737cdf6baab9d26ad647d356377e2a Author: Poul-Henning Kamp Date: Thu Nov 27 09:57:32 2014 +0000 White space fix diff --git a/bin/varnishtest/tests/b00032.vtc b/bin/varnishtest/tests/b00032.vtc index 2ed7183..55ece76 100644 --- a/bin/varnishtest/tests/b00032.vtc +++ b/bin/varnishtest/tests/b00032.vtc @@ -7,8 +7,8 @@ server s1 { txresp } -start -varnish v1 -vcl+backend {} -varnish v1 -vcl+backend {} +varnish v1 -vcl+backend {} +varnish v1 -vcl+backend {} varnish v1 -cliok vcl.list From phk at FreeBSD.org Thu Nov 27 10:07:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 27 Nov 2014 11:07:31 +0100 Subject: [master] 6b4267b White space polish Message-ID: commit 6b4267b4bc216c4bc6625f6500b2223a7ea8017e Author: Poul-Henning Kamp Date: Thu Nov 27 10:07:07 2014 +0000 White space polish diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 1a57bf3..c4bb931 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -311,7 +311,7 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', info, VSC_F(n_object, uint64_t, 1, 'i', info, "object structs made", - "Number of object structs made" + "Number of object structs made" ) VSC_F(n_vampireobject, uint64_t, 1, 'i', diag, "unresurrected objects", @@ -319,15 +319,15 @@ VSC_F(n_vampireobject, uint64_t, 1, 'i', diag, ) VSC_F(n_objectcore, uint64_t, 1, 'i', info, "objectcore structs made", - "Number of objectcore structs made" + "Number of objectcore structs made" ) VSC_F(n_objecthead, uint64_t, 1, 'i', info, "objecthead structs made", - "Number of objecthead structs made" + "Number of objecthead structs made" ) VSC_F(n_waitinglist, uint64_t, 1, 'i', debug, "waitinglist structs made", - "Number of waitinglist structs made" + "Number of waitinglist structs made" ) VSC_F(n_backend, uint64_t, 0, 'i', info, @@ -347,7 +347,7 @@ VSC_F(n_lru_nuked, uint64_t, 0, 'i', info, ) VSC_F(n_lru_moved, uint64_t, 0, 'i', diag, "Number of LRU moved objects", - "Number of move operations done on the LRU list." + "Number of move operations done on the LRU list." ) VSC_F(losthdr, uint64_t, 0, 'a', info, diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 75b1f9b..cf6bd66 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -564,9 +564,9 @@ sp_variables = [ 'INT', ( 'hit', 'deliver',), ( ), """ - The count of cache-hits on this object. A value of 0 indicates a + The count of cache-hits on this object. A value of 0 indicates a cache miss. - """ + """ ), ('obj.http.', 'HEADER', diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 73835f9..5f21332 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -126,7 +126,7 @@ Description *fallback* will be returned. Example | if (std.integer(beresp.http.x-foo, 0) > 5) { - | ... + | ... | } $Function IP ip(STRING s, IP fallback) @@ -137,7 +137,7 @@ Description fails, *fallback* will be returned. Example | if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { - | ... + | ... | } $Function REAL real(STRING s, REAL fallback) @@ -224,7 +224,7 @@ Description Note that the comparison is case sensitive. Example | if (std.strstr(req.url, req.http.x-restrict)) { - | ... + | ... | } From daghf at varnish-software.com Thu Nov 27 16:00:38 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 27 Nov 2014 17:00:38 +0100 Subject: [master] 9fd7bb7 Drop PRIV_SESS, as agreed on VDD14Q4. Message-ID: commit 9fd7bb7482dbc6d7c6817bd78dd2bd79732f9123 Author: Dag Haavi Finstad Date: Tue Nov 25 14:10:37 2014 +0100 Drop PRIV_SESS, as agreed on VDD14Q4. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 7749216..724b1a0 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -300,7 +300,7 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now) now = VTIM_real(); AZ(isnan(sp->t_open)); - VRTPRIV_dynamic_kill(sp, 0); + assert(VTAILQ_EMPTY(&sp->privs)); VSL(SLT_SessClose, sp->vxid, "%s %.3f", sess_close_2str(sp->reason, 0), now - sp->t_open); VSL(SLT_End, sp->vxid, "%s", ""); diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 4998e74..482e34d 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -89,8 +89,6 @@ VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id) FREE_OBJ(vps); } } - if (id == 0) - assert(VTAILQ_EMPTY(&sp->privs)); } struct vmod_priv * @@ -99,12 +97,6 @@ VRT_priv_req(VRT_CTX, void *vmod_id) return (VRT_priv_dynamic(ctx, (uintptr_t)ctx->req, (uintptr_t)vmod_id)); } -struct vmod_priv * -VRT_priv_sess(VRT_CTX, void *vmod_id) -{ - return (VRT_priv_dynamic(ctx, (uintptr_t)NULL, (uintptr_t)vmod_id)); -} - /*-------------------------------------------------------------------- */ diff --git a/bin/varnishtest/tests/v00041.vtc b/bin/varnishtest/tests/v00041.vtc index af951f9..2be9f8a 100644 --- a/bin/varnishtest/tests/v00041.vtc +++ b/bin/varnishtest/tests/v00041.vtc @@ -1,4 +1,4 @@ -varnishtest "Test priv_sess and priv_req" +varnishtest "Test priv_req" server s1 { rxreq @@ -12,14 +12,11 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.http.x0 = debug.test_priv_req(req.url); - set req.http.y0 = debug.test_priv_sess(req.url); } sub vcl_deliver { set resp.http.x0 = req.http.x0; set resp.http.x1 = debug.test_priv_req(""); - set resp.http.y0 = req.http.y0; - set resp.http.y1 = debug.test_priv_sess(""); } } -start @@ -29,13 +26,9 @@ client c1 { rxresp expect resp.http.x0 == /foobar expect resp.http.x1 == /foobar - expect resp.http.y0 == /foobar - expect resp.http.y1 == /foobar txreq -url /snafu rxresp expect resp.http.x0 == /snafu expect resp.http.x1 == /snafu - expect resp.http.y0 == /foobar - expect resp.http.y1 == /foobar } -run diff --git a/include/vrt.h b/include/vrt.h index f9624a6..78cf479 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -246,7 +246,6 @@ struct vmod_priv { typedef int vmod_init_f(struct vmod_priv *, const struct VCL_conf *); void VRT_priv_fini(const struct vmod_priv *p); -struct vmod_priv *VRT_priv_sess(VRT_CTX, void *vmod_id); struct vmod_priv *VRT_priv_req(VRT_CTX, void *vmod_id); /* Stevedore related functions */ diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 2eb9e73..72d8386 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -557,12 +557,6 @@ vcc_priv_arg(struct vcc *tl, const char *p, const char *name) e2 = vcc_mk_expr(VOID, "VRT_priv_req(ctx, &VGC_vmod_%.*s)", (int) (r - name), name); - } else if (!strcmp(p, "PRIV_SESS")) { - r = strchr(name, '.'); - AN(r); - e2 = vcc_mk_expr(VOID, - "VRT_priv_sess(ctx, &VGC_vmod_%.*s)", - (int) (r - name), name); } else { WRONG("Wrong PRIV_ type"); } diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2d335fc..ef6ea2c 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -58,7 +58,6 @@ ctypes = { 'IP': "VCL_IP", 'PRIV_CALL': "struct vmod_priv *", 'PRIV_VCL': "struct vmod_priv *", - 'PRIV_SESS': "struct vmod_priv *", 'PRIV_REQ': "struct vmod_priv *", 'REAL': "VCL_REAL", 'STRING': "VCL_STRING", diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 468fc51..09e6c0b 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -55,10 +55,6 @@ $Function STRING test_priv_req(PRIV_REQ, STRING) Test function for REQ private pointers -$Function STRING test_priv_sess(PRIV_SESS, STRING) - -Test function for SESS private pointers - $Function BLOB str2blob(STRING src) Turn a string into a blob diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 08b5aa8..d8077ce 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -88,18 +88,6 @@ vmod_test_priv_call(VRT_CTX, struct vmod_priv *priv) } } -VCL_STRING __match_proto__(td_debug_test_priv_sess) -vmod_test_priv_sess(VRT_CTX, struct vmod_priv *priv, VCL_STRING s) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (priv->priv == NULL) { - priv->priv = strdup(s); - priv->free = free; - } - return (priv->priv); -} - VCL_STRING __match_proto__(td_debug_test_priv_req) vmod_test_priv_req(VRT_CTX, struct vmod_priv *priv, VCL_STRING s) { From daghf at varnish-software.com Thu Nov 27 16:00:39 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 27 Nov 2014 17:00:39 +0100 Subject: [master] e656835 Make the VRTPRIV_* interface slightly more generic to let us use it without needing a req/sess pointer. Message-ID: commit e6568354ace28d4e79fc8c0b47b3ce3c903f9f61 Author: Dag Haavi Finstad Date: Tue Nov 25 14:26:28 2014 +0100 Make the VRTPRIV_* interface slightly more generic to let us use it without needing a req/sess pointer. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d8007c8..d69b4bd 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -119,7 +119,7 @@ struct sess; struct sesspool; struct vbc; struct vrt_backend; -struct vrt_privs; +struct vrt_priv; struct vsb; struct waitinglist; struct worker; @@ -299,6 +299,14 @@ struct vxid_pool { /*--------------------------------------------------------------------*/ +struct vrt_privs { + unsigned magic; +#define VRT_PRIVS_MAGIC 0x03ba7501 + VTAILQ_HEAD(,vrt_priv) privs; +}; + +/*--------------------------------------------------------------------*/ + struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -663,7 +671,7 @@ struct sess { double t_open; /* fd accepted */ double t_idle; /* fd accepted or resp sent */ - VTAILQ_HEAD(,vrt_privs) privs; + struct vrt_privs privs[1]; #if defined(HAVE_EPOLL_CTL) struct epoll_event ev; @@ -1046,7 +1054,8 @@ const char *VCL_Method_Name(unsigned); */ const char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap); char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap); -void VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id); +void VRTPRIV_init(struct vrt_privs *privs); +void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id); void ESI_Deliver(struct req *); void ESI_DeliverChild(struct req *, struct busyobj *); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 724b1a0..60c893e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -91,7 +91,7 @@ ses_new(struct sesspool *pp) sp->t_open = NAN; sp->t_idle = NAN; - VTAILQ_INIT(&sp->privs); + VRTPRIV_init(sp->privs); Lck_New(&sp->mtx, lck_sess); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); return (sp); @@ -300,7 +300,7 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now) now = VTIM_real(); AZ(isnan(sp->t_open)); - assert(VTAILQ_EMPTY(&sp->privs)); + assert(VTAILQ_EMPTY(&sp->privs->privs)); VSL(SLT_SessClose, sp->vxid, "%s %.3f", sess_close_2str(sp->reason, 0), now - sp->t_open); VSL(SLT_End, sp->vxid, "%s", ""); diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 482e34d..1819364 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -40,10 +40,10 @@ #include "vcl.h" #include "vrt.h" -struct vrt_privs { +struct vrt_priv { unsigned magic; -#define VRT_PRIVS_MAGIC 0x24157a52 - VTAILQ_ENTRY(vrt_privs) list; +#define VRT_PRIV_MAGIC 0x24157a52 + VTAILQ_ENTRY(vrt_priv) list; struct vmod_priv priv[1]; const struct VCL_conf *vcl; uintptr_t id; @@ -53,40 +53,51 @@ struct vrt_privs { /*-------------------------------------------------------------------- */ +void +VRTPRIV_init(struct vrt_privs *privs) +{ + privs->magic = VRT_PRIVS_MAGIC; + VTAILQ_INIT(&privs->privs); +} + static struct vmod_priv * VRT_priv_dynamic(VRT_CTX, uintptr_t id, uintptr_t vmod_id) { - struct vrt_privs *vps; + struct vrt_priv *vp; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - VTAILQ_FOREACH(vps, &ctx->req->sp->privs, list) { - CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC); - if (vps->vcl == ctx->vcl && vps->id == id - && vps->vmod_id == vmod_id) - return (vps->priv); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->sp->privs, VRT_PRIVS_MAGIC); + + VTAILQ_FOREACH(vp, &ctx->req->sp->privs->privs, list) { + CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC); + if (vp->vcl == ctx->vcl && vp->id == id + && vp->vmod_id == vmod_id) + return (vp->priv); } - ALLOC_OBJ(vps, VRT_PRIVS_MAGIC); - AN(vps); - vps->vcl = ctx->vcl; - vps->id = id; - vps->vmod_id = vmod_id; - VTAILQ_INSERT_TAIL(&ctx->req->sp->privs, vps, list); - return (vps->priv); + ALLOC_OBJ(vp, VRT_PRIV_MAGIC); + AN(vp); + vp->vcl = ctx->vcl; + vp->id = id; + vp->vmod_id = vmod_id; + VTAILQ_INSERT_TAIL(&ctx->req->sp->privs->privs, vp, list); + return (vp->priv); } void -VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id) +VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id) { - struct vrt_privs *vps, *vps1; + struct vrt_priv *vp, *vp1; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(privs, VRT_PRIVS_MAGIC); - VTAILQ_FOREACH_SAFE(vps, &sp->privs, list, vps1) { - CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC); - if (id == vps->id) { - VTAILQ_REMOVE(&sp->privs, vps, list); - VRT_priv_fini(vps->priv); - FREE_OBJ(vps); + VTAILQ_FOREACH_SAFE(vp, &privs->privs, list, vp1) { + CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC); + if (id == vp->id) { + VTAILQ_REMOVE(&privs->privs, vp, list); + VRT_priv_fini(vp->priv); + FREE_OBJ(vp); } } } @@ -107,4 +118,3 @@ VRT_priv_fini(const struct vmod_priv *p) if (p->priv != (void*)0 && p->free != (void*)0) p->free(p->priv); } - diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index a7ca699..29bd789 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -166,7 +166,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->vcl = NULL; } - VRTPRIV_dynamic_kill(sp, (uintptr_t)req); + VRTPRIV_dynamic_kill(sp->privs, (uintptr_t)req); /* Charge and log byte counters */ AN(req->vsl->wid); CNT_AcctLogCharge(wrk->stats, req); From daghf at varnish-software.com Thu Nov 27 16:00:39 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 27 Nov 2014 17:00:39 +0100 Subject: [master] e842e5c Merge branch 'vmodpriv' Message-ID: commit e842e5c07a5bd1f109e52ea57abd858164273b00 Merge: 6b4267b e053076 Author: Dag Haavi Finstad Date: Thu Nov 27 16:58:01 2014 +0100 Merge branch 'vmodpriv' diff --cc lib/libvmod_debug/vmod.vcc index 902f724,1684230..b2b661f --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@@ -51,15 -51,11 +51,11 @@@ $Function VOID test_priv_vcl(PRIV_VCL Test function for VCL private pointers - $Function STRING test_priv_req(PRIV_REQ, STRING) + $Function STRING test_priv_task(PRIV_TASK, STRING) - Test function for REQ private pointers - - $Function STRING test_priv_sess(PRIV_SESS, STRING) - - Test function for SESS private pointers + Test function for TASK private pointers -$Function BLOB str2blob(STRING src) +$Function BLOB str2blob(STRING src = "foo") Turn a string into a blob From daghf at varnish-software.com Thu Nov 27 16:00:39 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 27 Nov 2014 17:00:39 +0100 Subject: [master] e053076 Reintroduce PRIV_REQ as PRIV_TASK. PRIV_TASK is available (as separate priv pointers) both in the client side and the backend side VCL functions. Message-ID: commit e05307691ecc34b786ac235c4e407597d94f4514 Author: Dag Haavi Finstad Date: Tue Nov 25 14:40:13 2014 +0100 Reintroduce PRIV_REQ as PRIV_TASK. PRIV_TASK is available (as separate priv pointers) both in the client side and the backend side VCL functions. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d69b4bd..5ad4519 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -525,6 +525,7 @@ struct busyobj { struct vsb *synth_body; uint8_t digest[DIGEST_LEN]; + struct vrt_privs privs[1]; }; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index ad31e11..16c67f2 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -154,6 +154,8 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) memcpy(bo->digest, req->digest, sizeof bo->digest); + VRTPRIV_init(bo->privs); + return (bo); } @@ -190,6 +192,9 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) AZ(bo->htc); + VRTPRIV_dynamic_kill(bo->privs, (uintptr_t)bo); + assert(VTAILQ_EMPTY(&bo->privs->privs)); + VSLb(bo->vsl, SLT_BereqAcct, "%ju %ju %ju %ju %ju %ju", (uintmax_t)bo->acct.bereq_hdrbytes, (uintmax_t)bo->acct.bereq_bodybytes, diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 3e6e9d3..39df537 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -147,6 +147,7 @@ ved_include(struct req *preq, const char *src, const char *host) (void)usleep(10000); } + VRTPRIV_dynamic_kill(req->sp->privs, (uintptr_t)req); CNT_AcctLogCharge(wrk->stats, req); VSL_End(req->vsl); diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 1819364..a0a5185 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -63,14 +63,20 @@ VRTPRIV_init(struct vrt_privs *privs) static struct vmod_priv * VRT_priv_dynamic(VRT_CTX, uintptr_t id, uintptr_t vmod_id) { + struct vrt_privs *vps; struct vrt_priv *vp; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->sp->privs, VRT_PRIVS_MAGIC); + if (ctx->req) { + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->sp, SESS_MAGIC); + CAST_OBJ_NOTNULL(vps, ctx->req->sp->privs, VRT_PRIVS_MAGIC); + } else { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CAST_OBJ_NOTNULL(vps, ctx->bo->privs, VRT_PRIVS_MAGIC); + } - VTAILQ_FOREACH(vp, &ctx->req->sp->privs->privs, list) { + VTAILQ_FOREACH(vp, &vps->privs, list) { CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC); if (vp->vcl == ctx->vcl && vp->id == id && vp->vmod_id == vmod_id) @@ -81,7 +87,7 @@ VRT_priv_dynamic(VRT_CTX, uintptr_t id, uintptr_t vmod_id) vp->vcl = ctx->vcl; vp->id = id; vp->vmod_id = vmod_id; - VTAILQ_INSERT_TAIL(&ctx->req->sp->privs->privs, vp, list); + VTAILQ_INSERT_TAIL(&vps->privs, vp, list); return (vp->priv); } @@ -103,9 +109,19 @@ VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id) } struct vmod_priv * -VRT_priv_req(VRT_CTX, void *vmod_id) +VRT_priv_task(VRT_CTX, void *vmod_id) { - return (VRT_priv_dynamic(ctx, (uintptr_t)ctx->req, (uintptr_t)vmod_id)); + uintptr_t id; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->req) { + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + id = (uintptr_t)ctx->req; + } else { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + id = (uintptr_t)ctx->bo; + } + return (VRT_priv_dynamic(ctx, id, (uintptr_t)vmod_id)); } /*-------------------------------------------------------------------- diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index bb57072..705e11c 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=9k" -vcl+backend { +varnish v1 -arg "-p workspace_backend=10k" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/v00041.vtc b/bin/varnishtest/tests/v00041.vtc index 2be9f8a..9604eb2 100644 --- a/bin/varnishtest/tests/v00041.vtc +++ b/bin/varnishtest/tests/v00041.vtc @@ -1,4 +1,4 @@ -varnishtest "Test priv_req" +varnishtest "Test priv_task" server s1 { rxreq @@ -9,14 +9,26 @@ server s1 { varnish v1 -vcl+backend { import ${vmod_debug}; + import ${vmod_std}; sub vcl_recv { - set req.http.x0 = debug.test_priv_req(req.url); + set req.http.x0 = debug.test_priv_task(req.url); } sub vcl_deliver { set resp.http.x0 = req.http.x0; - set resp.http.x1 = debug.test_priv_req(""); + set resp.http.x1 = debug.test_priv_task(""); + } + + sub vcl_backend_fetch { + std.log("foo"); + set bereq.http.bx0 = debug.test_priv_task(bereq.url); + std.log("bar"); + } + + sub vcl_backend_response { + set beresp.http.bx0 = bereq.http.bx0; + set beresp.http.bx1 = debug.test_priv_task(""); } } -start @@ -26,9 +38,13 @@ client c1 { rxresp expect resp.http.x0 == /foobar expect resp.http.x1 == /foobar + expect resp.http.bx0 == /foobar + expect resp.http.bx1 == /foobar txreq -url /snafu rxresp expect resp.http.x0 == /snafu expect resp.http.x1 == /snafu + expect resp.http.bx0 == /snafu + expect resp.http.bx1 == /snafu } -run diff --git a/bin/varnishtest/tests/v00042.vtc b/bin/varnishtest/tests/v00042.vtc new file mode 100644 index 0000000..1640f56 --- /dev/null +++ b/bin/varnishtest/tests/v00042.vtc @@ -0,0 +1,68 @@ +varnishtest "Make sure we also get separate PRIV_TASK contexts in ESI subrequests." + +server s1 { + rxreq + expect req.url == "/a" + expect req.http.x0 == "/a0" + expect req.http.x1 == "/a0" + txresp -body { + + + } + + rxreq + expect req.url == "/foo" + expect req.http.x0 == "/foo1" + expect req.http.x1 == "/foo1" + txresp -body { + + + } + + rxreq + expect req.url == "/bar" + expect req.http.x0 == "/bar2" + expect req.http.x1 == "/bar2" + txresp + + rxreq + expect req.url == "/b" + expect req.http.x0 == "/b0" + expect req.http.x1 == "/b0" + + txresp +} -start + +varnish v1 -vcl+backend { + import ${vmod_debug}; + + sub vcl_recv { + set req.http.x0 = debug.test_priv_task(req.url + req.esi_level); + } + + sub vcl_miss { + set req.http.x1 = debug.test_priv_task(""); + } + + sub vcl_backend_response { + set beresp.do_esi = true; + + } + + sub vcl_deliver { + set resp.http.x1 = debug.test_priv_task(""); + } +} -start + + +client c1 { + txreq -url /a + rxresp + expect resp.http.x1 == "/a0" + + txreq -url /b + rxresp + expect resp.http.x1 == "/b0" +} -run + +varnish v1 -expect s_req == 2 diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 5ad685f..70f287e 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -194,6 +194,9 @@ PRIV_VCL PRIV_CALL See below +PRIV_TASK + See below + VOID C-type: ``void`` @@ -231,8 +234,8 @@ It is often useful for library functions to maintain local state, this can be anything from a precompiled regexp to open file descriptors and vast data structures. -The VCL compiler supports two levels of private pointers, "per call" -and "per VCL" +The VCL compiler supports three levels of private pointers, "per +call", "per VCL" and "per task". "per call" private pointers are useful to cache/store state relative to the specific call or its arguments, for instance a compiled regular @@ -243,9 +246,16 @@ last output of some expensive lookup. applies to all calls in this VCL, for instance flags that determine if regular expressions are case-sensitive in this vmod or similar. +"per task" private pointers are useful for state that applies to calls +for either a specific request or a backend request. For instance this +can be the result of a parsed cookie specific to a client. Note that +"per task" contexts are separate for the client side and the backend +side, so use in ``vcl_backend_*`` will yield a different private pointer +from the one used on the client side. + The way it works in the vmod code, is that a ``struct vmod_priv *`` is -passed to the functions where argument type PRIV_VCL or PRIV_CALL -is specified. +passed to the functions where argument type PRIV_VCL, PRIV_CALL or +PRIV_TASK is specified. This structure contains two members:: diff --git a/include/vrt.h b/include/vrt.h index 78cf479..9331600 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -246,7 +246,7 @@ struct vmod_priv { typedef int vmod_init_f(struct vmod_priv *, const struct VCL_conf *); void VRT_priv_fini(const struct vmod_priv *p); -struct vmod_priv *VRT_priv_req(VRT_CTX, void *vmod_id); +struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id); /* Stevedore related functions */ int VRT_Stv(const char *nm); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 72d8386..91c6a06 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -551,11 +551,11 @@ vcc_priv_arg(struct vcc *tl, const char *p, const char *name) Fh(tl, 0, "static struct vmod_priv %s;\n", buf); VSB_printf(ifp->fin, "\tVRT_priv_fini(&%s);", buf); e2 = vcc_mk_expr(VOID, "&%s", buf); - } else if (!strcmp(p, "PRIV_REQ")) { + } else if (!strcmp(p, "PRIV_TASK")) { r = strchr(name, '.'); AN(r); e2 = vcc_mk_expr(VOID, - "VRT_priv_req(ctx, &VGC_vmod_%.*s)", + "VRT_priv_task(ctx, &VGC_vmod_%.*s)", (int) (r - name), name); } else { WRONG("Wrong PRIV_ type"); diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index ef6ea2c..1501e31 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -58,7 +58,7 @@ ctypes = { 'IP': "VCL_IP", 'PRIV_CALL': "struct vmod_priv *", 'PRIV_VCL': "struct vmod_priv *", - 'PRIV_REQ': "struct vmod_priv *", + 'PRIV_TASK': "struct vmod_priv *", 'REAL': "VCL_REAL", 'STRING': "VCL_STRING", 'STRING_LIST': "const char *, ...", diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 09e6c0b..1684230 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -51,9 +51,9 @@ $Function VOID test_priv_vcl(PRIV_VCL) Test function for VCL private pointers -$Function STRING test_priv_req(PRIV_REQ, STRING) +$Function STRING test_priv_task(PRIV_TASK, STRING) -Test function for REQ private pointers +Test function for TASK private pointers $Function BLOB str2blob(STRING src) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index d8077ce..1701444 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -88,8 +88,8 @@ vmod_test_priv_call(VRT_CTX, struct vmod_priv *priv) } } -VCL_STRING __match_proto__(td_debug_test_priv_req) -vmod_test_priv_req(VRT_CTX, struct vmod_priv *priv, VCL_STRING s) +VCL_STRING __match_proto__(td_debug_test_priv_task) +vmod_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); From fgsch at lodoss.net Thu Nov 27 16:38:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Nov 2014 17:38:51 +0100 Subject: [master] 5ff2645 Handle default values without spaces around the equal sign Message-ID: commit 5ff26458f0b9ef632032ac5c68f8419749606946 Author: Federico G. Schwindt Date: Thu Nov 27 16:33:57 2014 +0000 Handle default values without spaces around the equal sign diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 15f82aa..dbd5051 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -732,7 +732,7 @@ class FileSection(object): return l = re.sub("[ \t]*#.*$", "", l) l = re.sub("[ \t]*\n", "", l) - l = re.sub("([(){},])", r' \1 ', l) + l = re.sub("([(){},=])", r' \1 ', l) if l == "": return for j in l.split(): diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index b2b661f..a027779 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -39,7 +39,7 @@ $Function VOID panic(STRING_LIST) Don't. -$Function STRING author(ENUM { phk, des, kristian, mithrandir } person = "phk") +$Function STRING author(ENUM { phk, des, kristian, mithrandir } person="phk") Test function for ENUM arguments @@ -55,7 +55,7 @@ $Function STRING test_priv_task(PRIV_TASK, STRING) Test function for TASK private pointers -$Function BLOB str2blob(STRING src = "foo") +$Function BLOB str2blob(STRING src="foo") Turn a string into a blob @@ -90,4 +90,4 @@ $Function VOID rot52(HTTP hdr) 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 STRING argtest(STRING one, REAL two=2, STRING three="3") From lkarsten at varnish-software.com Thu Nov 27 16:56:49 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Nov 2014 17:56:49 +0100 Subject: [master] 618b4c0 Export the VRT runtime version. Message-ID: commit 618b4c02e8bb853cb10c54044fff14bb1bd6b6a4 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 fgsch at lodoss.net Thu Nov 27 16:59:29 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Nov 2014 17:59:29 +0100 Subject: [master] 5c80dc6 Rework example Message-ID: commit 5c80dc65291b1ca17d6955f3ae2e97c6fe7873c1 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 Nov 27 17:09:17 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Nov 2014 18:09:17 +0100 Subject: [master] b6b5546 Add ABI Provide-s. Message-ID: commit b6b554626dc830d83e1705638882fd549693fa5d Author: Lasse Karstensen Date: Thu Nov 27 18:07:36 2014 +0100 Add ABI Provide-s. diff --git a/control b/control index 81f4f78..ca29224 100644 --- a/control +++ b/control @@ -27,8 +27,10 @@ Standards-Version: 3.9.3 Package: varnish Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libc6-dev | libc6.1-dev | libc-dev, adduser, libvarnishapi1 (= ${binary:Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, gcc (>= 3.3), libc6-dev | libc6.1-dev | libc-dev, adduser, libvarnishapi1 (>= ${binary:Version}) Suggests: varnish-doc +Provides: ${Varnish:ABI} +Provides: ${Varnish:strictABI} Description: state of the art, high-performance web accelerator Varnish Cache is a state of the art web accelerator written with performance and flexibility in mind. diff --git a/rules b/rules index 5ff61d6..f3c65a4 100755 --- a/rules +++ b/rules @@ -18,6 +18,14 @@ ifneq ($(filter $(DEB_HOST_ARCH),$(DISABLE_JEMALLOC_ARCH_LIST)),) LOCAL_CONFIGURE_FLAGS += --disable-jemalloc endif +VMOD_strictABI = $(shell printf '\#include "vmod_abi.h"\nVMOD_ABI_Version\n' \ + | cpp - -Iinclude \ + | sed -e '/"Varnish/!d' -e 's/.*\ \(.*\)\"$/varnishabi-strict-\1/') + +VMOD_ABI = $(shell 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') + # Main build rule, leave everything to debhelper %: dh $@ --parallel @@ -64,10 +72,13 @@ override_dh_installdocs: fi override_dh_gencontrol: + echo "Varnish:strictABI=$(VMOD_strictABI)" >> debian/substvars + echo "Varnish:ABI=$(VMOD_ABI)" >> debian/substvars + if [ -n "$$DEBIAN_OVERRIDE_BINARY_VERSION" ]; then \ - dh_gencontrol -- -v$$DEBIAN_OVERRIDE_BINARY_VERSION; \ + dh_gencontrol -- -Tdebian/substvars -v$$DEBIAN_OVERRIDE_BINARY_VERSION; \ else \ - dh_gencontrol ; \ + dh_gencontrol -- -Tdebian/substvars; \ fi # Override to add several init scripts From lkarsten at varnish-software.com Thu Nov 27 18:02:39 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Nov 2014 19:02:39 +0100 Subject: [master] fc4c27f Replace method for extracting gitref. Message-ID: commit fc4c27f04f98508497ab80092bb4b21772604086 Author: Lasse Karstensen Date: Thu Nov 27 19:01:53 2014 +0100 Replace method for extracting gitref. That sed line got unruly real quick when trying to escape it correctly. diff --git a/rules b/rules index f3c65a4..20e921b 100755 --- a/rules +++ b/rules @@ -18,9 +18,8 @@ ifneq ($(filter $(DEB_HOST_ARCH),$(DISABLE_JEMALLOC_ARCH_LIST)),) LOCAL_CONFIGURE_FLAGS += --disable-jemalloc endif -VMOD_strictABI = $(shell printf '\#include "vmod_abi.h"\nVMOD_ABI_Version\n' \ - | cpp - -Iinclude \ - | sed -e '/"Varnish/!d' -e 's/.*\ \(.*\)\"$/varnishabi-strict-\1/') +VMOD_strictABI = $(shell printf '\#include "vcs_version.h"\nVCS_Version\n' \ + | cpp - -Iinclude | sed -e '/^"/!d' -e 's/\"//g' -e 's/^/varnishabi-strict-/') VMOD_ABI = $(shell printf '\#include "vrt.h"\nvarnishabi- VRT_MAJOR_VERSION . VRT_MINOR_VERSION\n' \ | cpp - -Iinclude \ From lkarsten at varnish-software.com Thu Nov 27 18:04:55 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Nov 2014 19:04:55 +0100 Subject: [master] 8e06ac9 Extract gitref using same method as debs. Message-ID: commit 8e06ac9798f0432a7a5f3ab3448257f39a121628 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 fgsch at lodoss.net Fri Nov 28 00:07:21 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 28 Nov 2014 01:07:21 +0100 Subject: [master] d192350 Make vrt_selecthttp public Message-ID: commit d192350fdb7dcfa4f0fed24cb4af1ce89827df8e Author: Federico G. Schwindt Date: Thu Nov 27 18:42:39 2014 +0000 Make vrt_selecthttp public diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index a49da52..5fbf923 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -90,8 +90,8 @@ VRT_acl_log(VRT_CTX, const char *msg) /*--------------------------------------------------------------------*/ -static struct http * -vrt_selecthttp(VRT_CTX, enum gethdr_e where) +struct http * +VRT_selecthttp(VRT_CTX, enum gethdr_e where) { struct http *hp; @@ -110,7 +110,7 @@ vrt_selecthttp(VRT_CTX, enum gethdr_e where) hp = ctx->http_resp; break; default: - WRONG("vrt_selecthttp 'where' invalid"); + WRONG("VRT_selecthttp 'where' invalid"); } return (hp); } @@ -130,7 +130,7 @@ VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs) return(HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, hs->what)); } - hp = vrt_selecthttp(ctx, hs->where); + hp = VRT_selecthttp(ctx, hs->where); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (!http_GetHdr(hp, hs->what, &p)) return (NULL); @@ -228,7 +228,7 @@ VRT_SetHdr(VRT_CTX , const struct gethdr_s *hs, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(hs); AN(hs->what); - hp = vrt_selecthttp(ctx, hs->where); + hp = VRT_selecthttp(ctx, hs->where); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); va_start(ap, p); if (p == vrt_magic_string_unset) { diff --git a/include/vrt.h b/include/vrt.h index 9331600..2e720a2 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -208,6 +208,7 @@ int VRT_rewrite(const char *, const char *); void VRT_error(VRT_CTX, unsigned, const char *); int VRT_switch_config(const char *); +struct http *VRT_selecthttp(VRT_CTX, enum gethdr_e); const 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); diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 35c417b..42b356a 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -174,16 +174,11 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) VCL_VOID __match_proto__(td_std_collect) vmod_collect(VRT_CTX, VCL_HEADER hdr) { + struct http *hp; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (hdr->where == HDR_REQ) - http_CollectHdr(ctx->http_req, hdr->what); - else if (hdr->where == HDR_BEREQ) - http_CollectHdr(ctx->http_bereq, hdr->what); - else if (hdr->where == HDR_BERESP) - http_CollectHdr(ctx->http_beresp, hdr->what); - else if (hdr->where == HDR_RESP) - http_CollectHdr(ctx->http_resp, hdr->what); + hp = VRT_selecthttp(ctx, hdr->where); + http_CollectHdr(hp, hdr->what); } VCL_BOOL __match_proto__(td_std_healthy) From fgsch at lodoss.net Fri Nov 28 14:23:29 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 28 Nov 2014 15:23:29 +0100 Subject: [master] b406bd9 Reduce fetch_chunksize to 16k as agreed on VDD14Q4. Message-ID: commit b406bd9076745ee9ca050ff59bf588d1e2eb2667 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 25e8427..50ba8ea 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 fgsch at lodoss.net Sat Nov 29 21:48:10 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 29 Nov 2014 22:48:10 +0100 Subject: [master] 6d75bbc Sort options Message-ID: commit 6d75bbc22657766a0989a6912365d03c9e3db640 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 fgsch at lodoss.net Sat Nov 29 21:48:10 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 29 Nov 2014 22:48:10 +0100 Subject: [master] 22c8313 Update examples Message-ID: commit 22c8313979b9d1f13afabc74211101ee8253a9b4 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 ~~~~~~