From phk at varnish-cache.org Tue Apr 2 07:47:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 02 Apr 2013 09:47:58 +0200 Subject: [master] f5a4589 Jenkins indicates that we are not shaving close enough to the size of the transient storage in these test-cases, steal another 70 bytes. Message-ID: commit f5a45895177f8ecdd80ce3808b50b717b276400a Author: Poul-Henning Kamp Date: Tue Apr 2 07:47:29 2013 +0000 Jenkins indicates that we are not shaving close enough to the size of the transient storage in these test-cases, steal another 70 bytes. diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc index 9d5bd81..3b1bd83 100644 --- a/bin/varnishtest/tests/r01283.vtc +++ b/bin/varnishtest/tests/r01283.vtc @@ -2,7 +2,7 @@ varnishtest "#1283 - Test failure to allocate object for error (transient full)" server s1 { rxreq - txresp -bodylen 1048000 + txresp -bodylen 1048070 } -start varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend { diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 485a05d..c48ea44 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -3,7 +3,7 @@ varnishtest "#1284 - Test resource cleanup after STV_NewObject fail in fetch" server s1 { rxreq expect req.url == "/obj1" - txresp -bodylen 1048000 + txresp -bodylen 1048070 rxreq expect req.url == "/obj2" txresp -hdr "Long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -hdr "Long2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" From phk at varnish-cache.org Tue Apr 2 08:14:02 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 02 Apr 2013 10:14:02 +0200 Subject: [master] 2980d24 Fix a printf(3) type error Message-ID: commit 2980d2441a3aa6ea6ef225375e870fc6b015ef5f Author: Poul-Henning Kamp Date: Tue Apr 2 08:13:47 2013 +0000 Fix a printf(3) type error diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index fbb10ad..6c4780d 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -500,7 +500,7 @@ mgt_reap_child(void) r = waitpid(child_pid, &status, 0); } if (r != child_pid) - fprintf(stderr, "WAIT 0x%x\n", r); + fprintf(stderr, "WAIT 0x%jx\n", (uintmax_t)r); assert(r == child_pid); /* Compose obituary */ From tfheen at varnish-cache.org Tue Apr 2 11:44:32 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 02 Apr 2013 13:44:32 +0200 Subject: [3.0] c6b3fae Fix compilation error on Solaris Message-ID: commit c6b3fae69349063338772267cfd9f631c530b9fd Author: Geoff Simmons Date: Tue Apr 2 13:43:36 2013 +0200 Fix compilation error on Solaris Fixes #1167 diff --git a/bin/varnishd/cache_waiter_ports.c b/bin/varnishd/cache_waiter_ports.c index e26a80c..e599260 100644 --- a/bin/varnishd/cache_waiter_ports.c +++ b/bin/varnishd/cache_waiter_ports.c @@ -225,7 +225,7 @@ vca_main(void *arg) if (sp) { double tmo = - (sp->t_end + cache_param->timeout_idle) - now; + (sp->t_end + params->sess_timeout) - now; /* we should have removed all sps whose timeout has passed */ assert(tmo > 0.0); From tfheen at varnish-cache.org Tue Apr 2 12:25:56 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 02 Apr 2013 14:25:56 +0200 Subject: [3.0] 5e064a1 Increase the id field in VSM Message-ID: commit 5e064a1bafcb3b0bd4a2d7cdaeb479e36ff9c310 Author: Tollef Fog Heen Date: Tue Apr 2 14:19:42 2013 +0200 Increase the id field in VSM Increase the id field in VSM to 128 bytes to make space for 64 backend VCL name + IPv4, IPv6 and portnumber. This is the same as a9e5d35. Fixes: #1224 diff --git a/include/vsm.h b/include/vsm.h index 98e8610..bf3ece3 100644 --- a/include/vsm.h +++ b/include/vsm.h @@ -50,7 +50,7 @@ struct VSM_chunk { unsigned state; char class[8]; char type[8]; - char ident[64]; + char ident[128]; }; #define VSM_NEXT(sha) ((void*)((uintptr_t)(sha) + (sha)->len)) From phk at varnish-cache.org Wed Apr 3 09:15:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 11:15:58 +0200 Subject: [master] ffe4da2 After trying several different ways, rename vcl_hit{} to vcl_lookup{}, that seems to be the shortest path from A to B. Message-ID: commit ffe4da24efc15c9dae3888d912f2a263e0934086 Author: Poul-Henning Kamp Date: Wed Apr 3 09:14:53 2013 +0000 After trying several different ways, rename vcl_hit{} to vcl_lookup{}, that seems to be the shortest path from A to B. (Please don't update docs yet, this is just a transition state) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index fa9de50..03c8ce0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -744,7 +744,7 @@ cnt_hit(struct worker *wrk, struct req *req) assert(!(req->obj->objcore->flags & OC_F_PASS)); - VCL_hit_method(req); + VCL_lookup_method(req); if (req->handling == VCL_RET_DELIVER) { //AZ(req->busyobj->bereq->ws); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 2c61900..d6dfef0 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -530,7 +530,7 @@ VRT_purge(struct req *req, double ttl, double grace) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->cur_method == VCL_MET_HIT) + if (req->cur_method == VCL_MET_LOOKUP) HSH_Purge(req, req->obj->objcore->objhead, ttl, grace); else if (req->cur_method == VCL_MET_MISS) HSH_Purge(req, req->objcore->objhead, ttl, grace); diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index 986f276..a8432ab 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -93,7 +93,7 @@ sub vcl_hash { return (hash); } -sub vcl_hit { +sub vcl_lookup { return (deliver); } diff --git a/bin/varnishtest/tests/c00010.vtc b/bin/varnishtest/tests/c00010.vtc index 238dada..e9c78a9 100644 --- a/bin/varnishtest/tests/c00010.vtc +++ b/bin/varnishtest/tests/c00010.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { return(pass); } } -start diff --git a/bin/varnishtest/tests/c00033.vtc b/bin/varnishtest/tests/c00033.vtc index 28b192d..a7782a1 100644 --- a/bin/varnishtest/tests/c00033.vtc +++ b/bin/varnishtest/tests/c00033.vtc @@ -23,7 +23,7 @@ varnish v1 -vcl+backend { } } - sub vcl_hit { + sub vcl_lookup { if (req.method == "PURGE") { C{ VRT_purge(req, 0, 0); }C error 456 "got it"; diff --git a/bin/varnishtest/tests/c00041.vtc b/bin/varnishtest/tests/c00041.vtc index c51cf53..e9dd2cd 100644 --- a/bin/varnishtest/tests/c00041.vtc +++ b/bin/varnishtest/tests/c00041.vtc @@ -40,7 +40,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_miss { if (req.http.purge == "yes") { purge; } } - sub vcl_hit { if (req.http.purge == "yes") { purge; return(restart);} } + sub vcl_lookup { if (req.http.purge == "yes") { purge; return(restart);} } } -start client c1 { diff --git a/bin/varnishtest/tests/p00001.vtc b/bin/varnishtest/tests/p00001.vtc index ac95149..adfc1f0 100644 --- a/bin/varnishtest/tests/p00001.vtc +++ b/bin/varnishtest/tests/p00001.vtc @@ -24,7 +24,7 @@ client c1 { varnish v1 -stop varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { set obj.ttl = 1 s; } } diff --git a/bin/varnishtest/tests/r00310.vtc b/bin/varnishtest/tests/r00310.vtc index 6a5ce22..8097a6b 100644 --- a/bin/varnishtest/tests/r00310.vtc +++ b/bin/varnishtest/tests/r00310.vtc @@ -1,9 +1,9 @@ -varnishtest "Test obj.http.x-cache in vcl_hit" +varnishtest "Test obj.http.x-cache in vcl_lookup" -varnish v1 -errvcl {'obj.http.x-cache': cannot be set in method 'vcl_hit'.} { +varnish v1 -errvcl {'obj.http.x-cache': cannot be set in method 'vcl_lookup'.} { backend foo { .host = "localhost"; } - sub vcl_hit { + sub vcl_lookup { set obj.http.x-cache = "hit"; } } diff --git a/bin/varnishtest/tests/r00365.vtc b/bin/varnishtest/tests/r00365.vtc index dc1d590..a703a66 100644 --- a/bin/varnishtest/tests/r00365.vtc +++ b/bin/varnishtest/tests/r00365.vtc @@ -1,4 +1,4 @@ -varnishtest "Test restarts in vcl_hit" +varnishtest "Test restarts in vcl_lookup" server s1 { rxreq @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { set obj.ttl = 0s; return (restart); } diff --git a/bin/varnishtest/tests/r00411.vtc b/bin/varnishtest/tests/r00411.vtc index 67479d3..bab8eef 100644 --- a/bin/varnishtest/tests/r00411.vtc +++ b/bin/varnishtest/tests/r00411.vtc @@ -11,7 +11,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { if (obj.http.X-Magic-Redirect == "1") { set req.url = obj.http.Location; return (restart); diff --git a/bin/varnishtest/tests/r00412.vtc b/bin/varnishtest/tests/r00412.vtc index 2b0082a..2d3c69a 100644 --- a/bin/varnishtest/tests/r00412.vtc +++ b/bin/varnishtest/tests/r00412.vtc @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { return (restart); } } - sub vcl_hit { + sub vcl_lookup { if (obj.http.X-Magic-Redirect == "1") { set req.url = obj.http.Location; return (restart); diff --git a/bin/varnishtest/tests/r00444.vtc b/bin/varnishtest/tests/r00444.vtc index ad8e12a..85bdc15 100644 --- a/bin/varnishtest/tests/r00444.vtc +++ b/bin/varnishtest/tests/r00444.vtc @@ -25,7 +25,7 @@ varnish v1 -vcl+backend { return (lookup); } } - sub vcl_hit { + sub vcl_lookup { if (req.method == "POST") { /* Get rid of this object */ set obj.ttl = 0s; diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc index a41c25a..33e5198 100644 --- a/bin/varnishtest/tests/r00956.vtc +++ b/bin/varnishtest/tests/r00956.vtc @@ -11,7 +11,7 @@ varnish v1 -vcl+backend { set req.http.foo = beresp.ttl; set req.http.bar = "xxx"; } - sub vcl_hit { + sub vcl_lookup { set req.http.foo = obj.ttl; set obj.ttl = 7s; set obj.grace = 120s; diff --git a/bin/varnishtest/tests/r01113.vtc b/bin/varnishtest/tests/r01113.vtc index 23ef6e0..5bf31c1 100644 --- a/bin/varnishtest/tests/r01113.vtc +++ b/bin/varnishtest/tests/r01113.vtc @@ -15,7 +15,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { if (req.url == "/hit") { return(restart); } diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index 39d6eec..181e823 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -2,7 +2,7 @@ varnishtest "VCL compiler coverage test: vcc_action.c" varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_hit { return (restart) ; } + sub vcl_lookup { return (restart) ; } sub vcl_miss { rollback; return (restart); } } diff --git a/bin/varnishtest/tests/v00023.vtc b/bin/varnishtest/tests/v00023.vtc index ca36194..10f9bb3 100644 --- a/bin/varnishtest/tests/v00023.vtc +++ b/bin/varnishtest/tests/v00023.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_hit { + sub vcl_lookup { set obj.ttl = 0s; return (restart); } diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index e7b7675..a90c3a2 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -28,7 +28,7 @@ sub vcl_response { } } -sub vcl_hit { +sub vcl_lookup { if (obj.grace < 3m) { set obj.grace = 1m; } else { diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index af32e23..f5387d9 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -83,7 +83,7 @@ returns =( ('pass', ('error', 'restart', 'pass',)), ('hash', ('hash',)), ('miss', ('error', 'restart', 'pass', 'fetch',)), - ('hit', ('error', 'restart', 'pass', 'deliver',)), + ('lookup', ('error', 'restart', 'pass', 'deliver',)), ('fetch', ('error', 'fetch', 'pass',)), ('response', ('error', 'restart', 'deliver',)), ('deliver', ('restart', 'deliver',)), @@ -389,8 +389,8 @@ sp_variables = ( ), ('obj.proto', 'STRING', - ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'lookup', 'error',), + ( 'lookup', 'error',), 'const struct req *' ), ('obj.status', @@ -407,37 +407,37 @@ sp_variables = ( ), ('obj.hits', 'INT', - ( 'hit', 'deliver',), + ( 'lookup', 'deliver',), ( ), 'const struct req *' ), ('obj.http.', 'HEADER', - ( 'hit', 'error',), + ( 'lookup', 'error',), ( 'error',), # XXX ? 'const struct req *' ), ('obj.ttl', 'DURATION', - ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'lookup', 'error',), + ( 'lookup', 'error',), 'struct req *' ), ('obj.grace', 'DURATION', - ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'lookup', 'error',), + ( 'lookup', 'error',), 'struct req *' ), ('obj.keep', 'DURATION', - ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'lookup', 'error',), + ( 'lookup', 'error',), 'struct req *' ), ('obj.lastuse', 'DURATION', - ( 'hit', 'deliver', 'error',), + ( 'lookup', 'deliver', 'error',), ( ), 'const struct req *' ), diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index de899cb..86d089b 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -372,7 +372,7 @@ static struct action_table { } action_table[] = { { "error", parse_error, VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | - VCL_MET_MISS | VCL_MET_HIT | VCL_MET_RESPONSE + VCL_MET_MISS | VCL_MET_LOOKUP | VCL_MET_RESPONSE }, #define VCL_RET_MAC(l, U, B) \ @@ -390,7 +390,7 @@ static struct action_table { { "set", parse_set }, { "synthetic", parse_synthetic, VCL_MET_ERROR }, { "unset", parse_unset }, - { "purge", parse_purge, VCL_MET_MISS | VCL_MET_HIT }, + { "purge", parse_purge, VCL_MET_MISS | VCL_MET_LOOKUP }, { "new", parse_new, VCL_MET_INIT}, { NULL, NULL } }; From phk at varnish-cache.org Wed Apr 3 09:32:59 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 11:32:59 +0200 Subject: [master] 7da07a6 Fold cnt_hit() into cnt_lookup() Message-ID: commit 7da07a6e3cb063532a3bcc1ffbdf117e5162912f Author: Poul-Henning Kamp Date: Wed Apr 3 09:32:34 2013 +0000 Fold cnt_hit() into cnt_lookup() diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 03c8ce0..1e51f7f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -713,65 +713,6 @@ cnt_fetchbody(struct worker *wrk, struct req *req) return (REQ_FSM_MORE); } -/*-------------------------------------------------------------------- - * HIT - * We had a cache hit. Ask VCL, then march off as instructed. - * -DOT subgraph xcluster_hit { -DOT hit [ -DOT shape=record -DOT label="{cnt_hit:|{vcl_hit()|{req.|obj.}}|{error?|restart?}|{deliver?|pass?}}" -DOT ] -DOT } -XDOT hit:err -> err_hit [label="error"] -XDOT err_hit [label="ERROR",shape=plaintext] -XDOT hit:rst -> rst_hit [label="restart",color=purple] -XDOT rst_hit [label="RESTART",shape=plaintext] -DOT hit:pass -> pass [label=pass,style=bold,color=red] -DOT hit:del -> prepresp [label="deliver",style=bold,color=green] - */ - -static enum req_fsm_nxt -cnt_hit(struct worker *wrk, struct req *req) -{ - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - AZ(req->objcore); - AZ(req->busyobj); - - assert(!(req->obj->objcore->flags & OC_F_PASS)); - - VCL_lookup_method(req); - - if (req->handling == VCL_RET_DELIVER) { - //AZ(req->busyobj->bereq->ws); - //AZ(req->busyobj->beresp->ws); - (void)HTTP1_DiscardReqBody(req); // XXX: handle err - req->req_step = R_STP_PREPRESP; - return (REQ_FSM_MORE); - } - - /* Drop our object, we won't need it */ - (void)HSH_Deref(&wrk->stats, NULL, &req->obj); - req->objcore = NULL; - - switch(req->handling) { - case VCL_RET_PASS: - req->req_step = R_STP_PASS; - return (REQ_FSM_MORE); - case VCL_RET_ERROR: - req->req_step = R_STP_ERROR; - return (REQ_FSM_MORE); - case VCL_RET_RESTART: - req->req_step = R_STP_RESTART; - return (REQ_FSM_MORE); - default: - WRONG("Illegal action in vcl_hit{}"); - } -} /*-------------------------------------------------------------------- * LOOKUP @@ -863,7 +804,39 @@ cnt_lookup(struct worker *wrk, struct req *req) wrk->stats.cache_hit++; VSLb(req->vsl, SLT_Hit, "%u", req->obj->vxid); - req->req_step = R_STP_HIT; + + AZ(req->objcore); + AZ(req->busyobj); + + assert(!(req->obj->objcore->flags & OC_F_PASS)); + + VCL_lookup_method(req); + + if (req->handling == VCL_RET_DELIVER) { + //AZ(req->busyobj->bereq->ws); + //AZ(req->busyobj->beresp->ws); + (void)HTTP1_DiscardReqBody(req); // XXX: handle err + req->req_step = R_STP_PREPRESP; + return (REQ_FSM_MORE); + } + + /* Drop our object, we won't need it */ + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); + req->objcore = NULL; + + switch(req->handling) { + case VCL_RET_PASS: + req->req_step = R_STP_PASS; + break; + case VCL_RET_ERROR: + req->req_step = R_STP_ERROR; + break; + case VCL_RET_RESTART: + req->req_step = R_STP_RESTART; + break; + default: + WRONG("Illegal action in vcl_lookup{}"); + } return (REQ_FSM_MORE); } diff --git a/include/tbl/steps.h b/include/tbl/steps.h index 3ceaa5e..ece22cb 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -42,7 +42,6 @@ REQ_STEP(pipe, PIPE, (wrk, req)) REQ_STEP(pass, PASS, (wrk, req)) REQ_STEP(lookup, LOOKUP, (wrk, req)) REQ_STEP(miss, MISS, (wrk, req)) -REQ_STEP(hit, HIT, (wrk, req)) REQ_STEP(fetch, FETCH, (wrk, req)) REQ_STEP(fetchbody, FETCHBODY, (wrk, req)) REQ_STEP(prepresp, PREPRESP, (wrk, req)) From phk at varnish-cache.org Wed Apr 3 10:18:34 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 12:18:34 +0200 Subject: [master] c13365e Flush the req->vsl on a panic. Message-ID: commit c13365e028926e16a7a2c9aaf842c6972f97995e Author: Poul-Henning Kamp Date: Wed Apr 3 10:18:20 2013 +0000 Flush the req->vsl on a panic. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a63c36e..31b8384 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -910,7 +910,7 @@ extern volatile struct params * cache_param; void THR_SetName(const char *name); const char* THR_GetName(void); void THR_SetRequest(const struct req *); -const struct req * THR_GetRequest(void); +struct req * THR_GetRequest(void); /* cache_lck.c */ diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 13c6612..dfdbfa5 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -60,7 +60,7 @@ THR_SetRequest(const struct req *req) AZ(pthread_setspecific(req_key, req)); } -const struct req * +struct req * THR_GetRequest(void) { diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index dd9b2d7..3f49033 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -388,7 +388,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, int err, enum vas_e kind) { const char *q; - const struct req *req; + struct req *req; AZ(pthread_mutex_lock(&panicstr_mtx)); /* Won't be released, we're going to die @@ -437,6 +437,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, req = THR_GetRequest(); if (req != NULL) pan_req(req); + VSL_Flush(req->vsl, 0); } VSB_printf(pan_vsp, "\n"); VSB_bcat(pan_vsp, "", 1); /* NUL termination */ From phk at varnish-cache.org Wed Apr 3 10:55:55 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 12:55:55 +0200 Subject: [master] 6c6a41a Actually do the VSL_flush on panics Message-ID: commit 6c6a41a277a53edd01fdc5d5d962f8fa9437dea6 Author: Poul-Henning Kamp Date: Wed Apr 3 10:55:34 2013 +0000 Actually do the VSL_flush on panics diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 3f49033..1781789 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -435,9 +435,10 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); - if (req != NULL) + if (req != NULL) { pan_req(req); VSL_Flush(req->vsl, 0); + } } VSB_printf(pan_vsp, "\n"); VSB_bcat(pan_vsp, "", 1); /* NUL termination */ From phk at varnish-cache.org Wed Apr 3 10:58:49 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 12:58:49 +0200 Subject: [master] 20bb2a0 Add beresp.uncacheable (will replace beresp.do_pass) and obj.uncacheable variables. Message-ID: commit 20bb2a0b0da9100c070a575da17c2c411f542903 Author: Poul-Henning Kamp Date: Wed Apr 3 10:58:20 2013 +0000 Add beresp.uncacheable (will replace beresp.do_pass) and obj.uncacheable variables. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index f724054..b40e2e0 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -202,6 +202,7 @@ VBERESP(beresp, unsigned, do_gzip, busyobj->do_gzip) VBERESP(beresp, unsigned, do_gunzip, busyobj->do_gunzip) VBERESP(beresp, unsigned, do_stream, busyobj->do_stream) VBERESP(beresp, unsigned, do_pass, busyobj->do_pass) +VBERESP(beresp, unsigned, uncacheable, busyobj->do_pass) /*--------------------------------------------------------------------*/ @@ -554,6 +555,14 @@ VRT_r_obj_lastuse(const struct req *req) } unsigned +VRT_r_obj_uncacheable(const struct req *req) +{ + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); + return (req->obj->objcore->flags & OC_F_PASS ? 1 : 0); +} + +unsigned VRT_r_req_backend_healthy(const struct req *req) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); diff --git a/bin/varnishtest/tests/c00011.vtc b/bin/varnishtest/tests/c00011.vtc index 3145575..4a1391d 100644 --- a/bin/varnishtest/tests/c00011.vtc +++ b/bin/varnishtest/tests/c00011.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_response { - set beresp.do_pass = true; + set beresp.uncacheable = true; } } -start diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc index aefd1ce..c995511 100644 --- a/bin/varnishtest/tests/c00014.vtc +++ b/bin/varnishtest/tests/c00014.vtc @@ -15,7 +15,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_response { - set beresp.do_pass = true; + set beresp.uncacheable = true; } } -start diff --git a/bin/varnishtest/tests/e00011.vtc b/bin/varnishtest/tests/e00011.vtc index 8d129b8..6c0a8ef 100644 --- a/bin/varnishtest/tests/e00011.vtc +++ b/bin/varnishtest/tests/e00011.vtc @@ -17,7 +17,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_response { - set beresp.do_pass = true; + set beresp.uncacheable = true; set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00318.vtc b/bin/varnishtest/tests/r00318.vtc index bdcdb2f..86b7672 100644 --- a/bin/varnishtest/tests/r00318.vtc +++ b/bin/varnishtest/tests/r00318.vtc @@ -8,7 +8,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_response { set beresp.do_esi = true; - set beresp.do_pass = true; + set beresp.uncacheable = true; } } -start diff --git a/bin/varnishtest/tests/r01206.vtc b/bin/varnishtest/tests/r01206.vtc index 2dc3b6e..35aa8af 100644 --- a/bin/varnishtest/tests/r01206.vtc +++ b/bin/varnishtest/tests/r01206.vtc @@ -40,7 +40,7 @@ server s1 -start varnish v1 -vcl+backend { sub vcl_response { - set beresp.do_pass = true; + set beresp.uncacheable = true; } } diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index f5387d9..df86279 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -345,6 +345,12 @@ sp_variables = ( ( 'response',), 'const struct req *' ), + ('beresp.uncacheable', + 'BOOL', + ( 'response',), + ( 'response',), + 'const struct req *' + ), ('beresp.ttl', 'DURATION', ( 'response',), @@ -441,6 +447,12 @@ sp_variables = ( ( ), 'const struct req *' ), + ('obj.uncacheable', + 'BOOL', + ( 'lookup', 'deliver', 'error',), + ( ), + 'const struct req *' + ), ('resp.proto', 'STRING', ( 'deliver',), From phk at varnish-cache.org Wed Apr 3 10:59:55 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Apr 2013 12:59:55 +0200 Subject: [master] dc7f9a9 Move the check for cached uncacheable objs (= "hit-for-pass") into default VCL. Message-ID: commit dc7f9a9e6daac082f6dc2514d49d03776ee60da1 Author: Poul-Henning Kamp Date: Wed Apr 3 10:59:01 2013 +0000 Move the check for cached uncacheable objs (= "hit-for-pass") into default VCL. Add a back-stop, so that a return(deliver) gets turned into return(pass) with a VCL_Error logged. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1e51f7f..835ef42 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -793,25 +793,25 @@ cnt_lookup(struct worker *wrk, struct req *req) VRY_Finish(req, NULL); - if (oc->flags & OC_F_PASS) { + if (oc->flags & OC_F_PASS) wrk->stats.cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u", req->obj->vxid); - (void)HSH_Deref(&wrk->stats, NULL, &req->obj); - AZ(req->objcore); - req->req_step = R_STP_PASS; - return (REQ_FSM_MORE); - } - - wrk->stats.cache_hit++; + else + wrk->stats.cache_hit++; VSLb(req->vsl, SLT_Hit, "%u", req->obj->vxid); AZ(req->objcore); AZ(req->busyobj); - assert(!(req->obj->objcore->flags & OC_F_PASS)); - VCL_lookup_method(req); + if ((req->obj->objcore->flags & OC_F_PASS) && + req->handling == VCL_RET_DELIVER) { + VSLb(req->vsl, SLT_VCL_Error, + "obj.uncacheable set, but vcl_lookup{} returned 'deliver'" + ", changing to 'pass'"); + req->handling = VCL_RET_PASS; + } + if (req->handling == VCL_RET_DELIVER) { //AZ(req->busyobj->bereq->ws); //AZ(req->busyobj->beresp->ws); diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index a8432ab..cfd5880 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -94,6 +94,9 @@ sub vcl_hash { } sub vcl_lookup { + if (obj.uncacheable) { + return (pass); + } return (deliver); } From phk at varnish-cache.org Sat Apr 6 07:11:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 06 Apr 2013 09:11:58 +0200 Subject: [master] 010ef99 Use the new-ish enum type for req-fsm returns Message-ID: commit 010ef9936ea9971c0ba5c8d68602295fa27d2efb Author: Poul-Henning Kamp Date: Sat Apr 6 07:10:03 2013 +0000 Use the new-ish enum type for req-fsm returns diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 8586090..d5cf9e6 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -47,7 +47,7 @@ ved_include(struct req *preq, const char *src, const char *host) struct worker *wrk; struct req *req; char *wrk_ws_wm; - int i; + enum req_fsm_nxt s; wrk = preq->wrk; @@ -104,12 +104,12 @@ ved_include(struct req *preq, const char *src, const char *host) while (1) { req->wrk = wrk; - i = CNT_Request(wrk, req); - if (i == 1) + s = CNT_Request(wrk, req); + if (s == REQ_FSM_DONE) break; DSL(DBG_WAITINGLIST, req->vsl->wid, - "loop waiting for ESI (%d)", i); - assert(i == 2); + "loop waiting for ESI (%d)", (int)s); + assert(s == REQ_FSM_DISEMBARK); AZ(req->wrk); (void)usleep(10000); } From phk at varnish-cache.org Sat Apr 6 07:11:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 06 Apr 2013 09:11:58 +0200 Subject: [master] 2f940fb Move esi-policy from hash-lookup to req-fsm Message-ID: commit 2f940fb94fa3258a6b79ec179c79c842bb4fd259 Author: Poul-Henning Kamp Date: Sat Apr 6 07:11:27 2013 +0000 Move esi-policy from hash-lookup to req-fsm diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index b680605..7c51041 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -286,7 +286,7 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc) */ struct objcore * -HSH_Lookup(struct req *req) +HSH_Lookup(struct req *req, int wait_for_busy) { struct worker *wrk; struct objhead *oh; @@ -309,7 +309,7 @@ HSH_Lookup(struct req *req) if (req->hash_objhead != NULL) { /* - * This sess came off the waiting list, and brings a + * This req came off the waiting list, and brings an * oh refcnt with it. */ CHECK_OBJ_NOTNULL(req->hash_objhead, OBJHEAD_MAGIC); @@ -409,7 +409,7 @@ HSH_Lookup(struct req *req) if (busy_found) { /* There are one or more busy objects, wait for them */ - if (req->esi_level == 0) { + if (wait_for_busy) { CHECK_OBJ_NOTNULL(wrk->nwaitinglist, WAITINGLIST_MAGIC); if (oh->waitinglist == NULL) { @@ -418,10 +418,14 @@ HSH_Lookup(struct req *req) } VTAILQ_INSERT_TAIL(&oh->waitinglist->list, req, w_list); + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, + "on waiting list <%p>", oh); + } else { + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, + "hit busy obj <%p>", oh); } - if (DO_DEBUG(DBG_WAITINGLIST)) - VSLb(req->vsl, SLT_Debug, - "on waiting list <%p>", oh); wrk->stats.busy_sleep++; SES_Charge(req->wrk, req); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 835ef42..7891a5c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -751,7 +751,7 @@ cnt_lookup(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - oc = HSH_Lookup(req); + oc = HSH_Lookup(req, req->esi_level == 0 ? 1 : 0); if (oc == NULL) { /* * We lost the session to a busy object, disembark the diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index f90f592..f680881 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,7 +53,7 @@ struct hash_slinger { /* cache_hash.c */ void HSH_Cleanup(struct worker *w); -struct objcore *HSH_Lookup(struct req *); +struct objcore *HSH_Lookup(struct req *, int wait_for_busy); void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); From tfheen at varnish-cache.org Mon Apr 8 11:36:50 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 08 Apr 2013 13:36:50 +0200 Subject: [master] e6f12e9 Prefer exact matches Message-ID: commit e6f12e901f00989f81dc745ad1aa9b9f93051c2e Author: Tollef Fog Heen Date: Mon Apr 8 13:31:27 2013 +0200 Prefer exact matches If there are multiple matches for a given VSL tag (such as "Hit" matching both Hit and HitPass), prefer the one that is an exact match. Fixes #1288 diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 8587fb1..e10567c 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -70,6 +70,10 @@ VSL_Name2Tag(const char *name, int l) for (i = 0; i < 256; i++) { if (VSL_tags[i] != NULL && !strncasecmp(name, VSL_tags[i], l)) { + if (strlen(VSL_tags[i]) == l) { + /* Exact match */ + return (i); + } if (n == -1) n = i; else From phk at varnish-cache.org Tue Apr 9 11:29:55 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 09 Apr 2013 13:29:55 +0200 Subject: [master] 61b722b Move always_miss check up front to get it over with. Message-ID: commit 61b722b61676022997d366b55d6424e907001cfd Author: Poul-Henning Kamp Date: Tue Apr 9 11:29:35 2013 +0000 Move always_miss check up front to get it over with. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 7c51041..aeb7fe3 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -285,8 +285,50 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc) /*--------------------------------------------------------------------- */ +static struct objcore * +hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) +{ + struct objcore *oc; + + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + + oc = wrk->nobjcore; + wrk->nobjcore = NULL; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + + AN(oc->flags & OC_F_BUSY); + oc->refcnt = 1; /* Owned by busyobj */ + oc->objhead = oh; + VTAILQ_INSERT_TAIL(&oh->objcs, oc, list); + return (oc); +} + +/*--------------------------------------------------------------------- + * XXX: future action: + * + * if (always_miss) + * return (insert_busy_obj()) + * switch (Lookup()) { + * case HIT: + * return (object); + * case BUSY_ONLY: + * if (!ignore_body) + * return (WAIT) + * // fallthrough + * case MISS: + * return (insert_busy_obj()) + * case EXPIRED_AND_BUSY: + * if (!ignore_body) + * return (expired_object) + * // fallthrough + * case EXPIRED: + * return (expired_object + insert_busy_obj()) + * } + * + */ + struct objcore * -HSH_Lookup(struct req *req, int wait_for_busy) +HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) { struct worker *wrk; struct objhead *oh; @@ -324,6 +366,14 @@ HSH_Lookup(struct req *req, int wait_for_busy) CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_AssertHeld(&oh->mtx); + if (always_insert) { + /* Insert new objcore in objecthead and release mutex */ + oc = hsh_insert_busyobj(wrk, oh); + /* NB: no deref of objhead, new object inherits reference */ + Lck_Unlock(&oh->mtx); + return (oc); + } + assert(oh->refcnt > 0); busy_found = 0; grace_oc = NULL; @@ -336,7 +386,7 @@ HSH_Lookup(struct req *req, int wait_for_busy) if (oc->flags & OC_F_BUSY || oc->busyobj != NULL) { CHECK_OBJ_ORNULL(oc->busyobj, BUSYOBJ_MAGIC); - if (req->hash_ignore_busy || req->hash_always_miss) + if (req->hash_ignore_busy) continue; if (oc->busyobj != NULL && @@ -393,7 +443,7 @@ HSH_Lookup(struct req *req, int wait_for_busy) oc = grace_oc; } - if (oc != NULL && !req->hash_always_miss) { + if (oc != NULL) { /* We found an object we like */ assert(oh->refcnt > 1); assert(oc->objhead == oh); @@ -440,13 +490,8 @@ HSH_Lookup(struct req *req, int wait_for_busy) } /* Insert (precreated) objcore in objecthead and release mutex */ - oc = wrk->nobjcore; - wrk->nobjcore = NULL; - AN(oc->flags & OC_F_BUSY); - oc->refcnt = 1; /* Owned by busyobj */ - oc->objhead = oh; - VTAILQ_INSERT_TAIL(&oh->objcs, oc, list); - /* NB: do not deref objhead the new object inherits our reference */ + oc = hsh_insert_busyobj(wrk, oh); + /* NB: no deref of objhead, new object inherits reference */ Lck_Unlock(&oh->mtx); return (oc); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 7891a5c..d0fb0e1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -751,7 +751,10 @@ cnt_lookup(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - oc = HSH_Lookup(req, req->esi_level == 0 ? 1 : 0); + oc = HSH_Lookup(req, + req->esi_level == 0 ? 1 : 0, + req->hash_always_miss ? 1 : 0 + ); if (oc == NULL) { /* * We lost the session to a busy object, disembark the diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index f680881..1ff7cac 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,7 +53,7 @@ struct hash_slinger { /* cache_hash.c */ void HSH_Cleanup(struct worker *w); -struct objcore *HSH_Lookup(struct req *, int wait_for_busy); +struct objcore *HSH_Lookup(struct req *, int wait_for_busy, int always_insert); void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); From tfheen at varnish-cache.org Tue Apr 9 11:49:06 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 09 Apr 2013 13:49:06 +0200 Subject: [master] eb4cb91 Revert "Fix a bug discovered by inspection:" Message-ID: commit eb4cb91e7ddbaecb4fcddf45f374e2a0a9e68935 Author: Tollef Fog Heen Date: Tue Apr 9 13:23:02 2013 +0200 Revert "Fix a bug discovered by inspection:" 13:19 < phk> you're right, that's bass ackwards This reverts commit 4c47a36e9f8b7b2dfe7eff60c3fda418dc6effca. diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 0b84a46..fa0fdcf 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -180,7 +180,7 @@ stv_alloc(struct stevedore *stv, size_t size) if (size <= cache_param->fetch_chunksize) break; - size <<= 1; + size >>= 1; } if (st != NULL) CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index f5c1c8e..a286de6 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -17,4 +17,4 @@ client c1 { expect resp.status == 503 } -run -varnish v1 -expect SMA.test.c_fail < 50 +varnish v1 -expect SMA.test.c_fail < 5 From phk at varnish-cache.org Tue Apr 9 12:25:21 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 09 Apr 2013 14:25:21 +0200 Subject: [master] a84e768 Pick the youngest grace/IMS candidate object. Message-ID: commit a84e768796f46360c58967ccf9a331f6181ff5da Author: Poul-Henning Kamp Date: Tue Apr 9 12:24:29 2013 +0000 Pick the youngest grace/IMS candidate object. Save a couple of needless oc_getobj() calls. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index aeb7fe3..833f9fd 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -333,9 +333,9 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) struct worker *wrk; struct objhead *oh; struct objcore *oc; - struct objcore *grace_oc; - struct object *o; - double grace_ttl; + struct objcore *exp_oc; + struct object *o, *exp_o; + double exp_entered; int busy_found; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -376,8 +376,10 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) assert(oh->refcnt > 0); busy_found = 0; - grace_oc = NULL; - grace_ttl = NAN; + exp_o = NULL; + exp_oc = NULL; + exp_entered = 0.0; + o = NULL; VTAILQ_FOREACH(oc, &oh->objcs, list) { /* Must be at least our own ref + the objcore we examine */ assert(oh->refcnt > 1); @@ -408,20 +410,14 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) if (o->vary != NULL && !VRY_Match(req, o->vary)) continue; - /* If still valid, use it */ - if (EXP_Ttl(req, o) >= req->t_req) + if (EXP_Ttl(req, o) >= req->t_req) { + /* If still valid, use it */ break; - - /* - * Remember any matching objects inside their grace period - * and if there are several, use the least expired one. - */ - if (EXP_Grace(req, o) >= req->t_req) { - if (grace_oc == NULL || - grace_ttl < o->exp.entered + o->exp.ttl) { - grace_oc = oc; - grace_ttl = o->exp.entered + o->exp.ttl; - } + } else if (o->exp.entered > exp_entered) { + /* record the newest object */ + exp_oc = oc; + exp_o = o; + exp_entered = o->exp.entered; } } @@ -434,24 +430,22 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) AZ(req->objcore); if (oc == NULL /* We found no live object */ - && grace_oc != NULL /* There is a grace candidate */ + && exp_oc != NULL /* There is a grace candidate */ && (busy_found /* Somebody else is already busy */ || !VDI_Healthy(req->director, req))) { /* Or it is impossible to fetch */ - o = oc_getobj(&wrk->stats, grace_oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - oc = grace_oc; + oc = exp_oc; + o = exp_o; } if (oc != NULL) { + AN(o); /* We found an object we like */ assert(oh->refcnt > 1); assert(oc->objhead == oh); oc->refcnt++; Lck_Unlock(&oh->mtx); assert(HSH_DerefObjHead(&wrk->stats, &oh)); - o = oc_getobj(&wrk->stats, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (!cache_param->obj_readonly && o->hits < INT_MAX) o->hits++; return (oc); From phk at varnish-cache.org Wed Apr 10 19:50:48 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 10 Apr 2013 21:50:48 +0200 Subject: [master] ccec288 Change calling convention of HSH_Lookup() so the return value is what major case we hit, and the returned obj/busyobj goes into pointer arguments. Message-ID: commit ccec288d5b47f6b52ee229de5fa0ceef89d559dc Author: Poul-Henning Kamp Date: Wed Apr 10 19:49:58 2013 +0000 Change calling convention of HSH_Lookup() so the return value is what major case we hit, and the returned obj/busyobj goes into pointer arguments. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 833f9fd..cfc4599 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -327,8 +327,9 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) * */ -struct objcore * -HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) +enum lookup_e +HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, + int wait_for_busy, int always_insert) { struct worker *wrk; struct objhead *oh; @@ -338,6 +339,11 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) double exp_entered; int busy_found; + AN(ocp); + *ocp = NULL; + AN(bop); + *bop = NULL; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); wrk = req->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -368,10 +374,10 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) if (always_insert) { /* Insert new objcore in objecthead and release mutex */ - oc = hsh_insert_busyobj(wrk, oh); + *ocp = hsh_insert_busyobj(wrk, oh); /* NB: no deref of objhead, new object inherits reference */ Lck_Unlock(&oh->mtx); - return (oc); + return (HSH_MISS); } assert(oh->refcnt > 0); @@ -448,7 +454,8 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) assert(HSH_DerefObjHead(&wrk->stats, &oh)); if (!cache_param->obj_readonly && o->hits < INT_MAX) o->hits++; - return (oc); + *ocp = oc; + return (HSH_HIT); } if (busy_found) { @@ -480,14 +487,14 @@ HSH_Lookup(struct req *req, int wait_for_busy, int always_insert) */ req->hash_objhead = oh; Lck_Unlock(&oh->mtx); - return (NULL); + return (HSH_BUSY); } /* Insert (precreated) objcore in objecthead and release mutex */ - oc = hsh_insert_busyobj(wrk, oh); + *ocp = hsh_insert_busyobj(wrk, oh); /* NB: no deref of objhead, new object inherits reference */ Lck_Unlock(&oh->mtx); - return (oc); + return (HSH_MISS); } /*--------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index d0fb0e1..6ce4f3f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -740,6 +740,7 @@ cnt_lookup(struct worker *wrk, struct req *req) struct object *o; struct objhead *oh; struct busyobj *bo; + enum lookup_e lr; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -751,11 +752,11 @@ cnt_lookup(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - oc = HSH_Lookup(req, + lr = HSH_Lookup(req, &oc, &bo, req->esi_level == 0 ? 1 : 0, req->hash_always_miss ? 1 : 0 ); - if (oc == NULL) { + if (lr == HSH_BUSY) { /* * We lost the session to a busy object, disembark the * worker thread. We return to STP_LOOKUP when the busy diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 1ff7cac..76a47a7 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -30,6 +30,8 @@ struct sess; struct req; +struct objcore; +struct busyobj; struct worker; struct object; @@ -51,9 +53,19 @@ struct hash_slinger { hash_deref_f *deref; }; +enum lookup_e { + HSH_MISS, + HSH_BUSY, + HSH_HIT, + HSH_EXP, + HSH_EXPBUSY +}; + /* cache_hash.c */ void HSH_Cleanup(struct worker *w); -struct objcore *HSH_Lookup(struct req *, int wait_for_busy, int always_insert); +enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct busyobj **, + int wait_for_busy, int always_insert); +// struct objcore *HSH_Lookup(struct req *, int wait_for_busy, int always_insert); void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); From phk at varnish-cache.org Fri Apr 12 20:14:17 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 12 Apr 2013 22:14:17 +0200 Subject: [master] 12f5a29 Move HSH_Lookup() all the way to the V4 state, compensate backwards to V3 in cnt_lookup() Message-ID: commit 12f5a29c9721dc85467c18c4d290dac60406f06d Author: Poul-Henning Kamp Date: Fri Apr 12 20:13:02 2013 +0000 Move HSH_Lookup() all the way to the V4 state, compensate backwards to V3 in cnt_lookup() Amazingly all the vtc's still pass. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index cfc4599..eab4907 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -304,31 +304,10 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) } /*--------------------------------------------------------------------- - * XXX: future action: - * - * if (always_miss) - * return (insert_busy_obj()) - * switch (Lookup()) { - * case HIT: - * return (object); - * case BUSY_ONLY: - * if (!ignore_body) - * return (WAIT) - * // fallthrough - * case MISS: - * return (insert_busy_obj()) - * case EXPIRED_AND_BUSY: - * if (!ignore_body) - * return (expired_object) - * // fallthrough - * case EXPIRED: - * return (expired_object + insert_busy_obj()) - * } - * */ enum lookup_e -HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, +HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, int wait_for_busy, int always_insert) { struct worker *wrk; @@ -338,11 +317,12 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, struct object *o, *exp_o; double exp_entered; int busy_found; + enum lookup_e retval; AN(ocp); *ocp = NULL; - AN(bop); - *bop = NULL; + AN(bocp); + *bocp = NULL; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); wrk = req->wrk; @@ -374,7 +354,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, if (always_insert) { /* Insert new objcore in objecthead and release mutex */ - *ocp = hsh_insert_busyobj(wrk, oh); + *bocp = hsh_insert_busyobj(wrk, oh); /* NB: no deref of objhead, new object inherits reference */ Lck_Unlock(&oh->mtx); return (HSH_MISS); @@ -418,8 +398,17 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, if (EXP_Ttl(req, o) >= req->t_req) { /* If still valid, use it */ - break; - } else if (o->exp.entered > exp_entered) { + assert(oh->refcnt > 1); + assert(oc->objhead == oh); + oc->refcnt++; + Lck_Unlock(&oh->mtx); + assert(HSH_DerefObjHead(&wrk->stats, &oh)); + if (!cache_param->obj_readonly && o->hits < INT_MAX) + o->hits++; + *ocp = oc; + return (HSH_HIT); + } + if (o->exp.entered > exp_entered) { /* record the newest object */ exp_oc = oc; exp_o = o; @@ -427,74 +416,66 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct busyobj **bop, } } - /* - * If we have seen a busy object or the backend is unhealthy, and - * we have an object in grace, use it, if req.grace is also - * satisified. - * XXX: VDI_Healty() call with oh->mtx is not so cool. - */ + if (exp_oc != NULL) { + AN(exp_o); + assert(oh->refcnt > 1); + assert(exp_oc->objhead == oh); + exp_oc->refcnt++; - AZ(req->objcore); - if (oc == NULL /* We found no live object */ - && exp_oc != NULL /* There is a grace candidate */ - && (busy_found /* Somebody else is already busy */ - || !VDI_Healthy(req->director, req))) { - /* Or it is impossible to fetch */ - oc = exp_oc; - o = exp_o; + if (!busy_found) { + AZ(req->hash_ignore_busy); + *bocp = hsh_insert_busyobj(wrk, oh); + retval = HSH_EXPBUSY; + } else { + retval = HSH_EXP; + } + + Lck_Unlock(&oh->mtx); + if (retval == HSH_EXP) + assert(HSH_DerefObjHead(&wrk->stats, &oh)); + if (!cache_param->obj_readonly && exp_o->hits < INT_MAX) + exp_o->hits++; + *ocp = exp_oc; + return (retval); } - if (oc != NULL) { - AN(o); - /* We found an object we like */ - assert(oh->refcnt > 1); - assert(oc->objhead == oh); - oc->refcnt++; + if (!busy_found) { + /* Insert objcore in objecthead and release mutex */ + *bocp = hsh_insert_busyobj(wrk, oh); + /* NB: no deref of objhead, new object inherits reference */ Lck_Unlock(&oh->mtx); - assert(HSH_DerefObjHead(&wrk->stats, &oh)); - if (!cache_param->obj_readonly && o->hits < INT_MAX) - o->hits++; - *ocp = oc; - return (HSH_HIT); + return (HSH_MISS); } - if (busy_found) { - /* There are one or more busy objects, wait for them */ - if (wait_for_busy) { - CHECK_OBJ_NOTNULL(wrk->nwaitinglist, - WAITINGLIST_MAGIC); - if (oh->waitinglist == NULL) { - oh->waitinglist = wrk->nwaitinglist; - wrk->nwaitinglist = NULL; - } - VTAILQ_INSERT_TAIL(&oh->waitinglist->list, - req, w_list); - if (DO_DEBUG(DBG_WAITINGLIST)) - VSLb(req->vsl, SLT_Debug, - "on waiting list <%p>", oh); - } else { - if (DO_DEBUG(DBG_WAITINGLIST)) - VSLb(req->vsl, SLT_Debug, - "hit busy obj <%p>", oh); - } + /* There are one or more busy objects, wait for them */ - wrk->stats.busy_sleep++; - SES_Charge(req->wrk, req); - /* - * The objhead reference transfers to the sess, we get it - * back when the sess comes off the waiting list and - * calls us again - */ - req->hash_objhead = oh; - Lck_Unlock(&oh->mtx); - return (HSH_BUSY); + AZ(req->hash_ignore_busy); + + if (wait_for_busy) { + CHECK_OBJ_NOTNULL(wrk->nwaitinglist, WAITINGLIST_MAGIC); + if (oh->waitinglist == NULL) { + oh->waitinglist = wrk->nwaitinglist; + wrk->nwaitinglist = NULL; + } + VTAILQ_INSERT_TAIL(&oh->waitinglist->list, + req, w_list); + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); + } else { + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, "hit busy obj <%p>", oh); } - /* Insert (precreated) objcore in objecthead and release mutex */ - *ocp = hsh_insert_busyobj(wrk, oh); - /* NB: no deref of objhead, new object inherits reference */ + wrk->stats.busy_sleep++; + SES_Charge(req->wrk, req); + /* + * The objhead reference transfers to the sess, we get it + * back when the sess comes off the waiting list and + * calls us again + */ + req->hash_objhead = oh; Lck_Unlock(&oh->mtx); - return (HSH_MISS); + return (HSH_BUSY); } /*--------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 6ce4f3f..5697481 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -736,7 +736,7 @@ DOT lookup:yes -> pass [style=bold,color=red] static enum req_fsm_nxt cnt_lookup(struct worker *wrk, struct req *req) { - struct objcore *oc; + struct objcore *oc, *boc; struct object *o; struct objhead *oh; struct busyobj *bo; @@ -752,7 +752,7 @@ cnt_lookup(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - lr = HSH_Lookup(req, &oc, &bo, + lr = HSH_Lookup(req, &oc, &boc, req->esi_level == 0 ? 1 : 0, req->hash_always_miss ? 1 : 0 ); @@ -767,6 +767,45 @@ cnt_lookup(struct worker *wrk, struct req *req) } AZ(req->objcore); + + switch (lr) { + case HSH_EXP: +VSLb(req->vsl, SLT_Debug, "XXXX EXP\n"); + AN(oc); + AZ(boc); + break; + case HSH_EXPBUSY: +VSLb(req->vsl, SLT_Debug, "XXXX EXPBUSY\n"); + AN(oc); + AN(boc); + if (VDI_Healthy(req->director, req)) { +VSLb(req->vsl, SLT_Debug, "deref oc\n"); + (void)HSH_Deref(&wrk->stats, oc, NULL); + oc = boc; + boc = NULL; + } else { +VSLb(req->vsl, SLT_Debug, "drop boc\n"); + (void)HSH_Deref(&wrk->stats, boc, NULL); + boc = NULL; + } + break; + case HSH_MISS: +VSLb(req->vsl, SLT_Debug, "XXXX MISS\n"); + AZ(oc); + AN(boc); + oc = boc; + boc = NULL; + AN(oc->flags & OC_F_BUSY); + break; + case HSH_HIT: +VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); + AN(oc); + AZ(boc); + break; + default: + INCOMPL(); + } + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); oh = oc->objhead; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index cfd5880..f6c7833 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -94,9 +94,20 @@ sub vcl_hash { } sub vcl_lookup { +/* + if (!obj) { + return (deliver); + } if (obj.uncacheable) { return (pass); } + if (obj.ttl >= 0s) { + return (deliver); + } + if (obj.ttl + obj.grace > 0s) { + return (deliver_stale); + } +*/ return (deliver); } @@ -104,6 +115,7 @@ sub vcl_miss { return (fetch); } + sub vcl_fetch { return (fetch); } diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 76a47a7..ec6a4f2 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -63,7 +63,7 @@ enum lookup_e { /* cache_hash.c */ void HSH_Cleanup(struct worker *w); -enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct busyobj **, +enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, int wait_for_busy, int always_insert); // struct objcore *HSH_Lookup(struct req *, int wait_for_busy, int always_insert); void HSH_Ref(struct objcore *o); From phk at varnish-cache.org Mon Apr 15 21:00:48 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 15 Apr 2013 23:00:48 +0200 Subject: [master] 9b091b5 In the future we will need VCL also when we don't have a "struct req" at hand, most notably in the backend functions. Message-ID: commit 9b091b5e83f9408cc1a794ceb3dc54fd27ec1807 Author: Poul-Henning Kamp Date: Mon Apr 15 20:59:48 2013 +0000 In the future we will need VCL also when we don't have a "struct req" at hand, most notably in the backend functions. Pass also a struct worker pointer to all VCL methods. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 31b8384..1b2aaed 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1016,7 +1016,7 @@ void VCL_Rel(struct VCL_conf **vcc); void VCL_Poll(void); const char *VCL_Return_Name(unsigned method); -#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct req *); +#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct worker *, struct req *); #include "tbl/vcl_returns.h" #undef VCL_MET_MAC diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5697481..49d5fa1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp); RES_BuildHttp(req); - VCL_deliver_method(req); + VCL_deliver_method(wrk, req); switch (req->handling) { case VCL_RET_DELIVER: break; @@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req) http_PutResponse(h, req->err_reason); else http_PutResponse(h, http_StatusMessage(req->err_code)); - VCL_error_method(req); + VCL_error_method(wrk, req); if (req->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { @@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->do_esi); AZ(bo->do_pass); - VCL_response_method(req); + VCL_response_method(wrk, req); if (bo->do_pass) req->objcore->flags |= OC_F_PASS; @@ -845,7 +845,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); AZ(req->objcore); AZ(req->busyobj); - VCL_lookup_method(req); + VCL_lookup_method(wrk, req); if ((req->obj->objcore->flags & OC_F_PASS) && req->handling == VCL_RET_DELIVER) { @@ -923,8 +923,8 @@ cnt_miss(struct worker *wrk, struct req *req) http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } - VCL_fetch_method(req); - VCL_miss_method(req); + VCL_fetch_method(wrk, req); + VCL_miss_method(wrk, req); if (req->handling == VCL_RET_FETCH) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -988,8 +988,8 @@ cnt_pass(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_PASS); - VCL_fetch_method(req); - VCL_pass_method(req); + VCL_fetch_method(wrk, req); + VCL_pass_method(wrk, req); if (req->handling == VCL_RET_ERROR) { http_Teardown(bo->bereq); @@ -1047,7 +1047,7 @@ cnt_pipe(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, 0); - VCL_pipe_method(req); + VCL_pipe_method(wrk, req); if (req->handling == VCL_RET_ERROR) INCOMPL(); @@ -1119,7 +1119,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green] */ static enum req_fsm_nxt -cnt_recv(const struct worker *wrk, struct req *req) +cnt_recv(struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; @@ -1153,7 +1153,7 @@ cnt_recv(const struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - VCL_recv_method(req); + VCL_recv_method(wrk, req); recv_handling = req->handling; if (cache_param->http_gzip_support && @@ -1169,7 +1169,7 @@ cnt_recv(const struct worker *wrk, struct req *req) req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); - VCL_hash_method(req); + VCL_hash_method(wrk, req); assert(req->handling == VCL_RET_HASH); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 5c19997..8971550 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(NULL); + (void)vcl->conf->init_func(NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(NULL); + (void)vcl->conf->fini_func(NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -336,7 +336,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) #define VCL_MET_MAC(func, upper, bitmap) \ void \ -VCL_##func##_method(struct req *req) \ +VCL_##func##_method(struct worker *wrk, struct req *req) \ { \ char *aws; \ \ @@ -347,7 +347,7 @@ VCL_##func##_method(struct req *req) \ req->handling = 0; \ req->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ - (void)req->vcl->func##_func(req); \ + (void)req->vcl->func##_func(wrk, req); \ VSLb(req->vsl, SLT_VCL_return, "%s", \ VCL_Return_Name(req->handling)); \ req->cur_method = 0; \ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index df86279..852ed6e 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -746,10 +746,11 @@ fo.write(""" struct sess; struct req; struct cli; +struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(struct req *req); +typedef int vcl_func_f(struct worker *wrk, struct req *req); """) diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 6eca56c..3aa1916 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -692,7 +692,8 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) /* Emit method functions */ for (i = 0; i < VCL_MET_MAX; i++) { Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); - Fc(tl, 1, "VGC_function_%s(struct req *req)\n", + Fc(tl, 1, + "VGC_function_%s(struct worker *wrk, struct req *req)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); From phk at varnish-cache.org Tue Apr 16 08:39:36 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 16 Apr 2013 10:39:36 +0200 Subject: [master] b7027d4 Encode the VRT prototype leading arguments, they're about to become more complicated. Message-ID: commit b7027d48645e4e726f08c98df11cbdde52491c03 Author: Poul-Henning Kamp Date: Tue Apr 16 08:37:28 2013 +0000 Encode the VRT prototype leading arguments, they're about to become more complicated. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index b40e2e0..5ef7a9b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -232,8 +232,8 @@ VRT_l_client_identity(struct req *req, const char *str, ...) /*--------------------------------------------------------------------*/ #define BEREQ_TIMEOUT(which) \ -void __match_proto__() \ -VRT_l_bereq_##which(struct req *req, double num) \ +void \ +VRT_l_bereq_##which(const struct req *req, double num) \ { \ \ CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 852ed6e..3bdbed6 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -103,385 +103,385 @@ sp_variables = ( 'IP', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('client.identity', 'STRING', ( 'proc',), ( 'proc',), - 'struct req *' + 'R' ), ('server.ip', 'IP', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('server.hostname', 'STRING', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('server.identity', 'STRING', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('server.port', 'INT', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('req.method', 'STRING', ( 'proc',), ( 'proc',), - 'const struct req *' + 'cR' ), ('req.request', 'STRING', ( 'proc',), ( 'proc',), - 'const struct req *' + 'cR' ), ('req.url', 'STRING', ( 'proc',), ( 'proc',), - 'const struct req *' + 'cR' ), ('req.proto', 'STRING', ( 'proc',), ( 'proc',), - 'const struct req *' + 'cR' ), ('req.http.', 'HEADER', ( 'proc',), ( 'proc',), - 'const struct req *' + 'cR' ), ('req.backend', 'BACKEND', ( 'proc',), ( 'proc',), - 'struct req *' + 'R' ), ('req.restarts', 'INT', ( 'proc',), ( ), - 'const struct req *' + 'cR' ), ('req.esi_level', 'INT', ( 'proc',), ( ), - 'const struct req *' + 'cR' ), ('req.ttl', 'DURATION', ( 'proc',), ( 'proc',), - 'struct req *' + 'R' ), ('req.grace', 'DURATION', ( 'proc',), ( 'proc',), - 'struct req *' + 'R' ), ('req.keep', 'DURATION', ( 'proc',), ( 'proc',), - 'struct req *' + 'R' ), ('req.xid', 'STRING', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('req.esi', 'BOOL', ( 'recv', 'response', 'deliver', 'error',), ( 'recv', 'response', 'deliver', 'error',), - 'struct req *' + 'R' ), ('req.can_gzip', 'BOOL', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('req.backend.healthy', 'BOOL', ( 'proc',), ( ), - 'struct req *' + 'R' ), ('req.hash_ignore_busy', 'BOOL', ( 'recv',), ( 'recv',), - 'struct req *' + 'R' ), ('req.hash_always_miss', 'BOOL', ( 'recv',), ( 'recv',), - 'struct req *' + 'R' ), ('bereq.method', 'STRING', ( 'pipe', 'fetch', 'pass', 'miss', 'response',), ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - 'const struct req *' + 'cR' ), ('bereq.request', 'STRING', ( 'pipe', 'fetch', 'pass', 'miss', 'response',), ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - 'const struct req *' + 'cR' ), ('bereq.url', 'STRING', ( 'pipe', 'fetch', 'pass', 'miss', 'response',), ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - 'const struct req *' + 'cR' ), ('bereq.proto', 'STRING', ( 'pipe', 'fetch', 'pass', 'miss', 'response',), ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - 'const struct req *' + 'cR' ), ('bereq.http.', 'HEADER', ( 'pipe', 'fetch', 'pass', 'miss', 'response',), ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - 'const struct req *' + 'cR' ), ('bereq.connect_timeout', 'DURATION', ( 'pipe', 'fetch', 'pass', 'miss',), ( 'pipe', 'fetch', 'pass', 'miss',), - 'struct req *' + 'cR' ), ('bereq.first_byte_timeout', 'DURATION', ( 'fetch', 'pass', 'miss',), ( 'fetch', 'pass', 'miss',), - 'struct req *' + 'cR' ), ('bereq.between_bytes_timeout', 'DURATION', ( 'fetch', 'pass', 'miss',), ( 'fetch', 'pass', 'miss',), - 'struct req *' + 'cR' ), ('beresp.proto', 'STRING', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.saintmode', 'DURATION', ( ), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.status', 'INT', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.response', 'STRING', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.http.', 'HEADER', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.do_esi', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.do_stream', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.do_gzip', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.do_gunzip', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.do_pass', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.uncacheable', 'BOOL', ( 'response',), ( 'response',), - 'const struct req *' + 'cR' ), ('beresp.ttl', 'DURATION', ( 'response',), ( 'response',), - 'struct req *' + 'R' ), ('beresp.grace', 'DURATION', ( 'response',), ( 'response',), - 'struct req *' + 'R' ), ('beresp.keep', 'DURATION', ( 'response',), ( 'response',), - 'struct req *' + 'R' ), ('beresp.backend.name', 'STRING', ( 'response',), ( ), - 'const struct req *' + 'cR' ), ('beresp.backend.ip', 'IP', ( 'response',), ( ), - 'const struct req *' + 'cR' ), ('beresp.backend.port', 'INT', ( 'response',), ( ), - 'const struct req *' + 'cR' ), ('beresp.storage', 'STRING', ( 'response',), ( 'response',), - 'struct req *' + 'R' ), ('obj.proto', 'STRING', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'const struct req *' + 'cR' ), ('obj.status', 'INT', ( 'error',), ( 'error',), - 'const struct req *' + 'cR' ), ('obj.response', 'STRING', ( 'error',), ( 'error',), - 'const struct req *' + 'cR' ), ('obj.hits', 'INT', ( 'lookup', 'deliver',), ( ), - 'const struct req *' + 'cR' ), ('obj.http.', 'HEADER', ( 'lookup', 'error',), ( 'error',), # XXX ? - 'const struct req *' + 'cR' ), ('obj.ttl', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'struct req *' + 'R' ), ('obj.grace', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'struct req *' + 'R' ), ('obj.keep', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'struct req *' + 'R' ), ('obj.lastuse', 'DURATION', ( 'lookup', 'deliver', 'error',), ( ), - 'const struct req *' + 'cR' ), ('obj.uncacheable', 'BOOL', ( 'lookup', 'deliver', 'error',), ( ), - 'const struct req *' + 'cR' ), ('resp.proto', 'STRING', ( 'deliver',), ( 'deliver',), - 'const struct req *' + 'cR' ), ('resp.status', 'INT', ( 'deliver',), ( 'deliver',), - 'const struct req *' + 'cR' ), ('resp.response', 'STRING', ( 'deliver',), ( 'deliver',), - 'const struct req *' + 'cR' ), ('resp.http.', 'HEADER', ( 'deliver',), ( 'deliver',), - 'const struct req *' + 'cR' ), ('now', 'TIME', ( 'all',), ( ), - 'const struct req *' + 'cR' ), ) @@ -849,6 +849,17 @@ fo.write(""" const struct var vcc_vars[] = { """) +def mk_proto(c, r=False): + s = "" + for i in c: + if i == "c" and not r: + s += " const" + if i == "R": + if r: + s += " const" + s += " struct req *" + return s[1:] + for i in sp_variables: typ = i[1] cnam = i[0].replace(".", "_") @@ -864,10 +875,7 @@ for i in sp_variables: fo.write('",\n') else: fo.write('\t "VRT_r_%s(req)",\n' % cnam) - if i[4][:5] != "const": - fh.write(ctyp + " VRT_r_%s(const %s);\n" % (cnam, i[4])) - else: - fh.write(ctyp + " VRT_r_%s(%s);\n" % (cnam, i[4])) + fh.write(ctyp + " VRT_r_%s(%s);\n" % (cnam, mk_proto(i[4], True))) restrict(fo, i[2]) if len(i[3]) == 0: @@ -878,7 +886,7 @@ for i in sp_variables: fo.write('",\n') else: fo.write('\t "VRT_l_%s(req, ",\n' % cnam) - fh.write("void VRT_l_%s(%s, " % (cnam, i[4])) + fh.write("void VRT_l_%s(%s, " % (cnam, mk_proto(i[4], False))) if typ != "STRING": fh.write(ctyp + ");\n") else: From phk at varnish-cache.org Tue Apr 16 09:12:14 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 16 Apr 2013 11:12:14 +0200 Subject: [master] 69f498d Pass the designated workspace to the VCL methods. Message-ID: commit 69f498d49e0e8d2a11d13057dc34d6ca394618f9 Author: Poul-Henning Kamp Date: Tue Apr 16 09:11:52 2013 +0000 Pass the designated workspace to the VCL methods. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1b2aaed..051defb 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1016,7 +1016,8 @@ void VCL_Rel(struct VCL_conf **vcc); void VCL_Poll(void); const char *VCL_Return_Name(unsigned method); -#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct worker *, struct req *); +#define VCL_MET_MAC(l,u,b) \ + void VCL_##l##_method(struct worker *, struct req *, struct ws *); #include "tbl/vcl_returns.h" #undef VCL_MET_MAC diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 49d5fa1..2df6dd8 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp); RES_BuildHttp(req); - VCL_deliver_method(wrk, req); + VCL_deliver_method(wrk, req, req->http->ws); switch (req->handling) { case VCL_RET_DELIVER: break; @@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req) http_PutResponse(h, req->err_reason); else http_PutResponse(h, http_StatusMessage(req->err_code)); - VCL_error_method(wrk, req); + VCL_error_method(wrk, req, req->http->ws); if (req->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { @@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->do_esi); AZ(bo->do_pass); - VCL_response_method(wrk, req); + VCL_response_method(wrk, req, req->http->ws); if (bo->do_pass) req->objcore->flags |= OC_F_PASS; @@ -845,7 +845,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); AZ(req->objcore); AZ(req->busyobj); - VCL_lookup_method(wrk, req); + VCL_lookup_method(wrk, req, req->http->ws); if ((req->obj->objcore->flags & OC_F_PASS) && req->handling == VCL_RET_DELIVER) { @@ -923,8 +923,8 @@ cnt_miss(struct worker *wrk, struct req *req) http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } - VCL_fetch_method(wrk, req); - VCL_miss_method(wrk, req); + VCL_fetch_method(wrk, req, req->http->ws); + VCL_miss_method(wrk, req, req->http->ws); if (req->handling == VCL_RET_FETCH) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -988,8 +988,8 @@ cnt_pass(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_PASS); - VCL_fetch_method(wrk, req); - VCL_pass_method(wrk, req); + VCL_fetch_method(wrk, req, req->http->ws); + VCL_pass_method(wrk, req, req->http->ws); if (req->handling == VCL_RET_ERROR) { http_Teardown(bo->bereq); @@ -1047,7 +1047,7 @@ cnt_pipe(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, 0); - VCL_pipe_method(wrk, req); + VCL_pipe_method(wrk, req, req->http->ws); if (req->handling == VCL_RET_ERROR) INCOMPL(); @@ -1153,7 +1153,7 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - VCL_recv_method(wrk, req); + VCL_recv_method(wrk, req, req->http->ws); recv_handling = req->handling; if (cache_param->http_gzip_support && @@ -1169,7 +1169,7 @@ cnt_recv(struct worker *wrk, struct req *req) req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); - VCL_hash_method(wrk, req); + VCL_hash_method(wrk, req, req->http->ws); assert(req->handling == VCL_RET_HASH); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 8971550..a86bff7 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(NULL, NULL); + (void)vcl->conf->init_func(NULL, NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(NULL, NULL); + (void)vcl->conf->fini_func(NULL, NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -336,7 +336,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) #define VCL_MET_MAC(func, upper, bitmap) \ void \ -VCL_##func##_method(struct worker *wrk, struct req *req) \ +VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ { \ char *aws; \ \ @@ -347,7 +347,7 @@ VCL_##func##_method(struct worker *wrk, struct req *req) \ req->handling = 0; \ req->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ - (void)req->vcl->func##_func(wrk, req); \ + (void)req->vcl->func##_func(wrk, req, ws); \ VSLb(req->vsl, SLT_VCL_return, "%s", \ VCL_Return_Name(req->handling)); \ req->cur_method = 0; \ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 3bdbed6..67486f1 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -745,12 +745,13 @@ file_header(fo) fo.write(""" struct sess; struct req; +struct ws; struct cli; struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(struct worker *wrk, struct req *req); +typedef int vcl_func_f(struct worker *, struct req *, struct ws *); """) diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 3aa1916..99c5878 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -693,7 +693,8 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) for (i = 0; i < VCL_MET_MAX; i++) { Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); Fc(tl, 1, - "VGC_function_%s(struct worker *wrk, struct req *req)\n", + "VGC_function_%s(struct worker *wrk," + " struct req *req, struct ws *ws)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); From phk at varnish-cache.org Tue Apr 16 09:27:25 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 16 Apr 2013 11:27:25 +0200 Subject: [master] 8641ba8 Remove the req argument from the VCL foo-to-string conversion functions, all they need is a workspace. Some of them don't even need that. Message-ID: commit 8641ba85c8a7ac73bddcab2329158e57d24af01d Author: Poul-Henning Kamp Date: Tue Apr 16 09:26:50 2013 +0000 Remove the req argument from the VCL foo-to-string conversion functions, all they need is a workspace. Some of them don't even need that. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index d6dfef0..1551790 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -303,7 +303,7 @@ VRT_r_now(const struct req *req) /*--------------------------------------------------------------------*/ char * -VRT_IP_string(const struct req *req, const struct sockaddr_storage *sa) +VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa) { char *p; const struct sockaddr_in *si4; @@ -311,7 +311,7 @@ VRT_IP_string(const struct req *req, const struct sockaddr_storage *sa) const void *addr; int len; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); switch (sa->ss_family) { case AF_INET: len = INET_ADDRSTRLEN; @@ -327,65 +327,62 @@ VRT_IP_string(const struct req *req, const struct sockaddr_storage *sa) INCOMPL(); } XXXAN(len); - AN(p = WS_Alloc(req->http->ws, len)); + AN(p = WS_Alloc(ws, len)); AN(inet_ntop(sa->ss_family, addr, p, len)); return (p); } char * -VRT_INT_string(const struct req *req, long num) +VRT_INT_string(struct ws *ws, long num) { char *p; int size; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); size = snprintf(NULL, 0, "%ld", num) + 1; - AN(p = WS_Alloc(req->http->ws, size)); + AN(p = WS_Alloc(ws, size)); assert(snprintf(p, size, "%ld", num) < size); return (p); } char * -VRT_REAL_string(const struct req *req, double num) +VRT_REAL_string(struct ws *ws, double num) { char *p; int size; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); size = snprintf(NULL, 0, "%.3f", num) + 1; - AN(p = WS_Alloc(req->http->ws, size)); + AN(p = WS_Alloc(ws, size)); assert(snprintf(p, size, "%.3f", num) < size); return (p); } char * -VRT_TIME_string(const struct req *req, double t) +VRT_TIME_string(struct ws *ws, double t) { char *p; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - p = WS_Alloc(req->http->ws, VTIM_FORMAT_SIZE); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); + p = WS_Alloc(ws, VTIM_FORMAT_SIZE); if (p != NULL) VTIM_format(t, p); return (p); } const char * -VRT_BACKEND_string(const struct req *req, const struct director *d) +VRT_BACKEND_string(const struct director *d) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (d == NULL) - d = req->director; if (d == NULL) return (NULL); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); return (d->vcl_name); } const char * -VRT_BOOL_string(const struct req *req, unsigned val) +VRT_BOOL_string(unsigned val) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); return (val ? "true" : "false"); } diff --git a/include/vrt.h b/include/vrt.h index 228781d..2c05a17 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -32,6 +32,7 @@ */ struct req; +struct ws; struct vsb; struct cli; struct director; @@ -224,12 +225,12 @@ int VRT_Stv(const char *nm); /* Convert things to string */ -char *VRT_IP_string(const struct req *, const struct sockaddr_storage *sa); -char *VRT_INT_string(const struct req *, long); -char *VRT_REAL_string(const struct req *, double); -char *VRT_TIME_string(const struct req *, double); -const char *VRT_BOOL_string(const struct req *, unsigned); -const char *VRT_BACKEND_string(const struct req *, const struct director *d); +char *VRT_IP_string(struct ws *, const struct sockaddr_storage *sa); +char *VRT_INT_string(struct ws *, long); +char *VRT_REAL_string(struct ws *, double); +char *VRT_TIME_string(struct ws *, double); +const char *VRT_BOOL_string(unsigned); +const char *VRT_BACKEND_string(const struct director *d); #define VRT_done(req, hand) \ do { \ diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index b6790aa..e2a2256 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -402,22 +402,22 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) p = NULL; switch((*e)->fmt) { - case BACKEND: p = "VRT_BACKEND_string(req, \v1)"; break; - case BOOL: p = "VRT_BOOL_string(req, \v1)"; break; - case DURATION: p = "VRT_REAL_string(req, \v1)"; break; + case BACKEND: p = "VRT_BACKEND_string(\v1)"; break; + case BOOL: p = "VRT_BOOL_string(\v1)"; break; + case DURATION: p = "VRT_REAL_string(ws, \v1)"; break; /* XXX: should DURATION insist on "s" suffix ? */ case INT: if (vcc_isconst(*e)) { p = "\"\v1\""; constant = EXPR_CONST; } else { - p = "VRT_INT_string(req, \v1)"; + p = "VRT_INT_string(ws, \v1)"; } break; - case IP: p = "VRT_IP_string(req, \v1)"; break; - case BYTES: p = "VRT_REAL_string(req, \v1)"; break; /* XXX */ - case REAL: p = "VRT_REAL_string(req, \v1)"; break; - case TIME: p = "VRT_TIME_string(req, \v1)"; break; + case IP: p = "VRT_IP_string(ws, \v1)"; break; + case BYTES: p = "VRT_REAL_string(ws, \v1)"; break; /* XXX */ + case REAL: p = "VRT_REAL_string(ws, \v1)"; break; + case TIME: p = "VRT_TIME_string(ws, \v1)"; break; case HEADER: p = "VRT_GetHdr(req, \v1)"; break; case ENUM: case STRING: From phk at varnish-cache.org Tue Apr 16 10:17:33 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 16 Apr 2013 12:17:33 +0200 Subject: [master] 765139f Remove more 'req' arguments from VRT Message-ID: commit 765139fa6d2e244f8f3572175ed20b7fd6d059be Author: Poul-Henning Kamp Date: Tue Apr 16 10:12:12 2013 +0000 Remove more 'req' arguments from VRT diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 1551790..df705cb 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -293,10 +293,9 @@ VRT_hashdata(struct req *req, const char *str, ...) /*--------------------------------------------------------------------*/ double -VRT_r_now(const struct req *req) +VRT_r_now() { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); return (VTIM_real()); } @@ -430,41 +429,7 @@ VRT_synth_page(const struct req *req, unsigned flags, const char *str, ...) /*--------------------------------------------------------------------*/ void -VRT_ban(const struct req *req, char *cmds, ...) -{ - char *a1, *a2, *a3; - va_list ap; - struct ban *b; - int good; - - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - b = BAN_New(); - va_start(ap, cmds); - a1 = cmds; - good = 0; - while (a1 != NULL) { - good = 0; - a2 = va_arg(ap, char *); - if (a2 == NULL) - break; - a3 = va_arg(ap, char *); - if (a3 == NULL) - break; - if (BAN_AddTest(NULL, b, a1, a2, a3)) - break; - a1 = va_arg(ap, char *); - good = 1; - } - if (!good) - BAN_Free(b); /* XXX: report error how ? */ - else - (void)BAN_Insert(b); /* XXX: report error how ? */ -} - -/*--------------------------------------------------------------------*/ - -void -VRT_ban_string(const struct req *req, const char *str) +VRT_ban_string(const char *str) { char *a1, *a2, *a3; char **av; @@ -472,7 +437,6 @@ VRT_ban_string(const struct req *req, const char *str) int good; int i; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); av = VAV_Parse(str, NULL, ARGV_NOESC); if (av[0] != NULL) { /* XXX: report error how ? */ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5ef7a9b..16f8c8b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -232,7 +232,7 @@ VRT_l_client_identity(struct req *req, const char *str, ...) /*--------------------------------------------------------------------*/ #define BEREQ_TIMEOUT(which) \ -void \ +void \ VRT_l_bereq_##which(const struct req *req, double num) \ { \ \ diff --git a/include/vrt.h b/include/vrt.h index 2c05a17..3d769b1 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -168,8 +168,7 @@ int VRT_re_match(struct req *, const char *, void *re); const char *VRT_regsub(struct req *, int all, const char *, void *, const char *); -void VRT_ban(const struct req *, char *, ...); -void VRT_ban_string(const struct req *, const char *); +void VRT_ban_string(const char *); void VRT_purge(struct req *, double ttl, double grace); void VRT_count(struct req *, unsigned); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 67486f1..9b64cb9 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -481,7 +481,7 @@ sp_variables = ( 'TIME', ( 'all',), ( ), - 'cR' + '' ), ) @@ -851,6 +851,8 @@ const struct var vcc_vars[] = { """) def mk_proto(c, r=False): + if c == "": + return "void" s = "" for i in c: if i == "c" and not r: @@ -861,6 +863,20 @@ def mk_proto(c, r=False): s += " struct req *" return s[1:] + +def mk_args(c, r=False): + if c == "": + return "" + s = "" + for i in c: + if i == "c": + continue; + if i == "R": + s += "req" + if s != "" and not r: + s += "," + return s + for i in sp_variables: typ = i[1] cnam = i[0].replace(".", "_") @@ -875,8 +891,10 @@ for i in sp_variables: fo.write(i[0].split(".")[0].upper()) fo.write('",\n') else: - fo.write('\t "VRT_r_%s(req)",\n' % cnam) - fh.write(ctyp + " VRT_r_%s(%s);\n" % (cnam, mk_proto(i[4], True))) + fo.write('\t "VRT_r_%s(%s)",\n' % + (cnam, mk_args(i[4], True))) + fh.write(ctyp + " VRT_r_%s(%s);\n" % + (cnam, mk_proto(i[4], True))) restrict(fo, i[2]) if len(i[3]) == 0: @@ -886,7 +904,8 @@ for i in sp_variables: fo.write(i[0].split(".")[0].upper()) fo.write('",\n') else: - fo.write('\t "VRT_l_%s(req, ",\n' % cnam) + fo.write('\t "VRT_l_%s(%s",\n' % + (cnam, mk_args(i[4], False))) fh.write("void VRT_l_%s(%s, " % (cnam, mk_proto(i[4], False))) if typ != "STRING": fh.write(ctyp + ");\n") diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index 86d089b..a912188 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -261,7 +261,7 @@ parse_ban(struct vcc *tl) ExpectErr(tl, '('); vcc_NextToken(tl); - Fb(tl, 1, "VRT_ban_string(req, "); + Fb(tl, 1, "VRT_ban_string("); vcc_Expr(tl, STRING); ERRCHK(tl); Fb(tl, 0, ");\n"); From phk at varnish-cache.org Mon Apr 22 06:52:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 08:52:27 +0200 Subject: [master] d54e1ec Pass a busyobj * to the VCL methods Message-ID: commit d54e1ec9c12fcb787f3b0198f15d9c64e32d28a5 Author: Poul-Henning Kamp Date: Mon Apr 22 06:37:42 2013 +0000 Pass a busyobj * to the VCL methods diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a86bff7..502e1b7 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -191,7 +191,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(NULL, NULL, NULL); + (void)vcl->conf->init_func(NULL, NULL, NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -215,7 +215,7 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(NULL, NULL, NULL); + (void)vcl->conf->fini_func(NULL, NULL, NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -340,20 +340,21 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ { \ char *aws; \ \ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \ CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \ AN(req->sp); \ - aws = WS_Snapshot(req->wrk->aws); \ + aws = WS_Snapshot(wrk->aws); \ req->handling = 0; \ req->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ - (void)req->vcl->func##_func(wrk, req, ws); \ + (void)req->vcl->func##_func(wrk, req, NULL, ws); \ VSLb(req->vsl, SLT_VCL_return, "%s", \ VCL_Return_Name(req->handling)); \ req->cur_method = 0; \ assert((1U << req->handling) & bitmap); \ assert(!((1U << req->handling) & ~bitmap)); \ - WS_Reset(req->wrk->aws, aws); \ + WS_Reset(wrk->aws, aws); \ } #include "tbl/vcl_returns.h" diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 9b64cb9..f8c506b 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -745,13 +745,15 @@ file_header(fo) fo.write(""" struct sess; struct req; +struct busyobj; struct ws; struct cli; struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(struct worker *, struct req *, struct ws *); +typedef int vcl_func_f(struct worker *, struct req *, struct busyobj *, + struct ws *); """) diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 99c5878..30a71cb 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -694,7 +694,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); Fc(tl, 1, "VGC_function_%s(struct worker *wrk," - " struct req *req, struct ws *ws)\n", + " struct req *req, struct busyobj *bo, struct ws *ws)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); From phk at varnish-cache.org Mon Apr 22 06:52:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 08:52:27 +0200 Subject: [master] 20a5abe move VCL::handling from req to wrk Message-ID: commit 20a5abe7b911d135ccbe78b0dd05c673e1b40f61 Author: Poul-Henning Kamp Date: Mon Apr 22 06:52:18 2013 +0000 move VCL::handling from req to wrk diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 051defb..1b67d88 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -349,6 +349,7 @@ struct worker { struct vxid_pool vxid_pool; + unsigned handling; }; /* LRU ---------------------------------------------------------------*/ @@ -613,7 +614,6 @@ struct req { enum sess_close doclose; struct exp exp; unsigned cur_method; - unsigned handling; unsigned char wantbody; enum req_body_state_e req_body_status; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 1781789..bc3accf 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -225,9 +225,15 @@ pan_vcl(const struct VCL_conf *vcl) static void pan_wrk(const struct worker *wrk) { + const char *hand; VSB_printf(pan_vsp, " worker = %p {\n", wrk); pan_ws(wrk->aws, 4); + hand = VCL_Return_Name(wrk->handling); + if (hand != NULL) + VSB_printf(pan_vsp, " handling = %s,\n", hand); + else + VSB_printf(pan_vsp, " handling = 0x%x,\n", wrk->handling); VSB_printf(pan_vsp, " },\n"); } @@ -261,7 +267,7 @@ pan_busyobj(const struct busyobj *bo) static void pan_req(const struct req *req) { - const char *hand, *stp, *body; + const char *stp, *body; VSB_printf(pan_vsp, "req = %p {\n", req); @@ -290,11 +296,6 @@ pan_req(const struct req *req) VSB_printf(pan_vsp, " req_body = 0x%x,\n", req->req_body_status); - hand = VCL_Return_Name(req->handling); - if (hand != NULL) - VSB_printf(pan_vsp, " handling = %s,\n", hand); - else - VSB_printf(pan_vsp, " handling = 0x%x,\n", req->handling); if (req->err_code) VSB_printf(pan_vsp, " err_code = %d, err_reason = %s,\n", req->err_code, diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 2df6dd8..8d2b40c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -159,7 +159,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) RES_BuildHttp(req); VCL_deliver_method(wrk, req, req->http->ws); - switch (req->handling) { + switch (wrk->handling) { case VCL_RET_DELIVER: break; case VCL_RET_RESTART: @@ -310,21 +310,21 @@ cnt_error(struct worker *wrk, struct req *req) http_PutResponse(h, http_StatusMessage(req->err_code)); VCL_error_method(wrk, req, req->http->ws); - if (req->handling == VCL_RET_RESTART && + if (wrk->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { HSH_Drop(wrk, &req->obj); VBO_DerefBusyObj(wrk, &req->busyobj); req->req_step = R_STP_RESTART; return (REQ_FSM_MORE); - } else if (req->handling == VCL_RET_RESTART) - req->handling = VCL_RET_DELIVER; + } else if (wrk->handling == VCL_RET_RESTART) + wrk->handling = VCL_RET_DELIVER; /* We always close when we take this path */ req->doclose = SC_TX_ERROR; req->wantbody = 1; - assert(req->handling == VCL_RET_DELIVER); + assert(wrk->handling == VCL_RET_DELIVER); req->err_code = 0; req->err_reason = NULL; http_Teardown(bo->bereq); @@ -382,7 +382,7 @@ cnt_fetch(struct worker *wrk, struct req *req) } if (i) { - req->handling = VCL_RET_ERROR; + wrk->handling = VCL_RET_ERROR; req->err_code = 503; } else { /* @@ -421,7 +421,7 @@ cnt_fetch(struct worker *wrk, struct req *req) if (bo->do_pass) req->objcore->flags |= OC_F_PASS; - switch (req->handling) { + switch (wrk->handling) { case VCL_RET_DELIVER: req->req_step = R_STP_FETCHBODY; return (REQ_FSM_MORE); @@ -437,8 +437,8 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->vbc); if (req->objcore->objhead != NULL || - req->handling == VCL_RET_RESTART || - req->handling == VCL_RET_ERROR) { + wrk->handling == VCL_RET_RESTART || + wrk->handling == VCL_RET_ERROR) { CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; @@ -449,7 +449,7 @@ cnt_fetch(struct worker *wrk, struct req *req) req->director = NULL; req->storage_hint = NULL; - switch (req->handling) { + switch (wrk->handling) { case VCL_RET_RESTART: req->req_step = R_STP_RESTART; return (REQ_FSM_MORE); @@ -491,7 +491,7 @@ cnt_fetchbody(struct worker *wrk, struct req *req) bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - assert(req->handling == VCL_RET_DELIVER); + assert(wrk->handling == VCL_RET_DELIVER); if (req->objcore->objhead == NULL) { /* This is a pass from vcl_recv */ @@ -848,14 +848,14 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); VCL_lookup_method(wrk, req, req->http->ws); if ((req->obj->objcore->flags & OC_F_PASS) && - req->handling == VCL_RET_DELIVER) { + wrk->handling == VCL_RET_DELIVER) { VSLb(req->vsl, SLT_VCL_Error, "obj.uncacheable set, but vcl_lookup{} returned 'deliver'" ", changing to 'pass'"); - req->handling = VCL_RET_PASS; + wrk->handling = VCL_RET_PASS; } - if (req->handling == VCL_RET_DELIVER) { + if (wrk->handling == VCL_RET_DELIVER) { //AZ(req->busyobj->bereq->ws); //AZ(req->busyobj->beresp->ws); (void)HTTP1_DiscardReqBody(req); // XXX: handle err @@ -867,7 +867,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); (void)HSH_Deref(&wrk->stats, NULL, &req->obj); req->objcore = NULL; - switch(req->handling) { + switch(wrk->handling) { case VCL_RET_PASS: req->req_step = R_STP_PASS; break; @@ -926,7 +926,7 @@ cnt_miss(struct worker *wrk, struct req *req) VCL_fetch_method(wrk, req, req->http->ws); VCL_miss_method(wrk, req, req->http->ws); - if (req->handling == VCL_RET_FETCH) { + if (wrk->handling == VCL_RET_FETCH) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); req->req_step = R_STP_FETCH; return (REQ_FSM_MORE); @@ -937,7 +937,7 @@ cnt_miss(struct worker *wrk, struct req *req) http_Teardown(bo->bereq); VBO_DerefBusyObj(wrk, &req->busyobj); - switch(req->handling) { + switch(wrk->handling) { case VCL_RET_ERROR: req->req_step = R_STP_ERROR; break; @@ -991,13 +991,13 @@ cnt_pass(struct worker *wrk, struct req *req) VCL_fetch_method(wrk, req, req->http->ws); VCL_pass_method(wrk, req, req->http->ws); - if (req->handling == VCL_RET_ERROR) { + if (wrk->handling == VCL_RET_ERROR) { http_Teardown(bo->bereq); VBO_DerefBusyObj(wrk, &req->busyobj); req->req_step = R_STP_ERROR; return (REQ_FSM_MORE); } - assert(req->handling == VCL_RET_PASS); + assert(wrk->handling == VCL_RET_PASS); req->acct_req.pass++; req->req_step = R_STP_FETCH; @@ -1049,9 +1049,9 @@ cnt_pipe(struct worker *wrk, struct req *req) VCL_pipe_method(wrk, req, req->http->ws); - if (req->handling == VCL_RET_ERROR) + if (wrk->handling == VCL_RET_ERROR) INCOMPL(); - assert(req->handling == VCL_RET_PIPE); + assert(wrk->handling == VCL_RET_PIPE); PipeRequest(req); assert(WRW_IsReleased(wrk)); @@ -1154,7 +1154,7 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); VCL_recv_method(wrk, req, req->http->ws); - recv_handling = req->handling; + recv_handling = wrk->handling; if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && @@ -1170,7 +1170,7 @@ cnt_recv(struct worker *wrk, struct req *req) req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); VCL_hash_method(wrk, req, req->http->ws); - assert(req->handling == VCL_RET_HASH); + assert(wrk->handling == VCL_RET_HASH); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 502e1b7..723da03 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -345,15 +345,15 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \ AN(req->sp); \ aws = WS_Snapshot(wrk->aws); \ - req->handling = 0; \ + wrk->handling = 0; \ req->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ (void)req->vcl->func##_func(wrk, req, NULL, ws); \ VSLb(req->vsl, SLT_VCL_return, "%s", \ - VCL_Return_Name(req->handling)); \ + VCL_Return_Name(wrk->handling)); \ req->cur_method = 0; \ - assert((1U << req->handling) & bitmap); \ - assert(!((1U << req->handling) & ~bitmap)); \ + assert((1U << wrk->handling) & bitmap); \ + assert(!((1U << wrk->handling) & ~bitmap)); \ WS_Reset(wrk->aws, aws); \ } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index df705cb..622d6c8 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -258,16 +258,16 @@ VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...) /*--------------------------------------------------------------------*/ void -VRT_handling(struct req *req, unsigned hand) +VRT_handling(struct worker *wrk, unsigned hand) { - if (req == NULL) { + if (wrk == NULL) { assert(hand == VCL_RET_OK); return; } - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); assert(hand < VCL_RET_MAX); - req->handling = hand; + wrk->handling = hand; } /*-------------------------------------------------------------------- diff --git a/include/vrt.h b/include/vrt.h index 3d769b1..1b4d189 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -32,6 +32,7 @@ */ struct req; +struct worker; struct ws; struct vsb; struct cli; @@ -179,7 +180,7 @@ int VRT_switch_config(const char *); const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, const char *); char *VRT_GetHdr(const struct req *, const struct gethdr_s *); void VRT_SetHdr(struct req *, const struct gethdr_s *, const char *, ...); -void VRT_handling(struct req *, unsigned hand); +void VRT_handling(struct worker *, unsigned hand); void VRT_hashdata(struct req *, const char *str, ...); @@ -231,10 +232,4 @@ char *VRT_TIME_string(struct ws *, double); const char *VRT_BOOL_string(unsigned); const char *VRT_BACKEND_string(const struct director *d); -#define VRT_done(req, hand) \ - do { \ - VRT_handling(req, hand); \ - return (1); \ - } while (0) - const char *VRT_ReqString(struct req *, const char *p, ...); diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index a912188..baa5f29 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -79,7 +79,8 @@ parse_error(struct vcc *tl) Fb(tl, 1, ", 0\n"); } Fb(tl, 1, ");\n"); - Fb(tl, 1, "VRT_done(req, VCL_RET_ERROR);\n"); + Fb(tl, 1, "VRT_handling(wrk, VCL_RET_ERROR);\n"); + Fb(tl, 1, "return(1);\n"); } /*--------------------------------------------------------------------*/ @@ -311,7 +312,8 @@ parse_return(struct vcc *tl) #define VCL_RET_MAC(l, U, B) \ do { \ if (vcc_IdIs(tl->t, #l)) { \ - Fb(tl, 1, "VRT_done(req, VCL_RET_" #U ");\n"); \ + Fb(tl, 1, "VRT_handling(wrk, VCL_RET_" #U ");\n"); \ + Fb(tl, 1, "return (1);\n"); \ vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\ retval = 1; \ } \ From phk at varnish-cache.org Mon Apr 22 07:52:38 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 09:52:38 +0200 Subject: [master] a5e7017 Move cur_method from req to wrk Message-ID: commit a5e701721035f00d7e791fcac27f765c519f0807 Author: Poul-Henning Kamp Date: Mon Apr 22 07:52:23 2013 +0000 Move cur_method from req to wrk diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1b67d88..a7aad66 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -349,6 +349,7 @@ struct worker { struct vxid_pool vxid_pool; + unsigned cur_method; unsigned handling; }; @@ -613,7 +614,6 @@ struct req { enum sess_close doclose; struct exp exp; - unsigned cur_method; unsigned char wantbody; enum req_body_state_e req_body_status; @@ -1014,7 +1014,8 @@ void VCL_Init(void); void VCL_Refresh(struct VCL_conf **vcc); void VCL_Rel(struct VCL_conf **vcc); void VCL_Poll(void); -const char *VCL_Return_Name(unsigned method); +const char *VCL_Return_Name(unsigned); +const char *VCL_Method_Name(unsigned); #define VCL_MET_MAC(l,u,b) \ void VCL_##l##_method(struct worker *, struct req *, struct ws *); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index bc3accf..14c14b3 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -229,11 +229,17 @@ pan_wrk(const struct worker *wrk) VSB_printf(pan_vsp, " worker = %p {\n", wrk); pan_ws(wrk->aws, 4); + + hand = VCL_Method_Name(wrk->cur_method); + if (hand != NULL) + VSB_printf(pan_vsp, " VCL::method = %s,\n", hand); + else + VSB_printf(pan_vsp, " VCL::method = 0x%x,\n", wrk->cur_method); hand = VCL_Return_Name(wrk->handling); if (hand != NULL) - VSB_printf(pan_vsp, " handling = %s,\n", hand); + VSB_printf(pan_vsp, " VCL::return = %s,\n", hand); else - VSB_printf(pan_vsp, " handling = 0x%x,\n", wrk->handling); + VSB_printf(pan_vsp, " VCL::return = 0x%x,\n", wrk->handling); VSB_printf(pan_vsp, " },\n"); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 723da03..0ebf91a 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -65,10 +65,10 @@ static struct vcls *vcl_active; /* protected by vcl_mtx */ /*--------------------------------------------------------------------*/ const char * -VCL_Return_Name(unsigned method) +VCL_Return_Name(unsigned r) { - switch (method) { + switch (r) { #define VCL_RET_MAC(l, U, B) case VCL_RET_##U: return(#l); #include "tbl/vcl_returns.h" #undef VCL_RET_MAC @@ -77,6 +77,19 @@ VCL_Return_Name(unsigned method) } } +const char * +VCL_Method_Name(unsigned m) +{ + + switch (m) { +#define VCL_MET_MAC(func, upper, bitmap) case VCL_MET_##upper: return (#upper); +#include "tbl/vcl_returns.h" +#undef VCL_MET_MAC + default: + return (NULL); + } +} + /*--------------------------------------------------------------------*/ static void @@ -346,12 +359,12 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ AN(req->sp); \ aws = WS_Snapshot(wrk->aws); \ wrk->handling = 0; \ - req->cur_method = VCL_MET_ ## upper; \ + wrk->cur_method = VCL_MET_ ## upper; \ VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ (void)req->vcl->func##_func(wrk, req, NULL, ws); \ VSLb(req->vsl, SLT_VCL_return, "%s", \ VCL_Return_Name(wrk->handling)); \ - req->cur_method = 0; \ + wrk->cur_method = 0; \ assert((1U << wrk->handling) & bitmap); \ assert(!((1U << wrk->handling) & ~bitmap)); \ WS_Reset(wrk->aws, aws); \ diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 622d6c8..7ea7bcb 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -487,13 +487,14 @@ VRT_CacheReqBody(struct req *req, long long maxsize) */ void -VRT_purge(struct req *req, double ttl, double grace) +VRT_purge(const struct worker *wrk, struct req *req, double ttl, double grace) { + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->cur_method == VCL_MET_LOOKUP) + if (wrk->cur_method == VCL_MET_LOOKUP) HSH_Purge(req, req->obj->objcore->objhead, ttl, grace); - else if (req->cur_method == VCL_MET_MISS) + else if (wrk->cur_method == VCL_MET_MISS) HSH_Purge(req, req->objcore->objhead, ttl, grace); } diff --git a/bin/varnishtest/tests/c00033.vtc b/bin/varnishtest/tests/c00033.vtc index a7782a1..f78b582 100644 --- a/bin/varnishtest/tests/c00033.vtc +++ b/bin/varnishtest/tests/c00033.vtc @@ -25,13 +25,13 @@ varnish v1 -vcl+backend { sub vcl_lookup { if (req.method == "PURGE") { - C{ VRT_purge(req, 0, 0); }C + C{ VRT_purge(wrk, req, 0, 0); }C error 456 "got it"; } } sub vcl_miss { if (req.method == "PURGE") { - C{ VRT_purge(req, 0, 0); }C + C{ VRT_purge(wrk, req, 0, 0); }C error 456 "got it"; } } diff --git a/include/vrt.h b/include/vrt.h index 1b4d189..e71308a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -170,7 +170,7 @@ const char *VRT_regsub(struct req *, int all, const char *, void *, const char *); void VRT_ban_string(const char *); -void VRT_purge(struct req *, double ttl, double grace); +void VRT_purge(const struct worker *, struct req *, double ttl, double grace); void VRT_count(struct req *, unsigned); int VRT_rewrite(const char *, const char *); diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index baa5f29..bb42e35 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -347,7 +347,7 @@ parse_purge(struct vcc *tl) { vcc_NextToken(tl); - Fb(tl, 1, "VRT_purge(req, 0, 0);\n"); + Fb(tl, 1, "VRT_purge(wrk, req, 0, 0);\n"); } /*--------------------------------------------------------------------*/ From phk at varnish-cache.org Mon Apr 22 08:30:13 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 10:30:13 +0200 Subject: [master] 7913217 Follow up on discussion some weeks back, and rename vcl_fetch{} to vcl_backend_fetch{}, and vcl_response{} to vcl_backend_response{}. Message-ID: commit 791321739fccc7fe5bfaabbad99b0d81b792c1f8 Author: Poul-Henning Kamp Date: Mon Apr 22 08:28:44 2013 +0000 Follow up on discussion some weeks back, and rename vcl_fetch{} to vcl_backend_fetch{}, and vcl_response{} to vcl_backend_response{}. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8d2b40c..240d166 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -416,7 +416,7 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->do_esi); AZ(bo->do_pass); - VCL_response_method(wrk, req, req->http->ws); + VCL_backend_response_method(wrk, req, req->http->ws); if (bo->do_pass) req->objcore->flags |= OC_F_PASS; @@ -923,7 +923,7 @@ cnt_miss(struct worker *wrk, struct req *req) http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } - VCL_fetch_method(wrk, req, req->http->ws); + VCL_backend_fetch_method(wrk, req, req->http->ws); VCL_miss_method(wrk, req, req->http->ws); if (wrk->handling == VCL_RET_FETCH) { @@ -988,7 +988,7 @@ cnt_pass(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_PASS); - VCL_fetch_method(wrk, req, req->http->ws); + VCL_backend_fetch_method(wrk, req, req->http->ws); VCL_pass_method(wrk, req, req->http->ws); if (wrk->handling == VCL_RET_ERROR) { diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index f6c7833..f4137b4 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -116,11 +116,11 @@ sub vcl_miss { } -sub vcl_fetch { +sub vcl_backend_fetch { return (fetch); } -sub vcl_response { +sub vcl_backend_response { if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Surrogate-control ~ "no-store" || diff --git a/bin/varnishtest/tests.disabled/r00929.vtc b/bin/varnishtest/tests.disabled/r00929.vtc index 996465a..6f7729d 100644 --- a/bin/varnishtest/tests.disabled/r00929.vtc +++ b/bin/varnishtest/tests.disabled/r00929.vtc @@ -8,7 +8,7 @@ server s1 { varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = true; } diff --git a/bin/varnishtest/tests.disabled/r00978.vtc b/bin/varnishtest/tests.disabled/r00978.vtc index e14402d..8d52e60 100644 --- a/bin/varnishtest/tests.disabled/r00978.vtc +++ b/bin/varnishtest/tests.disabled/r00978.vtc @@ -22,7 +22,7 @@ varnish v1 -vcl+backend { set req.url = req.url + req.esi_level; } } - sub vcl_response { + sub vcl_backend_response { if (req.url == "/") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests.disabled/r00979.vtc b/bin/varnishtest/tests.disabled/r00979.vtc index 0857981..216f7cb 100644 --- a/bin/varnishtest/tests.disabled/r00979.vtc +++ b/bin/varnishtest/tests.disabled/r00979.vtc @@ -11,7 +11,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = true; } sub vcl_deliver { diff --git a/bin/varnishtest/tests.disabled/r00980.vtc b/bin/varnishtest/tests.disabled/r00980.vtc index da4d83c..f14113f 100644 --- a/bin/varnishtest/tests.disabled/r00980.vtc +++ b/bin/varnishtest/tests.disabled/r00980.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_gzip = true; set beresp.do_stream = true; } diff --git a/bin/varnishtest/tests.disabled/t00000.vtc b/bin/varnishtest/tests.disabled/t00000.vtc index b4fcc5b..cc47769 100644 --- a/bin/varnishtest/tests.disabled/t00000.vtc +++ b/bin/varnishtest/tests.disabled/t00000.vtc @@ -15,7 +15,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = true; } } -start diff --git a/bin/varnishtest/tests.disabled/t00001.vtc b/bin/varnishtest/tests.disabled/t00001.vtc index 84aa647..f6a3944 100644 --- a/bin/varnishtest/tests.disabled/t00001.vtc +++ b/bin/varnishtest/tests.disabled/t00001.vtc @@ -22,7 +22,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/foo") { set beresp.do_gzip = true; } diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index 7cb1b97..ff39f42 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -53,7 +53,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (beresp.status == 502) { set beresp.ttl = 10m; } diff --git a/bin/varnishtest/tests/b00018.vtc b/bin/varnishtest/tests/b00018.vtc index 6197511..06f4ed1 100644 --- a/bin/varnishtest/tests/b00018.vtc +++ b/bin/varnishtest/tests/b00018.vtc @@ -1,4 +1,4 @@ -varnishtest "Check that error in vcl_response works" +varnishtest "Check that error in vcl_backend_response works" server s1 { rxreq @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.Foo = "bar"; error 523 "not ok"; } diff --git a/bin/varnishtest/tests/b00019.vtc b/bin/varnishtest/tests/b00019.vtc index 542e32d..d393ab1 100644 --- a/bin/varnishtest/tests/b00019.vtc +++ b/bin/varnishtest/tests/b00019.vtc @@ -21,7 +21,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { return (restart); } diff --git a/bin/varnishtest/tests/b00020.vtc b/bin/varnishtest/tests/b00020.vtc index a6baaed..6b6943d 100644 --- a/bin/varnishtest/tests/b00020.vtc +++ b/bin/varnishtest/tests/b00020.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/b00021.vtc b/bin/varnishtest/tests/b00021.vtc index 331635b..5646183 100644 --- a/bin/varnishtest/tests/b00021.vtc +++ b/bin/varnishtest/tests/b00021.vtc @@ -10,10 +10,10 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_fetch { + sub vcl_backend_fetch { set bereq.between_bytes_timeout = 2s; } - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/b00022.vtc b/bin/varnishtest/tests/b00022.vtc index 9f4dd1e..2201586 100644 --- a/bin/varnishtest/tests/b00022.vtc +++ b/bin/varnishtest/tests/b00022.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl { .port = "${s1_port}"; .between_bytes_timeout = 1s; } - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/b00024.vtc b/bin/varnishtest/tests/b00024.vtc index 421ed0d..30f0466 100644 --- a/bin/varnishtest/tests/b00024.vtc +++ b/bin/varnishtest/tests/b00024.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_fetch { + sub vcl_backend_fetch { set bereq.first_byte_timeout = 1s; } } -start diff --git a/bin/varnishtest/tests/b00026.vtc b/bin/varnishtest/tests/b00026.vtc index 048c58e..14293cc 100644 --- a/bin/varnishtest/tests/b00026.vtc +++ b/bin/varnishtest/tests/b00026.vtc @@ -34,7 +34,7 @@ varnish v1 -vcl { } set req.backend = b2; } - sub vcl_fetch { + sub vcl_backend_fetch { set bereq.first_byte_timeout = 2s; } } -start diff --git a/bin/varnishtest/tests/b00027.vtc b/bin/varnishtest/tests/b00027.vtc index 941dc9c..f1907c0 100644 --- a/bin/varnishtest/tests/b00027.vtc +++ b/bin/varnishtest/tests/b00027.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/b00028.vtc b/bin/varnishtest/tests/b00028.vtc index 6316fde..b91c274 100644 --- a/bin/varnishtest/tests/b00028.vtc +++ b/bin/varnishtest/tests/b00028.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (beresp.http.foo ~ "bar") { set beresp.http.foo1 = "1"; } else { diff --git a/bin/varnishtest/tests/c00001.vtc b/bin/varnishtest/tests/c00001.vtc index bfc9d08..860e827 100644 --- a/bin/varnishtest/tests/c00001.vtc +++ b/bin/varnishtest/tests/c00001.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.Snafu1 = regsub(beresp.http.Foobar, "ar", "\0\0"); set beresp.http.Snafu2 = regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\4\3\2p"); diff --git a/bin/varnishtest/tests/c00009.vtc b/bin/varnishtest/tests/c00009.vtc index 9d5f1a0..e4705bb 100644 --- a/bin/varnishtest/tests/c00009.vtc +++ b/bin/varnishtest/tests/c00009.vtc @@ -21,7 +21,7 @@ varnish v1 -vcl+backend { } } - sub vcl_response { + sub vcl_backend_response { if (beresp.status != 200) { return (restart); } diff --git a/bin/varnishtest/tests/c00011.vtc b/bin/varnishtest/tests/c00011.vtc index 4a1391d..fc0af3d 100644 --- a/bin/varnishtest/tests/c00011.vtc +++ b/bin/varnishtest/tests/c00011.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.uncacheable = true; } } -start diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc index c995511..61654e1 100644 --- a/bin/varnishtest/tests/c00014.vtc +++ b/bin/varnishtest/tests/c00014.vtc @@ -14,7 +14,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.uncacheable = true; } } -start diff --git a/bin/varnishtest/tests/c00027.vtc b/bin/varnishtest/tests/c00027.vtc index 9e842de..88b4217 100644 --- a/bin/varnishtest/tests/c00027.vtc +++ b/bin/varnishtest/tests/c00027.vtc @@ -19,7 +19,7 @@ server s1 { } -start varnish v1 -arg "-s malloc,1M" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 10m; } } -start diff --git a/bin/varnishtest/tests/c00029.vtc b/bin/varnishtest/tests/c00029.vtc index 2eb685b..07111ba 100644 --- a/bin/varnishtest/tests/c00029.vtc +++ b/bin/varnishtest/tests/c00029.vtc @@ -37,7 +37,7 @@ varnish v1 -arg "-p saintmode_threshold=2" -vcl+backend { set req.grace = 1h; } - sub vcl_response { + sub vcl_backend_response { if (beresp.http.X-Saint == "yes") { set beresp.saintmode = 20s; return(restart); diff --git a/bin/varnishtest/tests/c00030.vtc b/bin/varnishtest/tests/c00030.vtc index 8941a45..9cfec57 100644 --- a/bin/varnishtest/tests/c00030.vtc +++ b/bin/varnishtest/tests/c00030.vtc @@ -44,7 +44,7 @@ varnish v1 -arg "-p saintmode_threshold=10" -vcl { set req.grace = 1h; } - sub vcl_response { + sub vcl_backend_response { if (beresp.http.X-Saint == "yes") { set beresp.saintmode = 20s; return (restart); diff --git a/bin/varnishtest/tests/c00032.vtc b/bin/varnishtest/tests/c00032.vtc index eb7e57c..a3b5c92 100644 --- a/bin/varnishtest/tests/c00032.vtc +++ b/bin/varnishtest/tests/c00032.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { } } - sub vcl_response { + sub vcl_backend_response { if (beresp.status == 400) { rollback; set req.url = "/bar"; diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index ad6d3c6..d75ecbb 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -16,7 +16,7 @@ server s1 { } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "invalid"; } } -start diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index a480fe1..b150770 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "s0"; } } -start diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index 17fb33b..ad2b701 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "s0"; } } -start diff --git a/bin/varnishtest/tests/c00047.vtc b/bin/varnishtest/tests/c00047.vtc index d9e4ee2..e2ec54e 100644 --- a/bin/varnishtest/tests/c00047.vtc +++ b/bin/varnishtest/tests/c00047.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.baz1 = regsuball(beresp.http.foo, "barb", "zz"); set beresp.http.baz2 = regsuball(beresp.http.foo, "ar", "zz"); set beresp.http.baz3 = regsuball(beresp.http.foo, "^", "baz"); diff --git a/bin/varnishtest/tests/c00055.vtc b/bin/varnishtest/tests/c00055.vtc index 15590d3..b7c93a4 100644 --- a/bin/varnishtest/tests/c00055.vtc +++ b/bin/varnishtest/tests/c00055.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl+backend { C{ VRT_CacheReqBody(req, 1000); }C return (pass); } - sub vcl_response { + sub vcl_backend_response { if (beresp.http.foo == "BAR") { return (restart); } diff --git a/bin/varnishtest/tests/e00000.vtc b/bin/varnishtest/tests/e00000.vtc index 2de8f23..157dea5 100644 --- a/bin/varnishtest/tests/e00000.vtc +++ b/bin/varnishtest/tests/e00000.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00001.vtc b/bin/varnishtest/tests/e00001.vtc index 13312d3..e988fb5 100644 --- a/bin/varnishtest/tests/e00001.vtc +++ b/bin/varnishtest/tests/e00001.vtc @@ -14,7 +14,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start -cliok "param.set esi_syntax 4" diff --git a/bin/varnishtest/tests/e00002.vtc b/bin/varnishtest/tests/e00002.vtc index 8aa223f..ebebf62 100644 --- a/bin/varnishtest/tests/e00002.vtc +++ b/bin/varnishtest/tests/e00002.vtc @@ -13,7 +13,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00003.vtc b/bin/varnishtest/tests/e00003.vtc index 6a8ea92..a79ac57 100644 --- a/bin/varnishtest/tests/e00003.vtc +++ b/bin/varnishtest/tests/e00003.vtc @@ -22,7 +22,7 @@ varnish v1 -vcl+backend { set req.url = req.url + req.esi_level; } } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00004.vtc b/bin/varnishtest/tests/e00004.vtc index 9a95dac..e6ae26f 100644 --- a/bin/varnishtest/tests/e00004.vtc +++ b/bin/varnishtest/tests/e00004.vtc @@ -17,7 +17,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00005.vtc b/bin/varnishtest/tests/e00005.vtc index 7f5c333..441362c 100644 --- a/bin/varnishtest/tests/e00005.vtc +++ b/bin/varnishtest/tests/e00005.vtc @@ -18,7 +18,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc index 3b9c6db..1bd6cf3 100644 --- a/bin/varnishtest/tests/e00006.vtc +++ b/bin/varnishtest/tests/e00006.vtc @@ -29,7 +29,7 @@ varnish v1 -vcl+backend { set req.backend = s1; } } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00007.vtc b/bin/varnishtest/tests/e00007.vtc index 225ec3c..729ff84 100644 --- a/bin/varnishtest/tests/e00007.vtc +++ b/bin/varnishtest/tests/e00007.vtc @@ -32,7 +32,7 @@ server s1 { } -start varnish v1 -storage "-smalloc,2m" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00008.vtc b/bin/varnishtest/tests/e00008.vtc index 4af581f..53545d6 100644 --- a/bin/varnishtest/tests/e00008.vtc +++ b/bin/varnishtest/tests/e00008.vtc @@ -56,7 +56,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00009.vtc b/bin/varnishtest/tests/e00009.vtc index 099d1b9..e2ef6b3 100644 --- a/bin/varnishtest/tests/e00009.vtc +++ b/bin/varnishtest/tests/e00009.vtc @@ -18,7 +18,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00010.vtc b/bin/varnishtest/tests/e00010.vtc index 1a0b33d..513a99a 100644 --- a/bin/varnishtest/tests/e00010.vtc +++ b/bin/varnishtest/tests/e00010.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start -cli "param.set esi_syntax 2" diff --git a/bin/varnishtest/tests/e00011.vtc b/bin/varnishtest/tests/e00011.vtc index 6c0a8ef..7dd2d14 100644 --- a/bin/varnishtest/tests/e00011.vtc +++ b/bin/varnishtest/tests/e00011.vtc @@ -16,7 +16,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.uncacheable = true; set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/e00012.vtc b/bin/varnishtest/tests/e00012.vtc index 60cc4d1..3cd8db6 100644 --- a/bin/varnishtest/tests/e00012.vtc +++ b/bin/varnishtest/tests/e00012.vtc @@ -17,7 +17,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00013.vtc b/bin/varnishtest/tests/e00013.vtc index b659e53..a8a6028 100644 --- a/bin/varnishtest/tests/e00013.vtc +++ b/bin/varnishtest/tests/e00013.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00014.vtc b/bin/varnishtest/tests/e00014.vtc index d174650..7021c95 100644 --- a/bin/varnishtest/tests/e00014.vtc +++ b/bin/varnishtest/tests/e00014.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index 5acf6bc..3d3e146 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -23,7 +23,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if(req.url == "/") { set req.esi = false; } diff --git a/bin/varnishtest/tests/e00016.vtc b/bin/varnishtest/tests/e00016.vtc index 718c690..44f7d6a 100644 --- a/bin/varnishtest/tests/e00016.vtc +++ b/bin/varnishtest/tests/e00016.vtc @@ -27,7 +27,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set req.esi = true; if(req.url == "/body") { set req.esi = false; diff --git a/bin/varnishtest/tests/e00017.vtc b/bin/varnishtest/tests/e00017.vtc index 0eedd1d..121662e 100644 --- a/bin/varnishtest/tests/e00017.vtc +++ b/bin/varnishtest/tests/e00017.vtc @@ -71,7 +71,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00018.vtc b/bin/varnishtest/tests/e00018.vtc index 6b709db..4a410cd 100644 --- a/bin/varnishtest/tests/e00018.vtc +++ b/bin/varnishtest/tests/e00018.vtc @@ -36,7 +36,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00019.vtc b/bin/varnishtest/tests/e00019.vtc index a45ed76..5731647 100644 --- a/bin/varnishtest/tests/e00019.vtc +++ b/bin/varnishtest/tests/e00019.vtc @@ -29,7 +29,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "bar") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/e00020.vtc b/bin/varnishtest/tests/e00020.vtc index 5a20356..55d6923 100644 --- a/bin/varnishtest/tests/e00020.vtc +++ b/bin/varnishtest/tests/e00020.vtc @@ -14,7 +14,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gunzip = true; } diff --git a/bin/varnishtest/tests/e00021.vtc b/bin/varnishtest/tests/e00021.vtc index 02bd4e8..26acd2c 100644 --- a/bin/varnishtest/tests/e00021.vtc +++ b/bin/varnishtest/tests/e00021.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.esi = true; } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gzip = true; } diff --git a/bin/varnishtest/tests/e00022.vtc b/bin/varnishtest/tests/e00022.vtc index fc45ed3..be980c5 100644 --- a/bin/varnishtest/tests/e00022.vtc +++ b/bin/varnishtest/tests/e00022.vtc @@ -18,7 +18,7 @@ varnish v1 -arg "-p thread_pool_stack=262144" -vcl+backend { sub vcl_recv { set req.esi = true; } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00023.vtc b/bin/varnishtest/tests/e00023.vtc index 47dec0f..2508c9c 100644 --- a/bin/varnishtest/tests/e00023.vtc +++ b/bin/varnishtest/tests/e00023.vtc @@ -36,7 +36,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/e00024.vtc b/bin/varnishtest/tests/e00024.vtc index b99d296..ea9f6c4 100644 --- a/bin/varnishtest/tests/e00024.vtc +++ b/bin/varnishtest/tests/e00024.vtc @@ -60,7 +60,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/e00026.vtc b/bin/varnishtest/tests/e00026.vtc index 39c3de0..6d2e50c 100644 --- a/bin/varnishtest/tests/e00026.vtc +++ b/bin/varnishtest/tests/e00026.vtc @@ -28,7 +28,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url != "/foo") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/e00027.vtc b/bin/varnishtest/tests/e00027.vtc index b977004..eac20d3 100644 --- a/bin/varnishtest/tests/e00027.vtc +++ b/bin/varnishtest/tests/e00027.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc index 1ddd9ec..5605b25 100644 --- a/bin/varnishtest/tests/g00002.vtc +++ b/bin/varnishtest/tests/g00002.vtc @@ -17,7 +17,7 @@ varnish v1 \ -cliok "param.set gzip_memlevel 1" \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc index 0721dc4..a4dfa7e 100644 --- a/bin/varnishtest/tests/g00003.vtc +++ b/bin/varnishtest/tests/g00003.vtc @@ -19,7 +19,7 @@ server s1 { varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_gunzip = true; if (req.url == "/foobar") { set beresp.do_gzip = true; diff --git a/bin/varnishtest/tests/g00004.vtc b/bin/varnishtest/tests/g00004.vtc index d70e146..286fc98 100644 --- a/bin/varnishtest/tests/g00004.vtc +++ b/bin/varnishtest/tests/g00004.vtc @@ -19,7 +19,7 @@ server s1 -repeat 2 { varnish v1 \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; if (req.url == "/gunzip") { diff --git a/bin/varnishtest/tests/m00002.vtc b/bin/varnishtest/tests/m00002.vtc index 414bbdb..f95bee8 100644 --- a/bin/varnishtest/tests/m00002.vtc +++ b/bin/varnishtest/tests/m00002.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 -vcl+backend { import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; - sub vcl_response { + sub vcl_backend_response { set beresp.http.rnd1 = std.random(0,1); set beresp.http.rnd2 = std.random(0,10); set beresp.http.rnd3 = std.random(8,10); diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index b1a57a8..740ba38 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -18,10 +18,10 @@ varnish v1 -vcl+backend { sub vcl_recv { std.collect(req.http.foo); } - sub vcl_fetch { + sub vcl_backend_fetch { std.collect(bereq.http.baz); } - sub vcl_response { + sub vcl_backend_response { std.collect(beresp.http.bar); } sub vcl_deliver { diff --git a/bin/varnishtest/tests/p00005.vtc b/bin/varnishtest/tests/p00005.vtc index ef2b5a1..a3d7051 100644 --- a/bin/varnishtest/tests/p00005.vtc +++ b/bin/varnishtest/tests/p00005.vtc @@ -11,7 +11,7 @@ varnish v1 \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 3s; } } -start @@ -37,7 +37,7 @@ server s1 -wait { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 3s; } } -start diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc index 395f9c6..07d6c2c 100644 --- a/bin/varnishtest/tests/p00008.vtc +++ b/bin/varnishtest/tests/p00008.vtc @@ -18,7 +18,7 @@ varnish v1 \ -arg "-pban_lurker_sleep=0" \ -storage "-sper1=persistent,${tmpdir}/_.per1,10m -sper2=persistent,${tmpdir}/_.per2,10m" \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "per1"; if (req.url ~ "silo2") { set beresp.storage = "per2"; diff --git a/bin/varnishtest/tests/r00251.vtc b/bin/varnishtest/tests/r00251.vtc index 6794c24..a337cce 100644 --- a/bin/varnishtest/tests/r00251.vtc +++ b/bin/varnishtest/tests/r00251.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.Snafu1 = "zoom" + regsub(beresp.http.Foomble, "ar", "\0\0") + diff --git a/bin/varnishtest/tests/r00318.vtc b/bin/varnishtest/tests/r00318.vtc index 86b7672..a30bdab 100644 --- a/bin/varnishtest/tests/r00318.vtc +++ b/bin/varnishtest/tests/r00318.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.uncacheable = true; } diff --git a/bin/varnishtest/tests/r00326.vtc b/bin/varnishtest/tests/r00326.vtc index f37d656..09cd013 100644 --- a/bin/varnishtest/tests/r00326.vtc +++ b/bin/varnishtest/tests/r00326.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00345.vtc b/bin/varnishtest/tests/r00345.vtc index 6cdfe1d..772c60f 100644 --- a/bin/varnishtest/tests/r00345.vtc +++ b/bin/varnishtest/tests/r00345.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -arg "-p debug=+workspace" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/r00386.vtc b/bin/varnishtest/tests/r00386.vtc index 21d944a..3edcb35 100644 --- a/bin/varnishtest/tests/r00386.vtc +++ b/bin/varnishtest/tests/r00386.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -arg "-p debug=+workspace" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/r00387.vtc b/bin/varnishtest/tests/r00387.vtc index eb6a366..879657c 100644 --- a/bin/varnishtest/tests/r00387.vtc +++ b/bin/varnishtest/tests/r00387.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/r00411.vtc b/bin/varnishtest/tests/r00411.vtc index bab8eef..3d1e832 100644 --- a/bin/varnishtest/tests/r00411.vtc +++ b/bin/varnishtest/tests/r00411.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { return (restart); } } - sub vcl_response { + sub vcl_backend_response { if (beresp.status == 303) { set beresp.ttl = 3m; set beresp.http.X-Magic-Redirect = "1"; diff --git a/bin/varnishtest/tests/r00412.vtc b/bin/varnishtest/tests/r00412.vtc index 2d3c69a..0e49607 100644 --- a/bin/varnishtest/tests/r00412.vtc +++ b/bin/varnishtest/tests/r00412.vtc @@ -11,7 +11,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (beresp.status == 303) { set beresp.ttl = 60 s; set beresp.http.X-Magic-Redirect = "1"; diff --git a/bin/varnishtest/tests/r00427.vtc b/bin/varnishtest/tests/r00427.vtc index 3d8c9ce..aa7d6ae 100644 --- a/bin/varnishtest/tests/r00427.vtc +++ b/bin/varnishtest/tests/r00427.vtc @@ -24,7 +24,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00433.vtc b/bin/varnishtest/tests/r00433.vtc index d0e6ba8..2ccbd3f 100644 --- a/bin/varnishtest/tests/r00433.vtc +++ b/bin/varnishtest/tests/r00433.vtc @@ -31,7 +31,7 @@ varnish v1 -vcl+backend { } } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00445.vtc b/bin/varnishtest/tests/r00445.vtc index 535107d..137ab15 100644 --- a/bin/varnishtest/tests/r00445.vtc +++ b/bin/varnishtest/tests/r00445.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00476.vtc b/bin/varnishtest/tests/r00476.vtc index d9e1c9e..976d434 100644 --- a/bin/varnishtest/tests/r00476.vtc +++ b/bin/varnishtest/tests/r00476.vtc @@ -16,7 +16,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00494.vtc b/bin/varnishtest/tests/r00494.vtc index 23c5695..31a9d6e 100644 --- a/bin/varnishtest/tests/r00494.vtc +++ b/bin/varnishtest/tests/r00494.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.bar = beresp.http.foo; remove beresp.http.foo; } diff --git a/bin/varnishtest/tests/r00524.vtc b/bin/varnishtest/tests/r00524.vtc index d52e331..46445a8 100644 --- a/bin/varnishtest/tests/r00524.vtc +++ b/bin/varnishtest/tests/r00524.vtc @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { sub vcl_recv { // return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -cliok "param.set timeout_idle 60" -start diff --git a/bin/varnishtest/tests/r00590.vtc b/bin/varnishtest/tests/r00590.vtc index 74d77bc..960ebd1 100644 --- a/bin/varnishtest/tests/r00590.vtc +++ b/bin/varnishtest/tests/r00590.vtc @@ -60,7 +60,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00612.vtc b/bin/varnishtest/tests/r00612.vtc index 189b720..d36e5a0 100644 --- a/bin/varnishtest/tests/r00612.vtc +++ b/bin/varnishtest/tests/r00612.vtc @@ -36,7 +36,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00641.vtc b/bin/varnishtest/tests/r00641.vtc index 94a15b9..7fefc8e 100644 --- a/bin/varnishtest/tests/r00641.vtc +++ b/bin/varnishtest/tests/r00641.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl+backend { sub vcl_recv { // return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -cliok "param.set timeout_idle 60" -start diff --git a/bin/varnishtest/tests/r00667.vtc b/bin/varnishtest/tests/r00667.vtc index f428e6a..1c1da1f 100644 --- a/bin/varnishtest/tests/r00667.vtc +++ b/bin/varnishtest/tests/r00667.vtc @@ -16,7 +16,7 @@ server s1 { varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 0s; } } -start diff --git a/bin/varnishtest/tests/r00702.vtc b/bin/varnishtest/tests/r00702.vtc index 9ac03cf..3a8b320 100644 --- a/bin/varnishtest/tests/r00702.vtc +++ b/bin/varnishtest/tests/r00702.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/r00704.vtc b/bin/varnishtest/tests/r00704.vtc index 5d0585c..d4e44be 100644 --- a/bin/varnishtest/tests/r00704.vtc +++ b/bin/varnishtest/tests/r00704.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/r00769.vtc b/bin/varnishtest/tests/r00769.vtc index 1f75ad9..2306346 100644 --- a/bin/varnishtest/tests/r00769.vtc +++ b/bin/varnishtest/tests/r00769.vtc @@ -11,7 +11,7 @@ varnish v1 -vcl+backend { error 700; } } - sub vcl_response { + sub vcl_backend_response { set beresp.status = 404; set beresp.http.X-status = beresp.status; return (deliver); diff --git a/bin/varnishtest/tests/r00781.vtc b/bin/varnishtest/tests/r00781.vtc index 52738e5..d58bf29 100644 --- a/bin/varnishtest/tests/r00781.vtc +++ b/bin/varnishtest/tests/r00781.vtc @@ -9,7 +9,7 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.url = req.http.foo; } - sub vcl_fetch { + sub vcl_backend_fetch { set bereq.url = req.http.foo; } } -start diff --git a/bin/varnishtest/tests/r00801.vtc b/bin/varnishtest/tests/r00801.vtc index d7b293f..5800662 100644 --- a/bin/varnishtest/tests/r00801.vtc +++ b/bin/varnishtest/tests/r00801.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/r00861.vtc b/bin/varnishtest/tests/r00861.vtc index cfdaca0..ff6b042 100644 --- a/bin/varnishtest/tests/r00861.vtc +++ b/bin/varnishtest/tests/r00861.vtc @@ -23,7 +23,7 @@ server s1 { varnish v1 \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/1" || req.url == "/2") { set beresp.do_esi = true; set beresp.do_gzip = true; diff --git a/bin/varnishtest/tests/r00873.vtc b/bin/varnishtest/tests/r00873.vtc index 00e1413..7612ad4 100644 --- a/bin/varnishtest/tests/r00873.vtc +++ b/bin/varnishtest/tests/r00873.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gzip = true; } diff --git a/bin/varnishtest/tests/r00894.vtc b/bin/varnishtest/tests/r00894.vtc index 23f0cb4..39b8fba 100644 --- a/bin/varnishtest/tests/r00894.vtc +++ b/bin/varnishtest/tests/r00894.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00913.vtc b/bin/varnishtest/tests/r00913.vtc index 6d5a54c..3e8672d 100644 --- a/bin/varnishtest/tests/r00913.vtc +++ b/bin/varnishtest/tests/r00913.vtc @@ -7,7 +7,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (beresp.http.bar ~ "$") { set beresp.http.foo = regsub(beresp.http.bar, "$", "XXX"); } diff --git a/bin/varnishtest/tests/r00915.vtc b/bin/varnishtest/tests/r00915.vtc index 1c0c21c..c7aacc8 100644 --- a/bin/varnishtest/tests/r00915.vtc +++ b/bin/varnishtest/tests/r00915.vtc @@ -12,7 +12,7 @@ varnish v1 \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { error(751); } } -start diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc index 51339b4..2b3a9e0 100644 --- a/bin/varnishtest/tests/r00916.vtc +++ b/bin/varnishtest/tests/r00916.vtc @@ -9,7 +9,7 @@ varnish v1 -errvcl {Symbol not found: 's-1' (expected type BACKEND)} { backend b { .host = "127.0.0.1"; } sub s1 { } - sub vcl_response { + sub vcl_backend_response { if (req.backend == s-1){ set req.backend = s-1; } diff --git a/bin/varnishtest/tests/r00941.vtc b/bin/varnishtest/tests/r00941.vtc index f6ee1a6..127336e 100644 --- a/bin/varnishtest/tests/r00941.vtc +++ b/bin/varnishtest/tests/r00941.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 1000s; } } -start diff --git a/bin/varnishtest/tests/r00942.vtc b/bin/varnishtest/tests/r00942.vtc index ffde262..e6c45b0 100644 --- a/bin/varnishtest/tests/r00942.vtc +++ b/bin/varnishtest/tests/r00942.vtc @@ -26,7 +26,7 @@ server s1 { varnish v1 \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; } } diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc index 33e5198..6c53905 100644 --- a/bin/varnishtest/tests/r00956.vtc +++ b/bin/varnishtest/tests/r00956.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 10s; set req.http.foo = beresp.ttl; set req.http.bar = "xxx"; diff --git a/bin/varnishtest/tests/r00961.vtc b/bin/varnishtest/tests/r00961.vtc index 7f7c4f7..c6e9209 100644 --- a/bin/varnishtest/tests/r00961.vtc +++ b/bin/varnishtest/tests/r00961.vtc @@ -36,7 +36,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r00962.vtc b/bin/varnishtest/tests/r00962.vtc index 77ea57e..21f01a8 100644 --- a/bin/varnishtest/tests/r00962.vtc +++ b/bin/varnishtest/tests/r00962.vtc @@ -14,7 +14,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "s0"; } } -start diff --git a/bin/varnishtest/tests/r00972.vtc b/bin/varnishtest/tests/r00972.vtc index f6d071c..da23127 100644 --- a/bin/varnishtest/tests/r00972.vtc +++ b/bin/varnishtest/tests/r00972.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = true; } } -start diff --git a/bin/varnishtest/tests/r01029.vtc b/bin/varnishtest/tests/r01029.vtc index 8e3064c..e388043 100644 --- a/bin/varnishtest/tests/r01029.vtc +++ b/bin/varnishtest/tests/r01029.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; if (req.url == "/foo") { set beresp.ttl = 0s; diff --git a/bin/varnishtest/tests/r01030.vtc b/bin/varnishtest/tests/r01030.vtc index db58d32..7ebd036 100644 --- a/bin/varnishtest/tests/r01030.vtc +++ b/bin/varnishtest/tests/r01030.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { } return (lookup); } - sub vcl_response { + sub vcl_backend_response { set beresp.http.url = req.url; } } -start diff --git a/bin/varnishtest/tests/r01036.vtc b/bin/varnishtest/tests/r01036.vtc index dfd4402..10f6920 100644 --- a/bin/varnishtest/tests/r01036.vtc +++ b/bin/varnishtest/tests/r01036.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -arg "-smalloc,1M" -arg "-pgzip_level=0" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_stream = false; set beresp.do_gzip = true; } diff --git a/bin/varnishtest/tests/r01037.vtc b/bin/varnishtest/tests/r01037.vtc index 46ec9d4..3d1518f 100644 --- a/bin/varnishtest/tests/r01037.vtc +++ b/bin/varnishtest/tests/r01037.vtc @@ -15,7 +15,7 @@ server s1 { } -start varnish v1 -arg "-smalloc,1M" -arg "-pgzip_level=0" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gzip = true; } diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index d7d438c..ea04142 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -46,7 +46,7 @@ server s1 { } -start varnish v1 -arg "-p workspace_backend=8k" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r01091.vtc b/bin/varnishtest/tests/r01091.vtc index 2b1fff3..dbf3820 100644 --- a/bin/varnishtest/tests/r01091.vtc +++ b/bin/varnishtest/tests/r01091.vtc @@ -25,7 +25,7 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.backend = f1.backend(); } - sub vcl_response { + sub vcl_backend_response { if(req.restarts < 1) { set beresp.saintmode = 1h; return(restart); diff --git a/bin/varnishtest/tests/r01092.vtc b/bin/varnishtest/tests/r01092.vtc index 4311b73..59aacf3 100644 --- a/bin/varnishtest/tests/r01092.vtc +++ b/bin/varnishtest/tests/r01092.vtc @@ -19,7 +19,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start -cliok "param.set esi_syntax 4" diff --git a/bin/varnishtest/tests/r01109.vtc b/bin/varnishtest/tests/r01109.vtc index 479786c..3b0fd23 100644 --- a/bin/varnishtest/tests/r01109.vtc +++ b/bin/varnishtest/tests/r01109.vtc @@ -22,7 +22,7 @@ server s1 { } -start varnish v1 -arg "-pfetch_chunksize=4k" -arg "-pgzip_level=0" -arg "-pthread_pool_stack=131072" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url ~ "/test") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/r01113.vtc b/bin/varnishtest/tests/r01113.vtc index 5bf31c1..dc71417 100644 --- a/bin/varnishtest/tests/r01113.vtc +++ b/bin/varnishtest/tests/r01113.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { return(restart); } } - sub vcl_response { + sub vcl_backend_response { if (req.url == "/fetch") { return(restart); } diff --git a/bin/varnishtest/tests/r01123.vtc b/bin/varnishtest/tests/r01123.vtc index 6881d60..a979fe6 100644 --- a/bin/varnishtest/tests/r01123.vtc +++ b/bin/varnishtest/tests/r01123.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { if (req.url == "/") { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/r01157.vtc b/bin/varnishtest/tests/r01157.vtc index ae30994..5815afe 100644 --- a/bin/varnishtest/tests/r01157.vtc +++ b/bin/varnishtest/tests/r01157.vtc @@ -12,7 +12,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { set beresp.do_stream = true; } + sub vcl_backend_response { set beresp.do_stream = true; } } -start client c1 { diff --git a/bin/varnishtest/tests/r01168.vtc b/bin/varnishtest/tests/r01168.vtc index 52a8827..e26b2ce 100644 --- a/bin/varnishtest/tests/r01168.vtc +++ b/bin/varnishtest/tests/r01168.vtc @@ -14,7 +14,7 @@ varnish v1 -vcl+backend { sub vcl_recv { rollback; } - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index a286de6..afb5642 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -storage "-s test=malloc,1M" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "test"; } } -start diff --git a/bin/varnishtest/tests/r01184.vtc b/bin/varnishtest/tests/r01184.vtc index 5c9de55..6eb07ed 100644 --- a/bin/varnishtest/tests/r01184.vtc +++ b/bin/varnishtest/tests/r01184.vtc @@ -32,7 +32,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } -start @@ -64,7 +64,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; } } @@ -95,7 +95,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.do_esi = true; set beresp.do_gunzip = true; } diff --git a/bin/varnishtest/tests/r01206.vtc b/bin/varnishtest/tests/r01206.vtc index 35aa8af..78e00b4 100644 --- a/bin/varnishtest/tests/r01206.vtc +++ b/bin/varnishtest/tests/r01206.vtc @@ -39,7 +39,7 @@ client c1 { server s1 -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.uncacheable = true; } } diff --git a/bin/varnishtest/tests/r01253.vtc b/bin/varnishtest/tests/r01253.vtc index 869f0a6..ce348ae 100644 --- a/bin/varnishtest/tests/r01253.vtc +++ b/bin/varnishtest/tests/r01253.vtc @@ -1,4 +1,4 @@ -varnishtest "restarting a pass in vcl_response should not panic" +varnishtest "restarting a pass in vcl_backend_response should not panic" server s1 { rxreq @@ -12,7 +12,7 @@ varnish v1 -vcl+backend { sub vcl_recv { return (pass); } - sub vcl_response { + sub vcl_backend_response { if (beresp.status != 200) { return (restart); } diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc index 3b1bd83..eaa7b81 100644 --- a/bin/varnishtest/tests/r01283.vtc +++ b/bin/varnishtest/tests/r01283.vtc @@ -11,7 +11,7 @@ varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend error 500; } } - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "Transient"; } } -start diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index c48ea44..7035536 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -10,7 +10,7 @@ server s1 { } -start varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.storage = "Transient"; } } -start diff --git a/bin/varnishtest/tests/s00002.vtc b/bin/varnishtest/tests/s00002.vtc index 4759635..f4cca57 100644 --- a/bin/varnishtest/tests/s00002.vtc +++ b/bin/varnishtest/tests/s00002.vtc @@ -47,7 +47,7 @@ varnish v1 -vcl { .initial = 0; } } - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 1s; set beresp.grace = 1m; } diff --git a/bin/varnishtest/tests/s00003.vtc b/bin/varnishtest/tests/s00003.vtc index 09f8572..35fc3d2 100644 --- a/bin/varnishtest/tests/s00003.vtc +++ b/bin/varnishtest/tests/s00003.vtc @@ -16,7 +16,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 1s; set beresp.grace = 10m; if (beresp.http.foo == "2") diff --git a/bin/varnishtest/tests/v00000.vtc b/bin/varnishtest/tests/v00000.vtc index a9a02b1..4041d61 100644 --- a/bin/varnishtest/tests/v00000.vtc +++ b/bin/varnishtest/tests/v00000.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.grace += 1 s; } - sub vcl_response { + sub vcl_backend_response { set beresp.ttl += 1 m; set beresp.grace += 1 h; } diff --git a/bin/varnishtest/tests/v00001.vtc b/bin/varnishtest/tests/v00001.vtc index 2f0d47c..ebe802b 100644 --- a/bin/varnishtest/tests/v00001.vtc +++ b/bin/varnishtest/tests/v00001.vtc @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { set req.proto = "HTTP/1.2"; set req.method = "GET"; } - sub vcl_fetch { + sub vcl_backend_fetch { set bereq.http.foobar = bereq.url + bereq.proto; @@ -26,7 +26,7 @@ varnish v1 -vcl+backend { set bereq.proto = "HTTP/1.2"; set bereq.method = "GET"; } - sub vcl_response { + sub vcl_backend_response { set beresp.http.foobar = beresp.proto + beresp.response + beresp.status; set beresp.proto = "HTTP/1.2"; diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index d08dcc1..c5f8fa5 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -25,7 +25,7 @@ varnish v1 -storage "-smalloc,1m" -vcl+backend { import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; - sub vcl_response { + sub vcl_backend_response { if (beresp.http.panic == "fetch") { debug.panic("Had Panic header: " + beresp.http.panic); } diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 50f82d2..eb5f3d5 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -60,7 +60,7 @@ varnish v1 -vcl { backend b { .host = "127.0.0.1"; } /* test time and backend comparison */ - sub vcl_response { + sub vcl_backend_response { if (beresp.ttl > 1d) { set beresp.ttl = 1d; } @@ -75,12 +75,12 @@ varnish v1 -vcl { varnish v1 -errvcl {Unknown time unit 'k'. Legal are 's', 'm', 'h' and 'd'} { backend b { .host = "127.0.0.1"; } - sub vcl_response { set obj.ttl = 1. k; } + sub vcl_backend_response { set obj.ttl = 1. k; } } varnish v1 -errvcl {Expression has type DURATION, expected BOOL} { backend b { .host = "127.0.0.1"; } - sub vcl_response { if (obj.ttl *= 2) { } } + sub vcl_backend_response { if (obj.ttl *= 2) { } } } varnish v1 -errvcl {Operator > not possible on BACKEND} { diff --git a/bin/varnishtest/tests/v00017.vtc b/bin/varnishtest/tests/v00017.vtc index 71d9dd5..29b1bfb 100644 --- a/bin/varnishtest/tests/v00017.vtc +++ b/bin/varnishtest/tests/v00017.vtc @@ -67,7 +67,7 @@ varnish v1 -vcl { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } sub vcl_recv { if (client.ip == "127.0.0.1") { return(pass); } } - sub vcl_fetch { if (client.ip != "127.0.0.1") { return(pass); } } + sub vcl_backend_fetch { if (client.ip != "127.0.0.1") { return(pass); } } } varnish v1 -errvcl {Operator > not possible on IP} { diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index 181e823..2553638 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -8,14 +8,14 @@ varnish v1 -vcl { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { error beresp.status ; } + sub vcl_backend_response { error beresp.status ; } } varnish v1 -vcl { backend b { .host = "127.0.0.1"; } sub vcl_miss { error 100 req.url ; } sub vcl_pass { error 100 "the butter please" ; } - sub vcl_response { error beresp.status req.url; } + sub vcl_backend_response { error beresp.status req.url; } } varnish v1 -errvcl {Variable 'server.port' is read only.} { @@ -25,12 +25,12 @@ varnish v1 -errvcl {Variable 'server.port' is read only.} { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.ttl /= 2; } + sub vcl_backend_response { set beresp.ttl /= 2; } } varnish v1 -errvcl {Expected '=' got '>>'} { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.ttl >>= 2; } + sub vcl_backend_response { set beresp.ttl >>= 2; } } varnish v1 -errvcl {Expected '=' got '+='} { @@ -61,27 +61,27 @@ varnish v1 -vcl { varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.do_gzip += 1; } + sub vcl_backend_response { set beresp.do_gzip += 1; } } varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.do_gzip = true; } + sub vcl_backend_response { set beresp.do_gzip = true; } } varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.do_gzip = false; } + sub vcl_backend_response { set beresp.do_gzip = false; } } varnish v1 -errvcl {Symbol not found: 'mu' (expected type BOOL):} { backend b { .host = "127.0.0.1"; } - sub vcl_response { set beresp.do_gzip = mu; } + sub vcl_backend_response { set beresp.do_gzip = mu; } } varnish v1 -errvcl {Only http header variables can be unset.} { backend b { .host = "127.0.0.1"; } - sub vcl_response { unset beresp.do_gzip; } + sub vcl_backend_response { unset beresp.do_gzip; } } varnish v1 -errvcl {Unknown token '<<' when looking for STRING} { diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 87227d3..2977c85 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -24,7 +24,7 @@ varnish v1 -errvcl {Expected an action, 'if', } " sub vcl_recv { { } { " varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { + sub vcl_backend_response { set beresp.ttl = 1w; set beresp.ttl *= 1.5; set beresp.ttl = 1.5 s * 2.5; @@ -73,20 +73,20 @@ varnish v1 -errvcl {Operator * not possible on type STRING.} { } varnish v1 -errvcl {DURATION + INT not possible.} { - sub vcl_response { + sub vcl_backend_response { set req.http.foo = req.grace + beresp.status; } } varnish v1 -errvcl {'!' must be followed by BOOL, found DURATION.} { - sub vcl_response { + sub vcl_backend_response { if (! req.grace) { } } } varnish v1 -errvcl {Operator + not possible on type BOOL.} { - sub vcl_response { + sub vcl_backend_response { if (beresp.do_gzip + beresp.do_gunzip) { } } @@ -226,7 +226,7 @@ varnish v1 -errvcl {DURATION + STRING not possible.} { varnish v1 -errvcl {'||' must be followed by BOOL, found DURATION.} { backend b { .host = "127.0.0.1"; } - sub vcl_response { + sub vcl_backend_response { if (req.url || beresp.ttl) { } } @@ -234,7 +234,7 @@ varnish v1 -errvcl {'||' must be followed by BOOL, found DURATION.} { varnish v1 -errvcl {'&&' must be followed by BOOL, found DURATION.} { backend b { .host = "127.0.0.1"; } - sub vcl_response { + sub vcl_backend_response { if (req.url && beresp.ttl) { } } @@ -242,7 +242,7 @@ varnish v1 -errvcl {'&&' must be followed by BOOL, found DURATION.} { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } - sub vcl_response { + sub vcl_backend_response { if (!req.url) { } } diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index a90c3a2..dd3a303 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -16,7 +16,7 @@ sub vcl_deliver { set resp.http.server_port = server.port; } -sub vcl_response { +sub vcl_backend_response { if (req.esi) { set beresp.http.esi = "yes"; } @@ -41,7 +41,7 @@ sub vcl_lookup { } } -sub vcl_fetch { +sub vcl_backend_fetch { if (bereq.between_bytes_timeout < 10s) { set bereq.http.quick = "please"; } diff --git a/bin/varnishtest/tests/v00032.vtc b/bin/varnishtest/tests/v00032.vtc index f18adaa..f9adb77 100644 --- a/bin/varnishtest/tests/v00032.vtc +++ b/bin/varnishtest/tests/v00032.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.has_s0 = storage.s0; set beresp.http.has_foo = storage.foo; set beresp.http.has_Transient = storage.Transient; diff --git a/bin/varnishtest/tests/v00033.vtc b/bin/varnishtest/tests/v00033.vtc index 504ad5a..4494c32 100644 --- a/bin/varnishtest/tests/v00033.vtc +++ b/bin/varnishtest/tests/v00033.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 -vcl+backend { - sub vcl_response { + sub vcl_backend_response { set beresp.http.foo = storage.nowhere.free_space + 1 B + 1 KB + 1 MB + 1GB + 1TB; diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index f8c506b..5df3fd8 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -78,18 +78,18 @@ tokens = { # Our methods and actions returns =( - ('recv', ('error', 'pass', 'pipe', 'lookup',)), - ('pipe', ('error', 'pipe',)), - ('pass', ('error', 'restart', 'pass',)), - ('hash', ('hash',)), - ('miss', ('error', 'restart', 'pass', 'fetch',)), - ('lookup', ('error', 'restart', 'pass', 'deliver',)), - ('fetch', ('error', 'fetch', 'pass',)), - ('response', ('error', 'restart', 'deliver',)), - ('deliver', ('restart', 'deliver',)), - ('error', ('restart', 'deliver',)), - ('init', ('ok',)), - ('fini', ('ok',)), + ('recv', ('error', 'pass', 'pipe', 'lookup',)), + ('pipe', ('error', 'pipe',)), + ('pass', ('error', 'restart', 'pass',)), + ('hash', ('hash',)), + ('miss', ('error', 'restart', 'pass', 'fetch',)), + ('lookup', ('error', 'restart', 'pass', 'deliver',)), + ('backend_fetch', ('error', 'fetch', 'pass',)), + ('backend_response', ('error', 'restart', 'deliver',)), + ('deliver', ('restart', 'deliver',)), + ('error', ('restart', 'deliver',)), + ('init', ('ok',)), + ('fini', ('ok',)), ) ####################################################################### @@ -209,8 +209,8 @@ sp_variables = ( ), ('req.esi', 'BOOL', - ( 'recv', 'response', 'deliver', 'error',), - ( 'recv', 'response', 'deliver', 'error',), + ( 'recv', 'backend_response', 'deliver', 'error',), + ( 'recv', 'backend_response', 'deliver', 'error',), 'R' ), ('req.can_gzip', @@ -239,158 +239,158 @@ sp_variables = ( ), ('bereq.method', 'STRING', - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), 'cR' ), ('bereq.request', 'STRING', - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), 'cR' ), ('bereq.url', 'STRING', - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), 'cR' ), ('bereq.proto', 'STRING', - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), 'cR' ), ('bereq.http.', 'HEADER', - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), - ( 'pipe', 'fetch', 'pass', 'miss', 'response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), + ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), 'cR' ), ('bereq.connect_timeout', 'DURATION', - ( 'pipe', 'fetch', 'pass', 'miss',), - ( 'pipe', 'fetch', 'pass', 'miss',), + ( 'pipe', 'backend_fetch', 'pass', 'miss',), + ( 'pipe', 'backend_fetch', 'pass', 'miss',), 'cR' ), ('bereq.first_byte_timeout', 'DURATION', - ( 'fetch', 'pass', 'miss',), - ( 'fetch', 'pass', 'miss',), + ( 'backend_fetch', 'pass', 'miss',), + ( 'backend_fetch', 'pass', 'miss',), 'cR' ), ('bereq.between_bytes_timeout', 'DURATION', - ( 'fetch', 'pass', 'miss',), - ( 'fetch', 'pass', 'miss',), + ( 'backend_fetch', 'pass', 'miss',), + ( 'backend_fetch', 'pass', 'miss',), 'cR' ), ('beresp.proto', 'STRING', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.saintmode', 'DURATION', ( ), - ( 'response',), + ( 'backend_response',), 'cR' ), ('beresp.status', 'INT', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.response', 'STRING', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.http.', 'HEADER', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.do_esi', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.do_stream', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.do_gzip', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.do_gunzip', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.do_pass', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.uncacheable', 'BOOL', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'cR' ), ('beresp.ttl', 'DURATION', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'R' ), ('beresp.grace', 'DURATION', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'R' ), ('beresp.keep', 'DURATION', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'R' ), ('beresp.backend.name', 'STRING', - ( 'response',), + ( 'backend_response',), ( ), 'cR' ), ('beresp.backend.ip', 'IP', - ( 'response',), + ( 'backend_response',), ( ), 'cR' ), ('beresp.backend.port', 'INT', - ( 'response',), + ( 'backend_response',), ( ), 'cR' ), ('beresp.storage', 'STRING', - ( 'response',), - ( 'response',), + ( 'backend_response',), + ( 'backend_response',), 'R' ), ('obj.proto', diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index bb42e35..feea593 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -374,7 +374,7 @@ static struct action_table { } action_table[] = { { "error", parse_error, VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | - VCL_MET_MISS | VCL_MET_LOOKUP | VCL_MET_RESPONSE + VCL_MET_MISS | VCL_MET_LOOKUP | VCL_MET_BACKEND_RESPONSE }, #define VCL_RET_MAC(l, U, B) \ From phk at varnish-cache.org Mon Apr 22 08:53:15 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 10:53:15 +0200 Subject: [master] 0c223ef Add a VCL_Ref{} function, we will need to give the fetcher threads a copy of the VCL. Message-ID: commit 0c223ef07dec966e05ea7ef1bb068e148077a6cc Author: Poul-Henning Kamp Date: Mon Apr 22 08:52:23 2013 +0000 Add a VCL_Ref{} function, we will need to give the fetcher threads a copy of the VCL. Reduce move the meat of the inline VCL method functions to a real function, before things get more complicated. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a7aad66..5e80247 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1012,6 +1012,7 @@ void VRY_Finish(struct req *req, struct busyobj *bo); /* cache_vcl.c */ void VCL_Init(void); void VCL_Refresh(struct VCL_conf **vcc); +void VCL_Ref(struct VCL_conf *vcc); void VCL_Rel(struct VCL_conf **vcc); void VCL_Poll(void); const char *VCL_Return_Name(unsigned); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 0ebf91a..6cddd28 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -122,6 +122,16 @@ VCL_Refresh(struct VCL_conf **vcc) } void +VCL_Ref(struct VCL_conf *vc) +{ + + Lck_Lock(&vcl_mtx); + assert(vc->busy > 0); + vc->busy++; + Lck_Unlock(&vcl_mtx); +} + +void VCL_Rel(struct VCL_conf **vcc) { struct VCL_conf *vc; @@ -347,27 +357,36 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ +static void +vcl_call_method(struct worker *wrk, struct req *req, struct ws *ws, + unsigned method, vcl_func_f *func) +{ + char *aws; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); + AN(req->sp); + aws = WS_Snapshot(wrk->aws); + wrk->handling = 0; + wrk->cur_method = method; + VSLb(req->vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); + (void)func(wrk, req, NULL, ws); + VSLb(req->vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); + wrk->cur_method = 0; + WS_Reset(wrk->aws, aws); +} + #define VCL_MET_MAC(func, upper, bitmap) \ void \ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ { \ - char *aws; \ \ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); \ - AN(req->sp); \ - aws = WS_Snapshot(wrk->aws); \ - wrk->handling = 0; \ - wrk->cur_method = VCL_MET_ ## upper; \ - VSLb(req->vsl, SLT_VCL_call, "%s", #func); \ - (void)req->vcl->func##_func(wrk, req, NULL, ws); \ - VSLb(req->vsl, SLT_VCL_return, "%s", \ - VCL_Return_Name(wrk->handling)); \ - wrk->cur_method = 0; \ + vcl_call_method(wrk, req, ws, VCL_MET_ ## upper, \ + req->vcl->func##_func); \ assert((1U << wrk->handling) & bitmap); \ assert(!((1U << wrk->handling) & ~bitmap)); \ - WS_Reset(wrk->aws, aws); \ } #include "tbl/vcl_returns.h" From phk at varnish-cache.org Mon Apr 22 09:17:18 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 11:17:18 +0200 Subject: [master] c395b65 Add even more arguments to the VCL method functions Message-ID: commit c395b650bc838be612d5300c67e92b1f7a0a28f9 Author: Poul-Henning Kamp Date: Mon Apr 22 09:17:06 2013 +0000 Add even more arguments to the VCL method functions diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5e80247..a284289 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1019,7 +1019,8 @@ const char *VCL_Return_Name(unsigned); const char *VCL_Method_Name(unsigned); #define VCL_MET_MAC(l,u,b) \ - void VCL_##l##_method(struct worker *, struct req *, struct ws *); + void VCL_##l##_method(struct VCL_conf *, struct worker *, struct req *, \ + struct busyobj *bo, struct ws *); #include "tbl/vcl_returns.h" #undef VCL_MET_MAC diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 240d166..3b06a8d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -158,7 +158,7 @@ cnt_prepresp(struct worker *wrk, struct req *req) HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp); RES_BuildHttp(req); - VCL_deliver_method(wrk, req, req->http->ws); + VCL_deliver_method(req->vcl, wrk, req, NULL, req->http->ws); switch (wrk->handling) { case VCL_RET_DELIVER: break; @@ -308,7 +308,7 @@ cnt_error(struct worker *wrk, struct req *req) http_PutResponse(h, req->err_reason); else http_PutResponse(h, http_StatusMessage(req->err_code)); - VCL_error_method(wrk, req, req->http->ws); + VCL_error_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { @@ -416,7 +416,8 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->do_esi); AZ(bo->do_pass); - VCL_backend_response_method(wrk, req, req->http->ws); + VCL_backend_response_method(req->vcl, wrk, req, NULL, + req->http->ws); if (bo->do_pass) req->objcore->flags |= OC_F_PASS; @@ -845,7 +846,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX HIT\n"); AZ(req->objcore); AZ(req->busyobj); - VCL_lookup_method(wrk, req, req->http->ws); + VCL_lookup_method(req->vcl, wrk, req, NULL, req->http->ws); if ((req->obj->objcore->flags & OC_F_PASS) && wrk->handling == VCL_RET_DELIVER) { @@ -923,8 +924,8 @@ cnt_miss(struct worker *wrk, struct req *req) http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } - VCL_backend_fetch_method(wrk, req, req->http->ws); - VCL_miss_method(wrk, req, req->http->ws); + VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws); + VCL_miss_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_FETCH) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -988,8 +989,8 @@ cnt_pass(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_PASS); - VCL_backend_fetch_method(wrk, req, req->http->ws); - VCL_pass_method(wrk, req, req->http->ws); + VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws); + VCL_pass_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_ERROR) { http_Teardown(bo->bereq); @@ -1047,7 +1048,7 @@ cnt_pipe(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, 0); - VCL_pipe_method(wrk, req, req->http->ws); + VCL_pipe_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_ERROR) INCOMPL(); @@ -1153,7 +1154,7 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - VCL_recv_method(wrk, req, req->http->ws); + VCL_recv_method(req->vcl, wrk, req, NULL, req->http->ws); recv_handling = wrk->handling; if (cache_param->http_gzip_support && @@ -1169,7 +1170,7 @@ cnt_recv(struct worker *wrk, struct req *req) req->sha256ctx = &sha256ctx; /* so HSH_AddString() can find it */ SHA256_Init(req->sha256ctx); - VCL_hash_method(wrk, req, req->http->ws); + VCL_hash_method(req->vcl, wrk, req, NULL, req->http->ws); assert(wrk->handling == VCL_RET_HASH); SHA256_Final(req->digest, req->sha256ctx); req->sha256ctx = NULL; diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 6cddd28..7c70c11 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -358,33 +358,42 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ static void -vcl_call_method(struct worker *wrk, struct req *req, struct ws *ws, - unsigned method, vcl_func_f *func) +vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, + struct ws *ws, unsigned method, vcl_func_f *func) { char *aws; + struct vsl_log *vsl; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); - AN(req->sp); + if (req != NULL) { + AZ(bo); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); + vsl = req->vsl; + } else { + AZ(req); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vsl = bo->vsl; + } aws = WS_Snapshot(wrk->aws); wrk->handling = 0; wrk->cur_method = method; - VSLb(req->vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); + VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); (void)func(wrk, req, NULL, ws); - VSLb(req->vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); + VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method = 0; WS_Reset(wrk->aws, aws); } #define VCL_MET_MAC(func, upper, bitmap) \ void \ -VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws) \ +VCL_##func##_method(struct VCL_conf *vcl, struct worker *wrk, \ + struct req *req, struct busyobj *bo, struct ws *ws) \ { \ \ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \ - vcl_call_method(wrk, req, ws, VCL_MET_ ## upper, \ - req->vcl->func##_func); \ + vcl_call_method(wrk, req, bo, ws, VCL_MET_ ## upper, \ + vcl->func##_func); \ assert((1U << wrk->handling) & bitmap); \ assert(!((1U << wrk->handling) & ~bitmap)); \ } From phk at varnish-cache.org Mon Apr 22 09:26:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 11:26:10 +0200 Subject: [master] 71f8160 Use the busyobj workspace for random VCL work in vcl_backend_*{} Message-ID: commit 71f81608d04d276f0162b737592f4fdaeb948ba9 Author: Poul-Henning Kamp Date: Mon Apr 22 09:25:45 2013 +0000 Use the busyobj workspace for random VCL work in vcl_backend_*{} Minor polish diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3b06a8d..17222a0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -417,7 +417,7 @@ cnt_fetch(struct worker *wrk, struct req *req) AZ(bo->do_pass); VCL_backend_response_method(req->vcl, wrk, req, NULL, - req->http->ws); + bo->beresp->ws); if (bo->do_pass) req->objcore->flags |= OC_F_PASS; @@ -924,7 +924,7 @@ cnt_miss(struct worker *wrk, struct req *req) http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } - VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws); + VCL_backend_fetch_method(req->vcl, wrk, req, NULL, bo->bereq->ws); VCL_miss_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_FETCH) { @@ -989,7 +989,7 @@ cnt_pass(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); http_FilterReq(req, HTTPH_R_PASS); - VCL_backend_fetch_method(req->vcl, wrk, req, NULL, req->http->ws); + VCL_backend_fetch_method(req->vcl, wrk, req, NULL, bo->bereq->ws); VCL_pass_method(req->vcl, wrk, req, NULL, req->http->ws); if (wrk->handling == VCL_RET_ERROR) { diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 7c70c11..de40572 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -355,7 +355,12 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) VBE_UseHealth(vcl->conf->director[i]); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Method functions to call into VCL programs. + * + * Either the request or busyobject must be specified, but not both. + * The workspace argument is where random VCL stuff gets space from. + */ static void vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, @@ -391,6 +396,7 @@ VCL_##func##_method(struct VCL_conf *vcl, struct worker *wrk, \ struct req *req, struct busyobj *bo, struct ws *ws) \ { \ \ + CHECK_OBJ_NOTNULL(vcl, VCL_CONF_MAGIC); \ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \ vcl_call_method(wrk, req, bo, ws, VCL_MET_ ## upper, \ vcl->func##_func); \ From phk at varnish-cache.org Mon Apr 22 10:36:07 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 12:36:07 +0200 Subject: [master] 5800cf9 Add a band-aid for now, and pass the bo with the req where bereq/beresp are available. Message-ID: commit 5800cf91104795200f6d242b0c3df099b0d6e5fe Author: Poul-Henning Kamp Date: Mon Apr 22 10:35:38 2013 +0000 Add a band-aid for now, and pass the bo with the req where bereq/beresp are available. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index de40572..43ecc7c 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -380,11 +380,21 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vsl = bo->vsl; } + if (method == VCL_MET_BACKEND_FETCH || + method == VCL_MET_PASS || + method == VCL_MET_MISS || + method == VCL_MET_PIPE || + method == VCL_MET_BACKEND_RESPONSE) { + /* XXX: temporary workaround */ + AN(req); + bo = req->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + } aws = WS_Snapshot(wrk->aws); wrk->handling = 0; wrk->cur_method = method; VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); - (void)func(wrk, req, NULL, ws); + (void)func(wrk, req, bo, ws); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method = 0; WS_Reset(wrk->aws, aws); From phk at varnish-cache.org Mon Apr 22 10:42:00 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 12:42:00 +0200 Subject: [master] 2d53dfe Start moving the backend VCL variables to use busyobj rather than req Message-ID: commit 2d53dfe4006d54ee783f9513c36b55f99789108e Author: Poul-Henning Kamp Date: Mon Apr 22 10:41:38 2013 +0000 Start moving the backend VCL variables to use busyobj rather than req diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 16f8c8b..8378095 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -63,38 +63,47 @@ vrt_do_string(const struct http *hp, int fld, #define VRT_DO_HDR(obj, hdr, http, fld) \ void \ -VRT_l_##obj##_##hdr(const struct req *req, const char *p, ...) \ +VRT_l_##obj##_##hdr(const struct CPAR *px, const char *p, ...) \ { \ va_list ap; \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ va_start(ap, p); \ vrt_do_string(http, fld, #obj "." #hdr, p, ap); \ va_end(ap); \ } \ \ const char * \ -VRT_r_##obj##_##hdr(const struct req *req) \ +VRT_r_##obj##_##hdr(const struct CPAR *px) \ { \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); \ return (http->hd[fld].b); \ } -VRT_DO_HDR(req, method, req->http, HTTP_HDR_METHOD) -VRT_DO_HDR(req, request, req->http, HTTP_HDR_METHOD) -VRT_DO_HDR(req, url, req->http, HTTP_HDR_URL) -VRT_DO_HDR(req, proto, req->http, HTTP_HDR_PROTO) -VRT_DO_HDR(bereq, method, req->busyobj->bereq, HTTP_HDR_METHOD) -VRT_DO_HDR(bereq, request, req->busyobj->bereq, HTTP_HDR_METHOD) -VRT_DO_HDR(bereq, url, req->busyobj->bereq, HTTP_HDR_URL) -VRT_DO_HDR(bereq, proto, req->busyobj->bereq, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, proto, req->obj->http, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, response, req->obj->http, HTTP_HDR_RESPONSE) -VRT_DO_HDR(resp, proto, req->resp, HTTP_HDR_PROTO) -VRT_DO_HDR(resp, response, req->resp, HTTP_HDR_RESPONSE) -VRT_DO_HDR(beresp, proto, req->busyobj->beresp, HTTP_HDR_PROTO) -VRT_DO_HDR(beresp, response, req->busyobj->beresp, HTTP_HDR_RESPONSE) +#define CPAR req +#define CMAGIC REQ_MAGIC +VRT_DO_HDR(req, method, px->http, HTTP_HDR_METHOD) +VRT_DO_HDR(req, request, px->http, HTTP_HDR_METHOD) +VRT_DO_HDR(req, url, px->http, HTTP_HDR_URL) +VRT_DO_HDR(req, proto, px->http, HTTP_HDR_PROTO) +VRT_DO_HDR(obj, proto, px->obj->http, HTTP_HDR_PROTO) +VRT_DO_HDR(obj, response, px->obj->http, HTTP_HDR_RESPONSE) +VRT_DO_HDR(resp, proto, px->resp, HTTP_HDR_PROTO) +VRT_DO_HDR(resp, response, px->resp, HTTP_HDR_RESPONSE) +#undef CPAR +#undef CMAGIC + +#define CPAR busyobj +#define CMAGIC BUSYOBJ_MAGIC +VRT_DO_HDR(bereq, method, px->bereq, HTTP_HDR_METHOD) +VRT_DO_HDR(bereq, request, px->bereq, HTTP_HDR_METHOD) +VRT_DO_HDR(bereq, url, px->bereq, HTTP_HDR_URL) +VRT_DO_HDR(bereq, proto, px->bereq, HTTP_HDR_PROTO) +VRT_DO_HDR(beresp, proto, px->beresp, HTTP_HDR_PROTO) +VRT_DO_HDR(beresp, response, px->beresp, HTTP_HDR_RESPONSE) +#undef CPAR +#undef CMAGIC /*--------------------------------------------------------------------*/ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 5df3fd8..2bd958e 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -241,25 +241,25 @@ sp_variables = ( 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cR' + 'cB' ), ('bereq.request', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cR' + 'cB' ), ('bereq.url', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cR' + 'cB' ), ('bereq.proto', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cR' + 'cB' ), ('bereq.http.', 'HEADER', @@ -289,7 +289,7 @@ sp_variables = ( 'STRING', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'cB' ), ('beresp.saintmode', 'DURATION', @@ -307,7 +307,7 @@ sp_variables = ( 'STRING', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'cB' ), ('beresp.http.', 'HEADER', @@ -859,10 +859,19 @@ def mk_proto(c, r=False): for i in c: if i == "c" and not r: s += " const" - if i == "R": + elif i == "c": + pass + elif i == "R": if r: s += " const" s += " struct req *" + elif i == "B": + if r: + s += " const" + s += " struct busyobj *" + else: + print("Unknown args-spec char '%s'" % i) + exit(1) return s[1:] @@ -873,8 +882,13 @@ def mk_args(c, r=False): for i in c: if i == "c": continue; - if i == "R": + elif i == "R": s += "req" + elif i == "B": + s += "bo" + else: + print("Unknown args-spec char '%s'" % i) + exit(1) if s != "" and not r: s += "," return s From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 4d0474f INSTALL: minor update Message-ID: commit 4d0474ff675b30a5394bb803e1bc626dbb3cefaf Author: Tollef Fog Heen Date: Thu Jul 19 14:30:10 2012 +0200 INSTALL: minor update diff --git a/INSTALL b/INSTALL index ca9f152..97b2502 100644 --- a/INSTALL +++ b/INSTALL @@ -5,8 +5,8 @@ run the 'configure' script in the top-level directory, then run 'make' and 'make install'. On Linux, you need to run 'ldconfig' as root afterwards in order to update the shared library cache. -If you obtained the sources directly from the Subversion repository, -you will need to run autogen.sh first to create the configure script. +If you obtained the sources directly from the Git repository, you will +need to run autogen.sh first to create the configure script. Varnish will store run-time state in $localstatedir/varnish; you may want to tune this using configure's --localstatedir parameter. From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 773d415 I have no idea how I ended up incrementting the fail counter by the size of the request, probably sleep copy&paste ? Message-ID: commit 773d4151c864fcca5a931995c8dba7c7318c18ae Author: Poul-Henning Kamp Date: Mon Jul 30 15:52:55 2012 +0000 I have no idea how I ended up incrementting the fail counter by the size of the request, probably sleep copy&paste ? Fixed #1175 Submitted by: martin diff --git a/bin/varnishd/storage_malloc.c b/bin/varnishd/storage_malloc.c index f72cd48..3450a76 100644 --- a/bin/varnishd/storage_malloc.c +++ b/bin/varnishd/storage_malloc.c @@ -67,7 +67,7 @@ sma_alloc(struct stevedore *st, size_t size) Lck_Lock(&sma_sc->sma_mtx); sma_sc->stats->c_req++; if (sma_sc->sma_alloc + size > sma_sc->sma_max) { - sma_sc->stats->c_fail += size; + sma_sc->stats->c_fail++; size = 0; } else { sma_sc->sma_alloc += size; diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc new file mode 100644 index 0000000..739c56a --- /dev/null +++ b/bin/varnishtest/tests/r01175.vtc @@ -0,0 +1,20 @@ +varnishtest "#1175 - -smalloc c_fail incremented by bytes" + +server s1 { + rxreq + txresp -nolen -hdr "Content-Length: 1048576" +} -start + +varnish v1 -storage "-s test=malloc,1M" -vcl+backend { + sub vcl_fetch { + set beresp.storage = "test"; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run + +varnish v1 -expect SMA.test.c_fail < 5 From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] c209326 Add the version identifier to the CLI banner. Message-ID: commit c209326d4c5cf3090b052a861a13b39b4085295f Author: Poul-Henning Kamp Date: Mon Aug 6 08:12:13 2012 +0000 Add the version identifier to the CLI banner. Inspired by: patch from geoff diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index e31f3f8..7b27e98 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -80,6 +80,7 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv) VCLI_Out(cli, "Varnish Cache CLI 1.0\n"); VCLI_Out(cli, "-----------------------------\n"); VCLI_Out(cli, "%s\n", VSB_data(vident) + 1); + VCLI_Out(cli, "%s\n", VCS_version); VCLI_Out(cli, "\n"); VCLI_Out(cli, "Type 'help' for command list.\n"); VCLI_Out(cli, "Type 'quit' to close CLI session.\n"); diff --git a/include/libvarnish.h b/include/libvarnish.h index a4fd542..b457d02 100644 --- a/include/libvarnish.h +++ b/include/libvarnish.h @@ -104,6 +104,7 @@ struct timespec TIM_timespec(double t); struct timeval TIM_timeval(double t); /* from libvarnish/version.c */ +extern const char *VCS_version; void VCS_Message(const char *); /* from libvarnish/vtmpfile.c */ diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 014eda4..3427ee7 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -36,11 +36,13 @@ #include "libvarnish.h" #include "vcs_version.h" +const char *VCS_version = + PACKAGE_TARNAME "-" PACKAGE_VERSION " revision " VCS_Version; + void VCS_Message(const char *progname) { - fprintf(stderr, "%s (%s-%s revision %s)\n", progname, - PACKAGE_TARNAME, PACKAGE_VERSION, VCS_Version); + fprintf(stderr, "%s (%s)\n", progname, VCS_version); fprintf(stderr, "Copyright (c) 2006 Verdens Gang AS\n"); fprintf(stderr, "Copyright (c) 2006-2011 Varnish Software AS\n"); } From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 3102324 Doc: Fix indentation issue Message-ID: commit 3102324e9022312d0a0b08346417ff6294bf16ff Author: Kristian Lyngstol Date: Wed Aug 8 16:40:14 2012 +0200 Doc: Fix indentation issue Old indentation made the :ref: into a literal block, thus not a real reference. This should do the trick. diff --git a/doc/sphinx/faq/general.rst b/doc/sphinx/faq/general.rst index 2444394..44a11b3 100644 --- a/doc/sphinx/faq/general.rst +++ b/doc/sphinx/faq/general.rst @@ -187,7 +187,7 @@ Yes, you need VCL code like this:: set req.backend = foobar; } - Please see :ref:`tutorial-advanced_backend_servers-directors_`. +Please see :ref:`tutorial-advanced_backend_servers-directors_`. Why ... From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] c703aff Change our chosen "bad_ip" to 192.0.2.255 which is a broadcast address from RFC5737's TEST-NET-1 and put a comment there to explain. Message-ID: commit c703aff8ded54b61cd247e2fff65cbf244b72ddf Author: Poul-Henning Kamp Date: Mon Jul 30 16:33:48 2012 +0000 Change our chosen "bad_ip" to 192.0.2.255 which is a broadcast address from RFC5737's TEST-NET-1 and put a comment there to explain. I fear this is a loosing battle, but at least this is more "official" than the previous "10.255.255.255" choice. Fixes #1159 diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 72caa2a..5ceb4ed 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -566,7 +566,15 @@ exec_file(const char *fn, const char *script, const char *tmpdir, cwd = getcwd(NULL, PATH_MAX); macro_def(vltop, NULL, "pwd", cwd); macro_def(vltop, NULL, "topbuild", "%s/%s", cwd, TOP_BUILDDIR); - macro_def(vltop, NULL, "bad_ip", "10.255.255.255"); + + /* + * We need an IP number which will not repond, ever, and that is a + * lot harder than it sounds. This IP# is from RFC5737 and a + * C-class broadcast at that. + * If tests involving ${bad_ip} fails and you run linux, you should + * check your /proc/sys/net/ipv4/ip_nonlocal_bind setting. + */ + macro_def(vltop, NULL, "bad_ip", "192.0.2.255"); /* Move into our tmpdir */ AZ(chdir(tmpdir)); From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] ac3ab42 doc: Attempt two at fixing references. Message-ID: commit ac3ab427dd0e97d27ac389913ad203e9f84c5a6f Author: Kristian Lyngstol Date: Wed Aug 8 16:45:06 2012 +0200 doc: Attempt two at fixing references. diff --git a/doc/sphinx/faq/general.rst b/doc/sphinx/faq/general.rst index 44a11b3..b0c7e13 100644 --- a/doc/sphinx/faq/general.rst +++ b/doc/sphinx/faq/general.rst @@ -187,7 +187,7 @@ Yes, you need VCL code like this:: set req.backend = foobar; } -Please see :ref:`tutorial-advanced_backend_servers-directors_`. +Please see :ref:`tutorial-advanced_backend_servers-directors`. Why ... @@ -196,7 +196,7 @@ Why ... **Why does it look like Varnish sends all requests to the backend? I thought it was a cache?** -Please see ref:`tutorial-increasing_your_hitrate`. +Please see :ref:`tutorial-increasing_your_hitrate`. **Why does Varnish require the system to have a C compiler?** From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 17183b7 Spelling Message-ID: commit 17183b743e395d776dcfbf1e4dd681a75bf8fe5f Author: Andreas Plesner Jacobsen Date: Wed Aug 8 21:40:52 2012 +0200 Spelling diff --git a/doc/sphinx/phk/index.rst b/doc/sphinx/phk/index.rst index 58935c7..665fda0 100644 --- a/doc/sphinx/phk/index.rst +++ b/doc/sphinx/phk/index.rst @@ -4,7 +4,7 @@ Poul-Hennings random outbursts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -You may or may not want to know what Poul-Henning think. +You may or may not want to know what Poul-Henning thinks. .. toctree:: From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] b2c508c Recognize OpenBSD as platform. Federico says it almost works. Message-ID: commit b2c508c676920545cde2064ed1db41603a2b404d Author: Poul-Henning Kamp Date: Thu Aug 9 08:27:03 2012 +0000 Recognize OpenBSD as platform. Federico says it almost works. Submitted by: Federico G. Schwindt diff --git a/autogen.sh b/autogen.sh index 07df626..6d28093 100755 --- a/autogen.sh +++ b/autogen.sh @@ -12,6 +12,9 @@ Darwin) FreeBSD) LIBTOOLIZE=libtoolize ;; +OpenBSD) + LIBTOOLIZE=libtoolize + ;; Linux) LIBTOOLIZE=libtoolize ;; From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 5a1b472 Remove long gone cli.debug cli calls Message-ID: commit 5a1b4724e4ad8f2e82e10c292017c6499d220d65 Author: Poul-Henning Kamp Date: Thu Aug 9 08:28:56 2012 +0000 Remove long gone cli.debug cli calls diff --git a/bin/varnishtest/tests/v00006.vtc b/bin/varnishtest/tests/v00006.vtc index f3faace..ca2bb7e 100644 --- a/bin/varnishtest/tests/v00006.vtc +++ b/bin/varnishtest/tests/v00006.vtc @@ -41,7 +41,7 @@ varnish v1 -expect n_backend == 2 varnish v1 -expect n_vcl_avail == 2 varnish v1 -expect n_vcl_discard == 0 -varnish v1 -cli "debug.backend" -cli "vcl.list" +varnish v1 -cli "vcl.list" # Discard the first VCL @@ -64,7 +64,7 @@ client c1 { # The workthread should have released its VCL reference now # but we need to tickle the CLI to notice -varnish v1 -cli "debug.backend" -cli "vcl.list" +varnish v1 -cli "vcl.list" varnish v1 -expect n_backend == 1 varnish v1 -expect n_vcl_avail == 1 From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 5e3c785 Remove long since gone debug.backend cli. Message-ID: commit 5e3c785f3a78bf91c5cc2ccf85be563e73bf3080 Author: Poul-Henning Kamp Date: Thu Aug 9 08:29:39 2012 +0000 Remove long since gone debug.backend cli. Submitted by: Federico G. Schwindt diff --git a/bin/varnishtest/tests/v00012.vtc b/bin/varnishtest/tests/v00012.vtc index 285f2c1..e7c8d44 100644 --- a/bin/varnishtest/tests/v00012.vtc +++ b/bin/varnishtest/tests/v00012.vtc @@ -33,8 +33,6 @@ client c2 { expect resp.status == 503 } -run -varnish v1 -cli "debug.backend" - sema r2 sync 2 client c1 -wait From tfheen at varnish-cache.org Mon Apr 22 11:26:59 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:26:59 +0200 Subject: [3.0] 30dc140 Sigh, this one is the working part of the fix: Message-ID: commit 30dc140793cd48a760cf2b46021f630497fe6e30 Author: Poul-Henning Kamp Date: Mon Aug 13 11:05:39 2012 +0000 Sigh, this one is the working part of the fix: If people only specify Transient, run only on Transient. Fixes #1176 diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 00eb645..d1b59c2 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -140,6 +140,8 @@ stv_pick_stevedore(const struct sess *sp, const char **hint) WSP(sp, SLT_Debug, "Storage hint not usable"); *hint = NULL; } + if (stv_next == NULL) + return (stv_transient); /* pick a stevedore and bump the head along */ stv = VTAILQ_NEXT(stv_next, list); if (stv == NULL) From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 1b373e8 If people only specify the Transient storage, only run on the Transient storage. Message-ID: commit 1b373e8d15ea411e3908d69b33bb64796b61f5c9 Author: Poul-Henning Kamp Date: Mon Aug 13 11:05:05 2012 +0000 If people only specify the Transient storage, only run on the Transient storage. Fixes #1176 diff --git a/bin/varnishtest/tests/r01176.vtc b/bin/varnishtest/tests/r01176.vtc new file mode 100644 index 0000000..d9a0a99 --- /dev/null +++ b/bin/varnishtest/tests/r01176.vtc @@ -0,0 +1,14 @@ +varnishtest "-s Transient=malloc crash" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -storage "-s Transient=malloc" -vcl+backend {} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 26c1421 Remove the FAQ from sphinx. It was never properly maintained. Message-ID: commit 26c142159a41879a742b095a29d3b6157a35c361 Author: Per Buer Date: Tue Aug 21 10:28:52 2012 +0200 Remove the FAQ from sphinx. It was never properly maintained. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index dc20abd..ed0930f 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -91,11 +91,6 @@ doctest: EXTRA_DIST = \ conf.py \ index.rst \ - faq/configuration.rst \ - faq/general.rst \ - faq/http.rst \ - faq/index.rst \ - faq/logging.rst \ glossary/index.rst \ installation/bugs.rst \ installation/help.rst \ diff --git a/doc/sphinx/faq/configuration.rst b/doc/sphinx/faq/configuration.rst deleted file mode 100644 index df06b07..0000000 --- a/doc/sphinx/faq/configuration.rst +++ /dev/null @@ -1,53 +0,0 @@ -%%%%%%%%%%%%%%% -Configuration -%%%%%%%%%%%%%%% - -.. _faq-vcl: - -VCL -=== - -**What is VCL?** - -VCL is an acronym for Varnish Configuration Language. In a VCL file, you configure how Varnish should behave. Sample VCL files will be included in this Wiki at a later stage. - -**Where is the documentation on VCL?** - -Please see ``man 7 vcl``. There are also some real-world examples on -the `wiki `_ - - -**How do I load VCL file while Varnish is running?** - -* Place the VCL file on the server -* Telnet into the managment port. -* do a "vcl.load " in managment interface. is whatever you would like to call your new configuration. -* do a "vcl.use " to start using your new config. - -**Should I use ''pipe'' or ''pass'' in my VCL code? What is the difference?** - -When varnish does a ``pass`` it acts like a normal HTTP proxy. It -reads the request and pushes it onto the backend. The next HTTP -request can then be handled like any other. - -``pipe`` is only used when Varnish for some reason can't handle the -``pass``. ``pipe`` reads the request, pushes in onty the backend -_only_ pushes bytes back and forth, with no other actions taken. - -Since most HTTP clients do pipeline several requests into one -connection this might give you an undesirable result - as every -subsequent request will reuse the existing ``pipe``. Please see `this -article ` for -more details and a workaround. - -Varnish versions prior to 2.0 does not support handling a request body -with ``pass`` mode, so in those releases ``pipe`` is required for -correct handling. - -In 2.0 and later, ``pass`` will handle the request body correctly. - -If you get 503 errors when making a request which is ``pass`` ed, make sure -that you're specifying the backend before returning from vcl_recv with ``pass``. - - - diff --git a/doc/sphinx/faq/general.rst b/doc/sphinx/faq/general.rst deleted file mode 100644 index b0c7e13..0000000 --- a/doc/sphinx/faq/general.rst +++ /dev/null @@ -1,238 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -General questions -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -What is Varnish? -================ - -Please see ref:`tutorial-intro`. - -How... -====== - -**How much RAM/Disk do I need for Varnish?** - -That depends on pretty much everything. - -I think our best current guidance is that you go for a cost-effective -RAM configuration, something like 1-16GB, and an SSD. - -Unless you positively know that you will need it, there is -little point in spending a fortune on a hand-sewn motherboard -that can fit several TB in special RAM blocks, riveted together -by leftover watch-makers in Switzerland. - -On the other hand, if you plot your traffic in Gb/s, you probably -need all the RAM you can afford/get. - -**How can I limit Varnish to use less RAM?** - -You can not. Varnish operates in Virtual Memory and it is up to the -kernel to decide which process gets to use how much RAM to map the -virtual address-space of the process. - -**How do I instruct varnish to ignore the query parameters and only cache one instance of an object?** - -This can be achieved by removing the query parameters using a regexp:: - - sub vcl_recv { - set req.url = regsub(req.url, "\?.*", ""); - } - -**How can I force a refresh on a object cached by varnish?** - -Refreshing is often called `purging -`_ a document. You can -purge at least 2 different ways in Varnish: - -1. Command line - - From the command line you can write:: - - ban.url ^/$ - - to ban your / document. As you might see ban.url takes an `regular expression `_ - as its argument. Hence the ``^`` and ``$`` at the front and end. If the ``^`` is omitted, all the documents ending in a ``/`` in the cache would be deleted. - - So to delete all the documents in the cache, write:: - - ban.url . - - at the command line. - -2. HTTP PURGE - - VCL code to allow HTTP PURGE is to be found `here `_. Note that this method does not support wildcard purging. - -**How can I debug the requests of a single client?** - -The "varnishlog" utility may produce a horrendous amount of output. To be able debug our own traffic can be useful. - -The ReqStart token will include the client IP address. To see log entries matching this, type:: - - $ varnishlog -c -m ReqStart:192.0.2.123 - -To see the backend requests generated by a client IP address, we can match on the TxHeader token, since the IP address of the client is included in the X-Forwarded-For header in the request sent to the backend. - -At the shell command line, type:: - - $ varnishlog -b -m TxHeader:192.0.2.123 - -**How can I rewrite URLS before they are sent to the backend?** - -You can use the ``regsub()`` function to do this. Here's an example for zope, to rewrite URLs for the virtualhostmonster:: - - if (req.http.host ~ "^(www.)?example.com") { - set req.url = regsub(req.url, "^", "/VirtualHostBase/http/example.com:80/Sites/example.com/VirtualHostRoot"); - } - -**I have a site with many host names, how do I keep them from multiplying the cache?** - -You can do this by normalizing the ``Host`` header for all your host names. Here's a VCL example:: - - if (req.http.host ~ "^(www.)?example.com") { - set req.http.host = "example.com"; - } - -**How do I do to alter the request going to the backend?** -You can use the ``bereq`` object for altering requests going to the backend, but you can only 'set' values to it. Therefore use req.url to build the request:: - - sub vcl_miss { - set bereq.url = regsub(req.url,"stream/","/"); - return(fetch); - } - -**How can I customize the error messages that Varnish returns?** - -A custom error page can be generated by adding a ``vcl_error`` to your configuration file. The default error page looks like this:: - - sub vcl_error { - set obj.http.Content-Type = "text/html; charset=utf-8"; - - synthetic {" - - - - - "} + obj.status + " " + obj.response + {" - - -

Error "} + obj.status + " " + obj.response + {"

-

"} + obj.response + {"

-

Guru Meditation:

-

XID: "} + req.xid + {"

-
Varnish
- - - "}; - return(deliver); - } - -**How do I instruct varnish to ignore the query parameters and only cache one instance of an object?** - -This can be achieved by removing the query parameters using a regexp:: - - sub vcl_recv { - set req.url = regsub(req.url, "\?.*", ""); - } - - -Can I... -======== - -**Can I run Varnish on the same system as Apache?** - -Yes, and many people do that with good success. - -There will be competition for resources, but Apache is not particular -good at using RAM effectively and Varnish is, so this synergy usually -more than compensates for the competition. - -**Can I run multiple Varnish on the same system?** - -Yes, as long as you give them different TCP ports and different ``-n`` -arguments, you will be fine. - - -**Can I cache multiple virtual hosts with one Varnish?** - -Yes, that works right out of the box. - -**Can I see what is cached in Varnish?** - -That is not possible for several reasons. A command to list -all the contents of a Varnish cache with millions of objects would -bring your Varnish to a standstill while it traverses the index. - -Besides, the output is a lot less useful than you might think. - -**Can I use Varnish to do HTTPS?** - -Not at present, and while we keep an eye on this, there are no -current plans to add HTTPS support, until we can find a way where -it adds significant value, relative to running a stand-alone -HTTPS proxy such as nginx or pound. - -**Can Varnish load balance between multiple backends?** - -Yes, you need VCL code like this:: - - director foobar round-robin { - { .backend = { .host = "www1.example.com"; .port = "http"; } } - { .backend = { .host = "www2.example.com"; .port = "http"; } } - } - - sub vcl_recv { - set req.backend = foobar; - } - -Please see :ref:`tutorial-advanced_backend_servers-directors`. - - -Why ... -======= - -**Why does it look like Varnish sends all requests to the backend? I thought it was a cache?** - - -Please see :ref:`tutorial-increasing_your_hitrate`. - -**Why does Varnish require the system to have a C compiler?** - -The :ref:`VCL ` compiler generates C source as output (your -config file), and uses the systems C-compiler to compile that into a -shared library. If there is no C compiler, Varnish will not work. - -**Isn't that security problem?** - -The days when you could prevent people from running non-approved -programs by removing the C compiler from your system ended roughly -with the VAX 11/780 computer. - -Troubleshooting -=============== - -**Why am I getting a cache hit, but a request is still going to my backend?** - -Varnish has a feature called **hit for pass**, which is used when Varnish gets a response from the backend and finds out it cannot be cached. In such cases, Varnish will create a cache object that records that fact, so that the next request goes directly to "pass". - - Since Varnish bundles multiple requests for the same URL to the backend, a common case where a client will get a **hit for pass** is: - * Client 1 requests url /foo - * Client 2..N request url /foo - * Varnish tasks a worker to fetch /foo for Client 1 - * Client 2..N are now queued pending response from the worker - * Worker returns object to varnish which turns out to be non-cacheable. - * Client 2..N are now given the **hit for pass** object instructing them to go to the backend - -The **hit for pass** object will stay cached for the duration of its ttl. This means that subsequent clients requesting /foo will be sent straight to the backend as long as the **hit for pass** object exists. -The :command:`varnishstat` can tell you how many **hit for pass** objects varnish has served. The default vcl will set ttl for a hit_for_pass object to 120s. But you can override this, using the following logic:: - - sub vcl_fetch { - if (!obj.cacheable) { - # Limit the lifetime of all 'hit for pass' objects to 10 seconds - obj.ttl = 10s; - return(hit_for_pass); - } - } - diff --git a/doc/sphinx/faq/http.rst b/doc/sphinx/faq/http.rst deleted file mode 100644 index 1e276ba..0000000 --- a/doc/sphinx/faq/http.rst +++ /dev/null @@ -1,55 +0,0 @@ -%%%%%%%%%%% -HTTP -%%%%%%%%%%% - -**What is the purpose of the X-Varnish HTTP header?** - -The X-Varnish HTTP header allows you to find the correct log-entries for the transaction. For a cache hit, X-Varnish will contain both the ID of the current request and the ID of the request that populated the cache. It makes debugging Varnish a lot easier. - -**Does Varnish support compression?** - -This is a simple question with a complicated answer; see `WIKI `_. - -**How do I add a HTTP header?** - -To add a HTTP header, unless you want to add something about the client/request, it is best done in vcl_fetch as this means it will only be processed every time the object is fetched:: - - sub vcl_fetch { - # Add a unique header containing the cache servers IP address: - remove beresp.http.X-Varnish-IP; - set beresp.http.X-Varnish-IP = server.ip; - # Another header: - set beresp.http.Foo = "bar"; - } - -**How can I log the client IP address on the backend?** - -All I see is the IP address of the varnish server. How can I log the client IP address? - -We will need to add the IP address to a header used for the backend request, and configure the backend to log the content of this header instead of the address of the connecting client (which is the varnish server). - -Varnish configuration:: - - sub vcl_recv { - # Add a unique header containing the client address - remove req.http.X-Forwarded-For; - set req.http.X-Forwarded-For = client.ip; - # [...] - } - -For the apache configuration, we copy the "combined" log format to a new one we call "varnishcombined", for instance, and change the client IP field to use the content of the variable we set in the varnish configuration:: - - LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined - -And so, in our virtualhost, you need to specify this format instead of "combined" (or "common", or whatever else you use):: - - - ServerName www.example.com - # [...] - CustomLog /var/log/apache2/www.example.com/access.log varnishcombined - # [...] - - -The [http://www.openinfo.co.uk/apache/index.html mod_extract_forwarded Apache module] might also be useful. - - diff --git a/doc/sphinx/faq/index.rst b/doc/sphinx/faq/index.rst deleted file mode 100644 index a8136a8..0000000 --- a/doc/sphinx/faq/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. _faq: - -%%%%%%%%%%%%%%%%%%%%%%%%%% -Frequently asked questions -%%%%%%%%%%%%%%%%%%%%%%%%%% - -The most frequently asked questions about Varnish in different contexts. - - -.. toctree:: - - general.rst - http.rst - configuration.rst - logging.rst - -.. todo:: - [V] - Now that the FAQ has been all reStructureized, we need to qualitycheck the content, update old info, and delete unrelevant info. - - diff --git a/doc/sphinx/faq/logging.rst b/doc/sphinx/faq/logging.rst deleted file mode 100644 index 89fdbde..0000000 --- a/doc/sphinx/faq/logging.rst +++ /dev/null @@ -1,8 +0,0 @@ -%%%%%%%%%%%%%%%%%%% -Logging -%%%%%%%%%%%%%%%%%%% - -**Where can I find the log files?** - -Varnish does not log to a file, but to shared memory log. Use the varnishlog utility to print the shared memory log or varnishncsa to present it in the Apache / NCSA "combined" log format. - diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index 2dbd605..c7c7fe8 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -21,7 +21,6 @@ Contents: installation/index.rst tutorial/index.rst reference/index.rst - faq/index.rst phk/index.rst glossary/index.rst From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 1c20549 remove warning (invalid comment Message-ID: commit 1c20549603a6c8cf8b09432475cf160bc27f8432 Author: Per Buer Date: Tue Aug 21 10:30:26 2012 +0200 remove warning (invalid comment diff --git a/doc/sphinx/glossary/index.rst b/doc/sphinx/glossary/index.rst index 7a2787d..3da5af3 100644 --- a/doc/sphinx/glossary/index.rst +++ b/doc/sphinx/glossary/index.rst @@ -7,8 +7,7 @@ Varnish Glossary .. glossary:: :sorted: - .. comment: - + .. This file will be sorted automagically during formatting, so we keep the source in subject order to make sure we cover all bases. From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 6a1e3cd Merge rest of a9e5d3 Message-ID: commit 6a1e3cd59e63c11ce64d00805d51e19487fb68bb Author: Tollef Fog Heen Date: Thu Apr 4 13:46:05 2013 +0200 Merge rest of a9e5d3 The regression test and sensible error message was missing, so merge those bits. diff --git a/bin/varnishtest/tests/r01144.vtc b/bin/varnishtest/tests/r01144.vtc new file mode 100644 index 0000000..403f77e --- /dev/null +++ b/bin/varnishtest/tests/r01144.vtc @@ -0,0 +1,38 @@ +varnishtest "very long backend names" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + backend fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210 + { + .host = "127.0.0.1"; + .port = "54321"; + } + sub vcl_recv { + if (req.url == "never") { + set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run + +varnish v1 -badvcl { + backend 0fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210 + { + .host = "127.0.0.1"; + .port = "54321"; + } + sub vcl_recv { + if (req.url == "never") { + set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; + } + } +} diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index f79447f..836d4c0 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -713,6 +713,13 @@ vcc_ParseDirector(struct vcc *tl) vcc_ExpectCid(tl); /* ID: name */ ERRCHK(tl); + if (tl->t->e - tl->t->b > 64) { + VSB_printf(tl->sb, + "Name of %.*s too long (max 64, is %zd):\n", + PF(t_first), (tl->t->e - tl->t->b)); + vcc_ErrWhere(tl, tl->t); + return; + } tl->t_dir = tl->t; vcc_NextToken(tl); From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 48f0287 Try to make osx build happier. Message-ID: commit 48f0287675cd561bb381b4756b7290a994aaa73b Author: Poul-Henning Kamp Date: Tue Aug 21 09:01:36 2012 +0000 Try to make osx build happier. And yes, why ptrdiff_t even exists and why it can be different, semantically or otherwise, from ssize_t is beyond me... diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index 836d4c0..655ee63 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -713,13 +713,13 @@ vcc_ParseDirector(struct vcc *tl) vcc_ExpectCid(tl); /* ID: name */ ERRCHK(tl); - if (tl->t->e - tl->t->b > 64) { - VSB_printf(tl->sb, - "Name of %.*s too long (max 64, is %zd):\n", - PF(t_first), (tl->t->e - tl->t->b)); - vcc_ErrWhere(tl, tl->t); - return; - } + if (tl->t->e - tl->t->b > 64) { + VSB_printf(tl->sb, + "Name of %.*s too long (max 64, is %zu):\n", + PF(t_first), (size_t)(tl->t->e - tl->t->b)); + vcc_ErrWhere(tl, tl->t); + return; + } tl->t_dir = tl->t; vcc_NextToken(tl); From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 6ecde6d Showcase !~ in the regex example Message-ID: commit 6ecde6d1d5434c54e4ba81bbf94e380501c40048 Author: Per Buer Date: Wed Aug 22 09:13:36 2012 +0200 Showcase !~ in the regex example diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 927f640..c4b4f96 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -404,7 +404,8 @@ insensitivity* add the flag within parens following a question mark, like this: :: - if (req.http.host ~ "(?i)example.com$") { + # If host is NOT example dot com.. + if (req.http.host !~ "(?i)example.com$") { ... } From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] a0eafec Pass -g to nm(1), it makes backtraces on OSX marginally less useless Message-ID: commit a0eafec8f6ca673b3d26c718096e45e9e5c8a023 Author: Poul-Henning Kamp Date: Wed Aug 22 08:59:47 2012 +0000 Pass -g to nm(1), it makes backtraces on OSX marginally less useless diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index fd91d08..fbf5713 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -274,7 +274,7 @@ Symbol_hack(const char *a0) uintptr_t a; struct symbols *s; - bprintf(buf, "nm -an %s 2>/dev/null", a0); + bprintf(buf, "nm -agn %s 2>/dev/null", a0); fi = popen(buf, "r"); if (fi == NULL) return; From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] ee12797 Remove last traces of sess_workspace from logs Message-ID: commit ee12797bab5c997297949c6446fa7959885a62fc Author: Andreas Plesner Jacobsen Date: Thu Jan 19 19:12:43 2012 +0100 Remove last traces of sess_workspace from logs Found by: Federico G. Schwindt diff --git a/doc/sphinx/reference/params.rst b/doc/sphinx/reference/params.rst index 4fdd3e6..b5670fe 100644 --- a/doc/sphinx/reference/params.rst +++ b/doc/sphinx/reference/params.rst @@ -247,7 +247,7 @@ http_req_size - Default: 32768 Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. - The memory for the request is allocated from the session workspace (param: sess_workspace) and this parameter limits how much of that the request is allowed to take up. + The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up. http_resp_hdr_len - Units: bytes @@ -260,7 +260,7 @@ http_resp_size - Default: 32768 Maximum number of bytes of HTTP backend resonse we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. - The memory for the request is allocated from the worker workspace (param: sess_workspace) and this parameter limits how much of that the request is allowed to take up. + The memory for the request is allocated from the thread pool workspace (param: thread_pool_workspace) and this parameter limits how much of that the request is allowed to take up. idle_send_timeout - Units: seconds @@ -394,14 +394,6 @@ sess_timeout Idle timeout for persistent sessions. If a HTTP request has not been received in this many seconds, the session is closed. -sess_workspace - - Units: bytes - - Default: 65536 - - Flags: delayed - - Bytes of HTTP protocol workspace allocated for sessions. This space must be big enough for the entire HTTP protocol header and any edits done to it in the VCL code. - Minimum is 1024 bytes. - session_linger - Units: ms - Default: 50 diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 4e2b3f2..351c7b3 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -274,8 +274,10 @@ Here is a list of all parameters, current as of last time we remembered to updat produced from the same text you will find in the CLI if you use the param.show command, so should there be a new parameter which is not listed here, you can find the description using the CLI commands. -Be aware that on 32 bit systems, certain default values, such as sess_workspace (=16k) and thread_pool_stack -(=64k) are reduced relative to the values listed here, in order to conserve VM space. +Be aware that on 32 bit systems, certain default values, such as +workspace_client (=16k), thread_pool_workspace (=16k), http_resp_size (=8k), +http_req_size (=12k), gzip_stack_buffer (=4k) and thread_pool_stack (=64k) are +reduced relative to the values listed here, in order to conserve VM space. .. include:: params.rst diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index f00053e..a76dee1 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -171,7 +171,7 @@ STRING_LIST a function, we may relax that at a latter time. If you don't want to bother with STRING_LIST, just use STRING - and make sure your sess_workspace param is big enough. + and make sure your thread_pool_workspace param is big enough. PRIV_VCL See below From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] b3e23d4 remove indent warning Message-ID: commit b3e23d4fc04fc89b44c7ef56f00a01e900e5d6e5 Author: Per Buer Date: Mon Aug 27 10:47:43 2012 +0200 remove indent warning diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 033be5a..a4ec1b9 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -77,12 +77,12 @@ Commands -------- .. glossary:: - :sorted: + :sorted: help [command] Display a list of available commands. If the command is specified, display help for this command. - + param.set param value Set the parameter specified by param to the specified value. See Run-Time Parameters for a list of parame? ters. From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 6fc5a54 Polish vre.c a bit with respect to memory management and error messages. Message-ID: commit 6fc5a54e85498e330d52caae627772d1c275f284 Author: Poul-Henning Kamp Date: Tue May 1 06:38:54 2012 +0000 Polish vre.c a bit with respect to memory management and error messages. diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c index 2d40f3f..03626bf 100644 --- a/lib/libvarnish/vre.c +++ b/lib/libvarnish/vre.c @@ -33,17 +33,22 @@ #include "miniobj.h" #include "vre.h" +#ifndef PCRE_STUDY_JIT_COMPILE +#define PCRE_STUDY_JIT_COMPILE 0 +#endif + +#if PCRE_MAJOR < 8 || (PCRE_MAJOR == 8 && PCRE_MINOR < 20) +# define pcre_free_study pcre_free +#endif + struct vre { unsigned magic; #define VRE_MAGIC 0xe83097dc pcre *re; pcre_extra *re_extra; + int my_extra; }; -#ifndef PCRE_STUDY_JIT_COMPILE -#define PCRE_STUDY_JIT_COMPILE 0 -#endif - /* * We don't want to spread or even expose the majority of PCRE options * so we establish our own options and implement hard linkage to PCRE @@ -54,29 +59,32 @@ const unsigned VRE_NOTEMPTY = PCRE_NOTEMPTY; vre_t * VRE_compile(const char *pattern, int options, - const char **errptr, int *erroffset) + const char **errptr, int *erroffset) { vre_t *v; *errptr = NULL; *erroffset = 0; ALLOC_OBJ(v, VRE_MAGIC); - if (v == NULL) + if (v == NULL) { + *errptr = "Out of memory for VRE"; return (NULL); + } v->re = pcre_compile(pattern, options, errptr, erroffset, NULL); if (v->re == NULL) { VRE_free(&v); return (NULL); } v->re_extra = pcre_study(v->re, PCRE_STUDY_JIT_COMPILE, errptr); + if (*errptr != NULL) { + VRE_free(&v); + return (NULL); + } if (v->re_extra == NULL) { - if (*errptr != NULL) { - VRE_free(&v); - return (NULL); - } - /* allocate our own, pcre_study can return NULL without it - * being an error */ + /* allocate our own */ v->re_extra = calloc(1, sizeof(pcre_extra)); + v->my_extra = 1; if (v->re_extra == NULL) { + *errptr = "Out of memory for pcre_extra"; VRE_free(&v); return (NULL); } @@ -118,11 +126,13 @@ VRE_free(vre_t **vv) *vv = NULL; CHECK_OBJ(v, VRE_MAGIC); -#ifdef PCRE_CONFIG_JIT - pcre_free_study(v->re_extra); -#else - free(v->re_extra); -#endif - pcre_free(v->re); + if (v->re_extra != NULL) { + if (v->my_extra) + free(v->re_extra); + else + pcre_free_study(v->re_extra); + } + if (v->re != NULL) + pcre_free(v->re); FREE_OBJ(v); } From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 22489e0 Invoke libtoolize before aclocal. Message-ID: commit 22489e0ccaee87c144a5fd5e6aa03ebdc8338abd Author: Martin Blix Grydeland Date: Thu Sep 6 09:59:00 2012 +0200 Invoke libtoolize before aclocal. libtoolize was overwriting m4/libtool.m4, which aclocal.m4 depended on and needed aclocal to update. This caused the autotools files to be updated, triggering a second configure run on first build. diff --git a/autogen.sh b/autogen.sh index 6d28093..8a13e62 100755 --- a/autogen.sh +++ b/autogen.sh @@ -41,8 +41,8 @@ fi set -ex -aclocal -I m4 $LIBTOOLIZE --copy --force +aclocal -I m4 autoheader automake --add-missing --copy --foreign autoconf From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] f8464b2 Don't put POLLHUP in .events Message-ID: commit f8464b26060f91a91fbb5ec153d6326b01ae617c Author: Tollef Fog Heen Date: Tue Oct 2 08:38:49 2012 +0200 Don't put POLLHUP in .events POLLHUP is always checked for, and is output-only on Linux and OSX, so avoid putting it in the list of events we check for. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index cb58704..5a947f1 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1049,7 +1049,7 @@ cmd_http_expect_close(CMD_ARGS) vtc_log(vl, 4, "Expecting close (fd = %d)", hp->fd); while (1) { fds[0].fd = hp->fd; - fds[0].events = POLLIN | POLLHUP | POLLERR; + fds[0].events = POLLIN | POLLERR; fds[0].revents = 0; i = poll(fds, 1, 1000); if (i == 0) diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e97fab2..56db682 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -408,7 +408,7 @@ varnish_launch(struct varnish *v) fd[0].fd = v->cli_fd; fd[0].events = POLLIN; fd[1].fd = v->fds[0]; - fd[1].events = POLLHUP; + fd[1].events = 0; /* Only care about POLLHUP, which is output-only */ i = poll(fd, 2, 10000); vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x", i, fd[0].revents, fd[1].revents); From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] b8aa4f5 Document that lookup forces GET to the backend Message-ID: commit b8aa4f52c37f7d4c10e91b82a9fb60b5b376ae08 Author: Tollef Fog Heen Date: Wed Sep 26 10:52:52 2012 +0200 Document that lookup forces GET to the backend diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index c4b4f96..00edea8 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -489,7 +489,8 @@ vcl_recv lookup Look up the requested object in the cache. Control will eventually pass to vcl_hit or vcl_miss, depending on whether the - object is in the cache. + object is in the cache. The ``bereq.request`` value will be set + to ``GET`` regardless of the value of ``req.request``. vcl_pipe Called upon entering pipe mode. In this mode, the request is passed From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] cf0b132 Typo Message-ID: commit cf0b132f427959193eec6074eb3b8c1abc4a7a40 Author: Tollef Fog Heen Date: Wed Sep 26 10:52:58 2012 +0200 Typo diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 00edea8..c34fefb 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -211,7 +211,7 @@ This is useful is you are using Varnish to load balance in front of other Varnish caches or other web accelerators as objects won't be duplicated across caches. -It will use the value of req.hash, just as the normal cache-lookup methods. +It will use the value of req.hash, just as the normal cache lookup methods. The round-robin director From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 7dddf1b .gitignore log files from make check Message-ID: commit 7dddf1b7939587c78721efb57396ac4805e564d0 Author: Tollef Fog Heen Date: Mon Oct 15 10:39:38 2012 +0200 .gitignore log files from make check diff --git a/.gitignore b/.gitignore index 21fe76b..77be3db 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,8 @@ TAGS # NetBeans insists on this /nbproject/private/ + +# Test droppings +bin/varnishtest/tests/*.log +bin/varnishtest/tests/*.log-t +bin/varnishtest/test-suite.log From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 62e16fc Fix markup of function list Message-ID: commit 62e16fc0f7e004d4efbdf2f8cf67c0cffb85ae65 Author: Magnus Hagander Date: Tue Oct 16 14:23:16 2012 +0200 Fix markup of function list ban() was previously not in bold on the man page. Turn it into two separate entries with separate descritions to fix that. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index c34fefb..22e7031 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -430,6 +430,7 @@ regsuball(str, regex, sub) As regsuball() but this replaces all occurrences. ban(ban expression) + Bans all objects in cache that match the expression. ban_url(regex) Bans all objects in cache whose URLs match regex. From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] fcf695f PATCH: remove non-ascii characters and don't manually split words. Message-ID: commit fcf695faa7dde9495fa4f60c25d2f9fbbf862acc Author: Federico G. Schwindt Date: Mon Oct 29 22:12:47 2012 +0000 PATCH: remove non-ascii characters and don't manually split words. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 2064cd9..3204097 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -380,7 +380,7 @@ which can later be used to match client addresses: } If an ACL entry specifies a host name which Varnish is unable to -resolve, it will match any address it is com? pared to. Consequently, +resolve, it will match any address it is compared to. Consequently, if it is preceded by a negation mark, it will reject any address it is compared to, which may not be what you intended. If the entry is enclosed in parentheses, however, it will simply be ignored. @@ -511,8 +511,8 @@ vcl_pipe vcl_pass Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the - client, but is not entered into the cache. Subsequent requests sub? - mitted over the same client connection are handled normally. + client, but is not entered into the cache. Subsequent requests + submitted over the same client connection are handled normally. The vcl_pass subroutine may terminate with calling return() with one of the following keywords: From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] c9db023 Return false if req.backend.health is accessed in vcl_deliver{} where this information is no longer available. Message-ID: commit c9db023f8c83f9f11199e09073ccfd8ecd320181 Author: Poul-Henning Kamp Date: Tue Apr 9 13:05:14 2013 +0200 Return false if req.backend.health is accessed in vcl_deliver{} where this information is no longer available. Fixes #1228 diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c index 9a2e500..189d8e9 100644 --- a/bin/varnishd/cache_vrt_var.c +++ b/bin/varnishd/cache_vrt_var.c @@ -536,6 +536,12 @@ unsigned VRT_r_req_backend_healthy(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + /* + * XXX: Not optimal, but we do not have a backend in vcl_deliver + * XXX: and we have to return something. + */ + if (sp->director == NULL) + return (0); CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); return (VDI_Healthy(sp->director, sp)); } diff --git a/bin/varnishtest/tests/r01228.vcl b/bin/varnishtest/tests/r01228.vcl new file mode 100644 index 0000000..33bf365 --- /dev/null +++ b/bin/varnishtest/tests/r01228.vcl @@ -0,0 +1,18 @@ +varnishtest "req.backend.healthy in vcl_deliver" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_deliver { + set resp.http.x-foo = req.backend.healthy; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 5fa5a39 s/obj.cookie/obj.http.set-cookie/ Message-ID: commit 5fa5a398f8da27875809c2db6a054c3d8f34e9da Author: Tollef Fog Heen Date: Fri Nov 23 14:54:12 2012 +0100 s/obj.cookie/obj.http.set-cookie/ diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 5c1da57..c458ba0 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -33,7 +33,7 @@ * * req.url == "/foo" * req.url ~ ".iso" && obj.size > 10MB - * req.http.host ~ "web1.com" && obj.set-cookie ~ "USER=29293" + * req.http.host ~ "web1.com" && obj.http.set-cookie ~ "USER=29293" * * We make the "&&" mandatory from the start, leaving the syntax space * for latter handling of "||" as well. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index a4ec1b9..1b98615 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -316,7 +316,7 @@ Example: Ban all documents where the serving host is "example.com" or "www.example.com", and where the Set-Cookie header received from the backend contains "USERID=1663":: - req.http.host ~ "^(?i)(www\.)example.com$" && obj.set-cookie ~ "USERID=1663" + req.http.host ~ "^(?i)(www\.)example.com$" && obj.http.set-cookie ~ "USERID=1663" SEE ALSO ======== From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 677d34f varnishadm: Handle EINTR from poll Message-ID: commit 677d34f4b307a5276fa1adf6ad737983f869e279 Author: Tollef Fog Heen Date: Mon Feb 4 12:32:20 2013 +0100 varnishadm: Handle EINTR from poll poll can return EINTR, so we need to handle that. Fixes: #1166 diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 043aa38..1787d8e 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -223,6 +223,9 @@ pass(int sock) fds[1].events = POLLIN; while (1) { i = poll(fds, 2, -1); + if (i == -1 && errno == EINTR) { + continue; + } assert(i > 0); if (fds[0].revents & POLLIN) { /* Get rid of the prompt, kinda hackish */ From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 29fc35d Make send_line static and drop prototype Message-ID: commit 29fc35d711db6477008f3783ccd75f3dfcec80a9 Author: Tollef Fog Heen Date: Wed Feb 20 09:06:34 2013 +0100 Make send_line static and drop prototype diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 1787d8e..0dd15ec 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -61,8 +61,6 @@ exit(status); \ } while (0) -void send_line(char *l); - #else #define RL_EXIT(status) exit(status) #endif @@ -178,7 +176,7 @@ do_args(int sock, int argc, char * const *argv) * to have a global variable. */ static int _line_sock; -void send_line(char *l) +static void send_line(char *l) { if (l) { cli_write(_line_sock, l); From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 49d7e92 Set ulimit -u (RLIMIT_NPROC) to unlimited for RHEL init script. Message-ID: commit 49d7e92b2469845f8a1d21efa0fc925b6602fdb1 Author: Dag Haavi Finstad Date: Mon Feb 25 11:07:39 2013 +0100 Set ulimit -u (RLIMIT_NPROC) to unlimited for RHEL init script. diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc index 19cc274..4afa6c5 100755 --- a/redhat/varnish.initrc +++ b/redhat/varnish.initrc @@ -56,6 +56,10 @@ start() { # Varnish wants to lock shared memory log in memory. ulimit -l ${MEMLOCK:-82000} + # Maximum number of threads (default in CentOS is 1024, which + # is often too small for varnish) + ulimit -u ${NPROCS:-unlimited} + # $DAEMON_OPTS is set in /etc/sysconfig/varnish. At least, one # has to set up a backend, or /tmp will be used, which is a bad idea. if [ "$DAEMON_OPTS" = "" ]; then diff --git a/redhat/varnish.sysconfig b/redhat/varnish.sysconfig index d88712f..f5846c9 100644 --- a/redhat/varnish.sysconfig +++ b/redhat/varnish.sysconfig @@ -11,6 +11,9 @@ NFILES=131072 # Default log size is 82MB + header MEMLOCK=82000 +# Maximum number of threads (for ulimit -u) +NPROCS="unlimited" + # Maximum size of corefile (for ulimit -c). Default in Fedora is 0 # DAEMON_COREFILE_LIMIT="unlimited" From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] e5da6ec Use ndirector, not serial in DNS director. Message-ID: commit e5da6ec90ca3e9917ec65bf077cf0042bd9b9e94 Author: Tollef Fog Heen Date: Mon Apr 22 13:25:43 2013 +0200 Use ndirector, not serial in DNS director. The test case for this doesn't trigger, but the failing VCL (when given in a file with -f) looks like: director squid round-robin { { .backend = { .host = "127.0.0.1"; .port = "3131"; } } } director dnsdir dns { .list = { "201.7.184.0"/32; } } sub vcl_recv { set req.backend = dnsdir; } Fixes #1295 diff --git a/lib/libvcl/vcc_dir_dns.c b/lib/libvcl/vcc_dir_dns.c index 45c80c1..72a9efb 100644 --- a/lib/libvcl/vcc_dir_dns.c +++ b/lib/libvcl/vcc_dir_dns.c @@ -87,7 +87,7 @@ print_backend(struct vcc *tl, AN(vsb); tl->fb = vsb; Fc(tl, 0, "\t{ .host = VGC_backend_%s },\n",vgcname); - Fh(tl, 1, "\n#define VGC_backend_%s %d\n", vgcname, serial); + Fh(tl, 1, "\n#define VGC_backend_%s %d\n", vgcname, tl->ndirector); Fb(tl, 0, "\nstatic const struct vrt_backend vgc_dir_priv_%s = {\n", vgcname); From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 9d88a0e Add a bit of tab completion to varnishadm Message-ID: commit 9d88a0eb739cd048cd8ee5154eb240521f1685fb Author: Tollef Fog Heen Date: Wed Feb 20 09:17:21 2013 +0100 Add a bit of tab completion to varnishadm diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 0dd15ec..8e68715 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -186,6 +186,41 @@ static void send_line(char *l) RL_EXIT(0); } } + +static char *commands[256]; +static char * +command_generator (const char *text, int state) +{ + static int list_index, len; + const char *name; + + /* If this is a new word to complete, initialize now. This + includes saving the length of TEXT for efficiency, and + initializing the index variable to 0. */ + if (!state) { + list_index = 0; + len = strlen(text); + } + + while ((name = commands[list_index]) != NULL) { + list_index++; + if (strncmp (name, text, len) == 0) + return (strdup(name)); + } + /* If no names matched, then return NULL. */ + return (NULL); +} + +static char ** +varnishadm_completion (const char *text, int start, int end) +{ + char **matches; + (void)end; + matches = (char **)NULL; + if (start == 0) + matches = rl_completion_matches(text, command_generator); + return (matches); +} #endif /* @@ -212,13 +247,42 @@ pass(int sock) } else { rl_callback_handler_install("", send_line); } + rl_attempted_completion_function = varnishadm_completion; #endif - cli_write(sock, "banner\n"); fds[0].fd = sock; fds[0].events = POLLIN; fds[1].fd = 0; fds[1].events = POLLIN; + + /* Grab the commands, for completion */ + cli_write(sock, "help\n"); + u = VCLI_ReadResult(fds[0].fd, &status, &answer, timeout); + if (!u) { + char *t, c[128]; + if (status == CLIS_COMMS) { + RL_EXIT(0); + } + t = answer; + + i = 0; + while (*t) { + if (sscanf(t, "%127s", c) == 1) { + commands[i++] = strdup(c); + while (*t != '\n' && *t != '\0') + t++; + if (*t == '\n') + t++; + } else { + /* what? */ + fprintf(stderr, "Unknown command '%s' parsing " + "help output. Tab completion may be " + "broken\n", t); + break; + } + } + } + cli_write(sock, "banner\n"); while (1) { i = poll(fds, 2, -1); if (i == -1 && errno == EINTR) { From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 67b150a Fix the CLI ref documentation (including a bug in the built in docs). Message-ID: commit 67b150acb1233d3bcbacde0ddb269a4f3d24f1f8 Author: Per Buer Date: Thu Aug 23 10:19:01 2012 +0200 Fix the CLI ref documentation (including a bug in the built in docs). diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 637b8d6..033be5a 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -148,7 +148,6 @@ Commands start Start the Varnish cache process if it is not already running. -status status Check the status of the Varnish cache process. From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] d420192 Fix a race condition, the child thread could get to the first assert before the parent carried out the assignment of the thread id to the variable. Message-ID: commit d4201928a2b86858810d149293c4b754d612ed01 Author: Poul-Henning Kamp Date: Wed Aug 22 10:01:19 2012 +0000 Fix a race condition, the child thread could get to the first assert before the parent carried out the assignment of the thread id to the variable. Detected by: OSX diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index a4ba598..8acbc20 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -275,6 +275,7 @@ smp_thread(struct sess *sp, void *priv) (void)sp; CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC); + sc->thread = pthread_self(); /* First, load all the objects from all segments */ VTAILQ_FOREACH(sg, &sc->segments, list) @@ -306,6 +307,7 @@ static void smp_open(const struct stevedore *st) { struct smp_sc *sc; + pthread_t pt; ASSERT_CLI(); @@ -347,7 +349,7 @@ smp_open(const struct stevedore *st) smp_new_seg(sc); /* Start the worker silo worker thread, it will load the objects */ - WRK_BgThread(&sc->thread, "persistence", smp_thread, sc); + WRK_BgThread(&pt, "persistence", smp_thread, sc); VTAILQ_INSERT_TAIL(&silos, sc, list); Lck_Unlock(&sc->mtx); From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 3b49dc9 PATCH: document beresp.http.header Message-ID: commit 3b49dc9da50f26e16fd23ee8812b8e4dd0862ec9 Author: Federico G. Schwindt Date: Mon Oct 29 22:09:08 2012 +0000 PATCH: document beresp.http.header diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 3204097..fbe3857 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -817,6 +817,9 @@ beresp.do_gunzip Boolean. Unzip the object before storing it in the cache. Defaults to false. +beresp.http.header + The corresponding HTTP header. + beresp.proto The HTTP protocol version used the backend replied with. From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 7b4557a Prefer exact matches Message-ID: commit 7b4557a38969a3a000093c7f9ba9959cce5d3a6e Author: Tollef Fog Heen Date: Mon Apr 8 13:31:27 2013 +0200 Prefer exact matches If there are multiple matches for a given VSL tag (such as "Hit" matching both Hit and HitPass), prefer the one that is an exact match. Fixes #1288 diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 21cd8e9..070265d 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -67,6 +67,10 @@ VSL_Name2Tag(const char *name, int l) for (i = 0; i < 256; i++) { if (VSL_tags[i] != NULL && !strncasecmp(name, VSL_tags[i], l)) { + if (strlen(VSL_tags[i]) == l) { + /* Exact match */ + return (i); + } if (n == -1) n = i; else From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 94dd555 Documentation fix for error in vcl_deliver. Message-ID: commit 94dd555f6b13f1d0a9ff5d1ff3e2fddf1bd57cfd Author: Dag Haavi Finstad Date: Mon Oct 29 09:58:03 2012 +0100 Documentation fix for error in vcl_deliver. Fixed by: Federico G. Schwindt Fixes: #1216 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 22e7031..2064cd9 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -610,9 +610,6 @@ vcl_deliver deliver Deliver the object to the client. - error code [reason] - Return the specified error code to the client and abandon the request. - restart Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* varnish emits a guru meditation From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] ebba85f Disable the PCRE JIT compiler by default Message-ID: commit ebba85fe7832318083ddd2ba04def6947f15eb37 Author: Tollef Fog Heen Date: Tue Sep 4 08:16:50 2012 +0200 Disable the PCRE JIT compiler by default The JIT compiler is broken on some versions of PCRE, at least on i386, so disable it by default. It can be enabled using --enable-pcre-jit to configure. Fixes #1191 diff --git a/configure.ac b/configure.ac index 9e68374..403e301 100644 --- a/configure.ac +++ b/configure.ac @@ -556,6 +556,17 @@ fi AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code]) +# --enable-pcre-jit +AC_ARG_ENABLE(pcre-jit, + AS_HELP_STRING([--enable-pcre-jit], + [use the PCRE JIT compiler (default is NO)]), + , + [enable_pcre_jit=no]) + +if test "$enable_pcre_jit" = yes; then + AC_DEFINE([USE_PCRE_JIT],[1],[use the PCRE JIT compiler]) +fi + # Generate output AC_CONFIG_FILES([ Makefile diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c index 03626bf..5207a57 100644 --- a/lib/libvarnish/vre.c +++ b/lib/libvarnish/vre.c @@ -33,8 +33,10 @@ #include "miniobj.h" #include "vre.h" -#ifndef PCRE_STUDY_JIT_COMPILE -#define PCRE_STUDY_JIT_COMPILE 0 +#if USE_PCRE_JIT +#define VRE_STUDY_JIT_COMPILE PCRE_STUDY_JIT_COMPILE +#else +#define VRE_STUDY_JIT_COMPILE 0 #endif #if PCRE_MAJOR < 8 || (PCRE_MAJOR == 8 && PCRE_MINOR < 20) @@ -74,7 +76,7 @@ VRE_compile(const char *pattern, int options, VRE_free(&v); return (NULL); } - v->re_extra = pcre_study(v->re, PCRE_STUDY_JIT_COMPILE, errptr); + v->re_extra = pcre_study(v->re, VRE_STUDY_JIT_COMPILE, errptr); if (*errptr != NULL) { VRE_free(&v); return (NULL); From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] a75a58d Clarify storage backend usage Some more text describing the behaviour on the various storage backend + some reformatting for readability Message-ID: commit a75a58d39550df4368679fc5463bfdcb03c2b0a8 Author: Per Buer Date: Mon Aug 27 10:41:19 2012 +0200 Clarify storage backend usage Some more text describing the behaviour on the various storage backend + some reformatting for readability diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 351c7b3..c4baf6e 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -161,10 +161,16 @@ Storage Types The following storage types are available: malloc[,size] - Storage for each object is allocated with malloc(3). - The size parameter specifies the maximum amount of memory varnishd will allocate. The size is assumed to - be in bytes, unless followed by one of the following suffixes: + Malloc is a memory based backend. Each object will be allocated + from memory. If your system runs low on memory swap will be + used. Be aware that the size limitation only limits the actual + storage and that approximately 1k of memory per object will be + used for various internal structures. + + The size parameter specifies the maximum amount of memory + varnishd will allocate. The size is assumed to be in bytes, + unless followed by one of the following suffixes: K, k The size is expressed in kibibytes. @@ -174,16 +180,24 @@ malloc[,size] T, t The size is expressed in tebibytes. - The default size is unlimited. + The default size is unlimited. + + Mallocs performance is bound by memory speed so it is very fast. file[,path[,size[,granularity]]] - Storage for each object is allocated from an arena backed by a file. This is the default. - The path parameter specifies either the path to the backing file or the path to a directory in which - varnishd will create the backing file. The default is /tmp. + The file backend stores objects in memory backed by a file on + disk with mmap. This is the default storage backend and unless + you specify another storage this one will used along with + Transient storage. - The size parameter specifies the size of the backing file. The size is assumed to be in bytes, unless fol? - lowed by one of the following suffixes: + The path parameter specifies either the path to the backing file + or the path to a directory in which varnishd will create the + backing file. The default is /tmp. + + The size parameter specifies the size of the backing file. The + size is assumed to be in bytes, unless fol? lowed by one of the + following suffixes: K, k The size is expressed in kibibytes. @@ -193,21 +207,29 @@ file[,path[,size[,granularity]]] T, t The size is expressed in tebibytes. - % The size is expressed as a percentage of the free space on the file system where it resides. + % The size is expressed as a percentage of the free space on the + file system where it resides. The default size is 50%. - If the backing file already exists, it will be truncated or expanded to the specified size. + If the backing file already exists, it will be truncated or + expanded to the specified size. + + Note that if varnishd has to create or expand the file, it will + not pre-allocate the added space, leading to fragmentation, + which may adversely impact performance. Pre-creating the + storage file using dd(1) will reduce fragmentation to a minimum. - Note that if varnishd has to create or expand the file, it will not pre-allocate the added space, leading - to fragmentation, which may adversely impact performance. Pre-creating the storage file using dd(1) will - reduce fragmentation to a minimum. + The granularity parameter specifies the granularity of + allocation. All allocations are rounded up to this size. The + size is assumed to be in bytes, unless followed by one of the + suffixes described for size except for %. - The granularity parameter specifies the granularity of allocation. All allocations are rounded up to this - size. The size is assumed to be in bytes, unless followed by one of the suffixes described for size except - for %. + The default size is the VM page size. The size should be + reduced if you have many small objects. - The default size is the VM page size. The size should be reduced if you have many small objects. + File performance is typically limited by the write speed of the + device, and depending on use, the seek time. persistent,path,size {experimental} @@ -246,38 +268,47 @@ Transient Storage Management Interface -------------------- -If the -T option was specified, varnishd will offer a command-line management interface on the specified address -and port. The recommended way of connecting to the command-line management interface is through varnishadm(1). +If the -T option was specified, varnishd will offer a command-line +management interface on the specified address and port. The +recommended way of connecting to the command-line management interface +is through varnishadm(1). The commands available are documented in varnish(7). Run-Time Parameters ------------------- -Runtime parameters are marked with shorthand flags to avoid repeating the same text over and over in the table -below. The meaning of the flags are: +Runtime parameters are marked with shorthand flags to avoid repeating +the same text over and over in the table below. The meaning of the +flags are: experimental - We have no solid information about good/bad/optimal values for this parameter. Feedback with experience - and observations are most welcome. + We have no solid information about good/bad/optimal values for + this parameter. Feedback with experience and observations are + most welcome. delayed - This parameter can be changed on the fly, but will not take effect immediately. + This parameter can be changed on the fly, but will not take + effect immediately. restart - The worker process must be stopped and restarted, before this parameter takes effect. + The worker process must be stopped and restarted, before this + parameter takes effect. reload The VCL programs must be reloaded for this parameter to take effect. -Here is a list of all parameters, current as of last time we remembered to update the manual page. This text is -produced from the same text you will find in the CLI if you use the param.show command, so should there be a new -parameter which is not listed here, you can find the description using the CLI commands. +Here is a list of all parameters, current as of last time we +remembered to update the manual page. This text is produced from the +same text you will find in the CLI if you use the param.show command, +so should there be a new parameter which is not listed here, you can +find the description using the CLI commands. Be aware that on 32 bit systems, certain default values, such as -workspace_client (=16k), thread_pool_workspace (=16k), http_resp_size (=8k), -http_req_size (=12k), gzip_stack_buffer (=4k) and thread_pool_stack (=64k) are -reduced relative to the values listed here, in order to conserve VM space. +workspace_client (=16k), thread_pool_workspace (=16k), http_resp_size +(=8k), http_req_size (=12k), gzip_stack_buffer (=4k) and +thread_pool_stack (=64k) are reduced relative to the values listed +here, in order to conserve VM space. .. include:: params.rst From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 07d488c varnishlog: if -m given, but no -c and -b, assume both Message-ID: commit 07d488cb96c703dd7c0ccf7049448c6291f1f0cf Author: Tollef Fog Heen Date: Mon Feb 4 14:17:50 2013 +0100 varnishlog: if -m given, but no -c and -b, assume both If we don't add -c and -b in there, varnishlog will print all transactions that aren't associated with a session. That is likely to not be what the user wants. Fixes: #1071 diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index c7749cb..d15c485 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -48,7 +48,7 @@ #include "vsl.h" #include "varnishapi.h" -static int b_flag, c_flag; +static int b_flag = 0, c_flag = 0; /* Ordering-----------------------------------------------------------*/ @@ -329,6 +329,16 @@ main(int argc, char * const *argv) } } + /* If we're matching, we want either -b or -c, apply both if + * none are given. This prevents spurious noise in the log + * output. */ + if (b_flag == 0 && c_flag == 0 && m_flag) { + b_flag = 1; + AN(VSL_Arg(vd, 'b', NULL)); + c_flag = 1; + AN(VSL_Arg(vd, 'c', NULL)); + } + if (O_flag && m_flag) usage(); From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] afb0827 Fix an off-by-one in an error message Message-ID: commit afb0827a711c2b760c6f0cef94cb03b08794748a Author: Poul-Henning Kamp Date: Thu Oct 25 08:30:29 2012 +0000 Fix an off-by-one in an error message diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index 655ee63..4897426 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -651,7 +651,7 @@ vcc_DefBackend(struct vcc *tl, const struct token *nm) sym = VCC_GetSymbolTok(tl, nm, SYM_BACKEND); AN(sym); if (sym->ndef > 0) { - VSB_printf(tl->sb, "Backend %.*s redefined\n", PF(tl->t)); + VSB_printf(tl->sb, "Backend %.*s redefined\n", PF(nm)); vcc_ErrWhere(tl, nm); return; } From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] b9d16c5 No point in referencing ancient history Message-ID: commit b9d16c51b12e537bc4f62d233000308909fc692d Author: Tollef Fog Heen Date: Mon Nov 12 09:40:39 2012 +0100 No point in referencing ancient history diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index fbe3857..fd4f588 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -395,9 +395,8 @@ To match an IP address against an ACL, simply use the match operator: Regular Expressions ------------------- -In Varnish 2.1.0 Varnish switched to using PCRE - Perl-compatible -regular expressions. For a complete description of PCRE please see the -PCRE(3) man page. +Varnish uses PCRE - Perl-compatible regular expressions. For a +complete description of PCRE please see the pcre(3) man page. To send flags to the PCRE engine, such as to turn on *case insensitivity* add the flag within parens following a question mark, From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 5103801 Use memchr rather than strchr/index Message-ID: commit 5103801ff1ba7c8f6bb1522d6f6f2ac3bcc22288 Author: Tollef Fog Heen Date: Mon Oct 15 12:56:15 2012 +0200 Use memchr rather than strchr/index the strings we get from the libvarnishapi functions are not necessarily null-terminated, so avoid using str* functions on them. Thanks to lampe for the patch. Fixes #1115 diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index dc7b4f9..f9fbfa7 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -316,7 +316,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, clean_logline(lp); break; } - qs = index(ptr, '?'); + qs = memchr(ptr, '?', len); if (qs) { trimline(&lp->df_U, ptr, qs); trimline(&lp->df_q, qs, end); @@ -360,7 +360,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_TxHeader: if (!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; if (isprefix(ptr, "authorization:", end, &next) && @@ -435,7 +435,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, clean_logline(lp); break; } - qs = index(ptr, '?'); + qs = memchr(ptr, '?', len); if (qs) { trimline(&lp->df_U, ptr, qs); trimline(&lp->df_q, qs, end); @@ -468,7 +468,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_RxHeader: if (!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; if (tag == SLT_RxHeader && @@ -493,7 +493,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, if(!lp->active) break; - split = strchr(ptr, ':'); + split = memchr(ptr, ':', len); if (split == NULL) break; From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] 54456ac stats are no longer in CLI Message-ID: commit 54456ac8bc1014a2a923a502a10b43e7794ab743 Author: Andreas Plesner Jacobsen Date: Tue Apr 17 22:25:56 2012 +0200 stats are no longer in CLI diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index ff86cb3..637b8d6 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -28,9 +28,6 @@ parameters available through the CLI. The individual parameters are documented in the varnishd(1) man page. -statistics - Statistic counters are available from the CLI. - bans Bans are filters that are applied to keep Varnish from serving stale content. When you issue a ban Varnish will not serve any @@ -151,13 +148,6 @@ Commands start Start the Varnish cache process if it is not already running. -stats - Show summary statistics. - - All the numbers presented are totals since server startup; for a - better idea of the current situation, use the varnishstat(1) - utility. - status status Check the status of the Varnish cache process. From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] aab3450 Set the split character back to '=' after applying the runtime parameter to preserve the arguments as seen e.g. ps. Message-ID: commit aab34502bce139233d91b7e19fb5aa9a7eb167a0 Author: Martin Blix Grydeland Date: Thu Dec 13 13:13:38 2012 +0100 Set the split character back to '=' after applying the runtime parameter to preserve the arguments as seen e.g. ps. Fixes: #1238 diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index fbf5713..2f88409 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -480,6 +480,7 @@ main(int argc, char * const *argv) AN(p); *p++ = '\0'; MCF_ParamSet(cli, optarg, p); + *--p = '='; cli_check(cli); break; case 's': From tfheen at varnish-cache.org Mon Apr 22 11:27:00 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:00 +0200 Subject: [3.0] fde20f7 A couple of cleanups to get OSX to be more happy. Message-ID: commit fde20f7adb6cd51cff84fe4731f3b9da1ed3217f Author: Poul-Henning Kamp Date: Wed Aug 22 09:31:21 2012 +0000 A couple of cleanups to get OSX to be more happy. diff --git a/bin/varnishd/storage_persistent.h b/bin/varnishd/storage_persistent.h index 2a5bd77..9536ab8 100644 --- a/bin/varnishd/storage_persistent.h +++ b/bin/varnishd/storage_persistent.h @@ -42,7 +42,7 @@ #endif #define ASSERT_SILO_THREAD(sc) \ - do {assert(pthread_self() == (sc)->thread);} while (0) + do {assert(pthread_equal(pthread_self(), (sc)->thread));} while (0) #define OC_F_NEEDFIXUP OC_F_PRIV diff --git a/bin/varnishtest/tests/r01035.vtc b/bin/varnishtest/tests/r01035.vtc index ccd6078..4bcb735 100644 --- a/bin/varnishtest/tests/r01035.vtc +++ b/bin/varnishtest/tests/r01035.vtc @@ -1,6 +1,6 @@ varnishtest "Test case for #1035" -varnish v1 -arg "-a 127.0.0.1:80 -b localhost:8080" +varnish v1 -arg "-a 127.0.0.1:80 -b 127.0.0.1:8080" varnish v1 -cliok "param.set listen_address 127.0.0.1:80" varnish v1 -clierr 106 "param.set listen_address 127.0.0.1:65540" varnish v1 -clierr 106 "param.set listen_address 127.0.0.1:65536" From tfheen at varnish-cache.org Mon Apr 22 11:27:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 13:27:01 +0200 Subject: [3.0] 26b4509 Make Message-ID: commit 26b450904c39eb2b056e42846bd11be2993866e9 Author: Poul-Henning Kamp Date: Thu Oct 18 22:07:29 2012 +0000 Make set req.http.Cookie = req.http.Cookie + " " + req.http.Cookie-sess; do the obvious thing, even if req.http.Cookie does not exist. The underlying issue was a badly though through overloading of the NULL value to mean "Unset". Now it has its own magic marker. Fixes #1218 diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index c17c361..ca57b95 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -51,6 +51,7 @@ #include "cache_backend.h" const void * const vrt_magic_string_end = &vrt_magic_string_end; +const void * const vrt_magic_string_unset = &vrt_magic_string_unset; /*--------------------------------------------------------------------*/ @@ -224,7 +225,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); hp = vrt_selecthttp(sp, where); va_start(ap, p); - if (p == NULL) { + if (p == vrt_magic_string_unset) { http_Unset(hp, hdr); } else { b = VRT_String(hp->ws, hdr + 1, p, ap); diff --git a/bin/varnishtest/tests/r01218.vtc b/bin/varnishtest/tests/r01218.vtc new file mode 100644 index 0000000..ed87746 --- /dev/null +++ b/bin/varnishtest/tests/r01218.vtc @@ -0,0 +1,20 @@ +varnishtest "regression for NULL string concatenation" + +server s1 { + rxreq + expect req.http.Candy == "FOOBAR" + expect req.http.Cookie == "FOOBAR" + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.http.Candy = " FOOBAR" + req.http.Cookie; + set req.http.Cookie = req.http.Cookie + " FOOBAR"; + } +} -start + +client c1 { + txreq + rxresp +} -run diff --git a/include/vrt.h b/include/vrt.h index 72c4cfe..3a90c05 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -43,6 +43,7 @@ struct sockaddr_storage; */ extern const void * const vrt_magic_string_end; +extern const void * const vrt_magic_string_unset; struct vrt_backend_probe { const char *url; diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index 033149b..1d0a62d 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -170,7 +170,7 @@ parse_unset(struct vcc *tl) return; } ERRCHK(tl); - Fb(tl, 1, "%s0);\n", vp->lname); + Fb(tl, 1, "%svrt_magic_string_unset);\n", vp->lname); vcc_NextToken(tl); } From tfheen at varnish-cache.org Mon Apr 22 12:22:55 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Apr 2013 14:22:55 +0200 Subject: [master] 433e86f Set the waiter pipe as non-blocking and record overflows Message-ID: commit 433e86f030648db20a7a8f7d43f20ce9be7581e6 Author: Tollef Fog Heen Date: Tue Apr 9 08:25:26 2013 +0200 Set the waiter pipe as non-blocking and record overflows Fixes #1285 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a284289..3a0fb92 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1039,6 +1039,7 @@ void VMOD_Init(void); void WAIT_Enter(struct sess *sp); void WAIT_Init(void); const char *WAIT_GetName(void); +void WAIT_Write_Session(struct sess *sp, int fd); /* cache_wrk.c */ diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 53d7f0f..1b868fe 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "cache/cache.h" @@ -77,3 +78,16 @@ WAIT_Enter(struct sess *sp) SES_Close(sp, SC_REM_CLOSE); waiter->pass(waiter_priv, sp); } + +void +WAIT_Write_Session(struct sess *sp, int fd) +{ + ssize_t written; + written = write(fd, &sp, sizeof sp); + if (written != sizeof sp && (errno == EAGAIN || errno == EWOULDBLOCK)) { + VSC_C_main->sess_pipe_overflow++; + SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); + return; + } + assert (written == sizeof sp); +} diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index a15bbe5..ba41210 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -37,19 +37,19 @@ #include -#include #include #include "cache/cache.h" #include "waiter/waiter.h" #include "vtim.h" +#include "vfil.h" #ifndef EPOLLRDHUP # define EPOLLRDHUP 0 #endif -#define NEEV 100 +#define NEEV 8192 struct vwe { unsigned magic; @@ -220,12 +220,13 @@ vwe_timeout_idle_ticker(void *priv) /*--------------------------------------------------------------------*/ static void -vwe_pass(void *priv, const struct sess *sp) +vwe_pass(void *priv, struct sess *sp) { struct vwe *vwe; CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC); - assert(sizeof sp == write(vwe->pipes[1], &sp, sizeof sp)); + + WAIT_Write_Session(sp, vwe->pipes[1]); } /*--------------------------------------------------------------------*/ @@ -233,7 +234,6 @@ vwe_pass(void *priv, const struct sess *sp) static void * vwe_init(void) { - int i; struct vwe *vwe; ALLOC_OBJ(vwe, VWE_MAGIC); @@ -242,17 +242,9 @@ vwe_init(void) AZ(pipe(vwe->pipes)); AZ(pipe(vwe->timer_pipes)); - i = fcntl(vwe->pipes[0], F_GETFL); - assert(i != -1); - i |= O_NONBLOCK; - i = fcntl(vwe->pipes[0], F_SETFL, i); - assert(i != -1); - - i = fcntl(vwe->timer_pipes[0], F_GETFL); - assert(i != -1); - i |= O_NONBLOCK; - i = fcntl(vwe->timer_pipes[0], F_SETFL, i); - assert(i != -1); + AZ(VFIL_nonblocking(vwe->pipes[0])); + AZ(VFIL_nonblocking(vwe->pipes[1])); + AZ(VFIL_nonblocking(vwe->timer_pipes[0])); AZ(pthread_create(&vwe->timer_thread, NULL, vwe_timeout_idle_ticker, vwe)); diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 8d37ad6..1c51399 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -38,7 +38,6 @@ #include #include -#include #include #include @@ -46,6 +45,7 @@ #include "waiter/waiter.h" #include "vtim.h" +#include "vfil.h" #define NKEV 100 @@ -210,12 +210,13 @@ vwk_thread(void *priv) /*--------------------------------------------------------------------*/ static void -vwk_pass(void *priv, const struct sess *sp) +vwk_pass(void *priv, struct sess *sp) { struct vwk *vwk; CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC); - assert(sizeof sp == write(vwk->pipes[1], &sp, sizeof sp)); + + WAIT_Write_Session(sp, vwk->pipes[1]); } /*--------------------------------------------------------------------*/ @@ -223,7 +224,6 @@ vwk_pass(void *priv, const struct sess *sp) static void * vwk_init(void) { - int i; struct vwk *vwk; ALLOC_OBJ(vwk, VWK_MAGIC); @@ -232,11 +232,8 @@ vwk_init(void) VTAILQ_INIT(&vwk->sesshead); AZ(pipe(vwk->pipes)); - i = fcntl(vwk->pipes[0], F_GETFL); - assert(i != -1); - i |= O_NONBLOCK; - i = fcntl(vwk->pipes[0], F_SETFL, i); - assert(i != -1); + AZ(VFIL_nonblocking(vwk->pipes[0])); + AZ(VFIL_nonblocking(vwk->pipes[1])); AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk)); return (vwk); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 4339617..d2c29d1 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -30,6 +30,7 @@ #include "config.h" +#include #include #include @@ -37,6 +38,7 @@ #include "waiter/waiter.h" #include "vtim.h" +#include "vfil.h" #define NEEV 128 @@ -191,13 +193,13 @@ vwp_main(void *priv) /*--------------------------------------------------------------------*/ static void -vwp_poll_pass(void *priv, const struct sess *sp) +vwp_poll_pass(void *priv, struct sess *sp) { struct vwp *vwp; CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC); - assert(sizeof sp == write(vwp->pipes[1], &sp, sizeof sp)); + WAIT_Write_Session(sp, vwp->pipes[1]); } /*--------------------------------------------------------------------*/ @@ -211,6 +213,9 @@ vwp_poll_init(void) AN(vwp); VTAILQ_INIT(&vwp->sesshead); AZ(pipe(vwp->pipes)); + + AZ(VFIL_nonblocking(vwp->pipes[1])); + vwp_pollspace(vwp, 256); AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp)); return (vwp); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 3c07b95..a3bd96d 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -240,14 +240,18 @@ vws_thread(void *priv) /*--------------------------------------------------------------------*/ static void -vws_pass(void *priv, const struct sess *sp) +vws_pass(void *priv, struct sess *sp) { int r; struct vws *vws; CAST_OBJ_NOTNULL(vws, priv, VWS_MAGIC); - while((r = port_send(vws->dport, 0, TRUST_ME(sp))) == -1 && - errno == EAGAIN); + r = port_send(vws->dport, 0, TRUST_ME(sp)); + if (r == -1 && errno == EAGAIN) { + VSC_C_main->sess_pipe_overflow++; + SES_Delete(sp, SC_SESS_PIPE_OVERFLOW, NAN); + return; + } AZ(r); } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 9f9f795..ce46e4d 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -31,7 +31,7 @@ struct sess; typedef void* waiter_init_f(void); -typedef void waiter_pass_f(void *priv, const struct sess *); +typedef void waiter_pass_f(void *priv, struct sess *); #define WAITER_DEFAULT "platform dependent" diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index c9d28ba..6246a51 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -39,5 +39,6 @@ SESS_CLOSE(TX_PIPE, "Piped transaction") SESS_CLOSE(TX_ERROR, "Error transaction") SESS_CLOSE(TX_EOF, "EOF transmission") SESS_CLOSE(OVERLOAD, "Out of some resource") +SESS_CLOSE(SESS_PIPE_OVERFLOW, "Session pipe overflow") /*lint -restore */ diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 3f6d3fe..6506668 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -88,6 +88,11 @@ VSC_F(sess_fail, uint64_t, 1, 'c', " some resource like filedescriptors." ) +VSC_F(sess_pipe_overflow, uint64_t, 1, 'c', + "Session pipe overflow", + "Count of sessions dropped due to the session pipe overflowing." +) + /*---------------------------------------------------------------------*/ VSC_F(client_req_400, uint64_t, 1, 'a', diff --git a/include/vfil.h b/include/vfil.h index 74885ef..533dfd8 100644 --- a/include/vfil.h +++ b/include/vfil.h @@ -33,3 +33,4 @@ int seed_random(void); int VFIL_tmpfile(char *); char *VFIL_readfile(const char *pfx, const char *fn, ssize_t *sz); char *VFIL_readfd(int fd, ssize_t *sz); +int VFIL_nonblocking(int fd); diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index 6bcbde5..df02a48 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -123,3 +123,16 @@ VFIL_readfile(const char *pfx, const char *fn, ssize_t *sz) errno = err; return (r); } + +int +VFIL_nonblocking(int fd) +{ + int i; + + i = fcntl(fd, F_GETFL); + assert(i != -1); + i |= O_NONBLOCK; + i = fcntl(fd, F_SETFL, i); + assert(i != -1); + return (i); +} From phk at varnish-cache.org Mon Apr 22 13:09:22 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 15:09:22 +0200 Subject: [master] 931fa70 Move be*.status to use busyobj Message-ID: commit 931fa7061e329a5367c9517d5daf3c9bdc79686f Author: Poul-Henning Kamp Date: Mon Apr 22 13:09:11 2013 +0000 Move be*.status to use busyobj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8378095..bd75951 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -81,6 +81,24 @@ VRT_r_##obj##_##hdr(const struct CPAR *px) \ return (http->hd[fld].b); \ } +#define VRT_DO_STATUS(obj, http) \ +void \ +VRT_l_##obj##_status(const struct CPAR *px, long num) \ +{ \ + \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ + assert(num >= 100 && num <= 999); \ + http->status = (uint16_t)num; \ +} \ + \ +long \ +VRT_r_##obj##_status(const struct CPAR *px) \ +{ \ + \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ + return(http->status); \ +} + #define CPAR req #define CMAGIC REQ_MAGIC VRT_DO_HDR(req, method, px->http, HTTP_HDR_METHOD) @@ -89,9 +107,11 @@ VRT_DO_HDR(req, url, px->http, HTTP_HDR_URL) VRT_DO_HDR(req, proto, px->http, HTTP_HDR_PROTO) VRT_DO_HDR(obj, proto, px->obj->http, HTTP_HDR_PROTO) VRT_DO_HDR(obj, response, px->obj->http, HTTP_HDR_RESPONSE) +VRT_DO_STATUS(obj, px->obj->http) VRT_DO_HDR(resp, proto, px->resp, HTTP_HDR_PROTO) VRT_DO_HDR(resp, response, px->resp, HTTP_HDR_RESPONSE) -#undef CPAR +VRT_DO_STATUS(resp, px->resp) +#undef CPAR #undef CMAGIC #define CPAR busyobj @@ -102,35 +122,12 @@ VRT_DO_HDR(bereq, url, px->bereq, HTTP_HDR_URL) VRT_DO_HDR(bereq, proto, px->bereq, HTTP_HDR_PROTO) VRT_DO_HDR(beresp, proto, px->beresp, HTTP_HDR_PROTO) VRT_DO_HDR(beresp, response, px->beresp, HTTP_HDR_RESPONSE) -#undef CPAR +VRT_DO_STATUS(beresp, px->beresp) +#undef CPAR #undef CMAGIC /*--------------------------------------------------------------------*/ -#define VRT_DO_STATUS(obj, http) \ -void \ -VRT_l_##obj##_status(const struct req *req, long num) \ -{ \ - \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - assert(num >= 100 && num <= 999); \ - http->status = (uint16_t)num; \ -} \ - \ -long \ -VRT_r_##obj##_status(const struct req *req) \ -{ \ - \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - return(http->status); \ -} - -VRT_DO_STATUS(obj, req->obj->http) -VRT_DO_STATUS(beresp, req->busyobj->beresp) -VRT_DO_STATUS(resp, req->resp) - -/*--------------------------------------------------------------------*/ - /* XXX: review this */ /* Add an objecthead to the saintmode list for the (hopefully) relevant * backend. Some double-up asserting here to avoid assert-errors when there diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 2bd958e..b38eb8e 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -301,7 +301,7 @@ sp_variables = ( 'INT', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'cB' ), ('beresp.response', 'STRING', From phk at varnish-cache.org Mon Apr 22 13:17:47 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 15:17:47 +0200 Subject: [master] 3e2c418 Move the beresp.do_* variables to busyobj Message-ID: commit 3e2c418dd640dbf5cf2da2008c87faf925168b0d Author: Poul-Henning Kamp Date: Mon Apr 22 13:17:36 2013 +0000 Move the beresp.do_* variables to busyobj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index bd75951..3b5bcc7 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -190,25 +190,25 @@ VRT_l_beresp_saintmode(const struct req *req, double a) #define VBERESP(dir, type, onm, field) \ void \ -VRT_l_##dir##_##onm(const struct req *req, type a) \ +VRT_l_##dir##_##onm(struct busyobj *bo, type a) \ { \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - req->field = a; \ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ + bo->field = a; \ } \ \ type \ -VRT_r_##dir##_##onm(const struct req *req) \ +VRT_r_##dir##_##onm(const struct busyobj *bo) \ { \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - return (req->field); \ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ + return (bo->field); \ } -VBERESP(beresp, unsigned, do_esi, busyobj->do_esi) -VBERESP(beresp, unsigned, do_gzip, busyobj->do_gzip) -VBERESP(beresp, unsigned, do_gunzip, busyobj->do_gunzip) -VBERESP(beresp, unsigned, do_stream, busyobj->do_stream) -VBERESP(beresp, unsigned, do_pass, busyobj->do_pass) -VBERESP(beresp, unsigned, uncacheable, busyobj->do_pass) +VBERESP(beresp, unsigned, do_esi, do_esi) +VBERESP(beresp, unsigned, do_gzip, do_gzip) +VBERESP(beresp, unsigned, do_gunzip, do_gunzip) +VBERESP(beresp, unsigned, do_stream, do_stream) +VBERESP(beresp, unsigned, do_pass, do_pass) +VBERESP(beresp, unsigned, uncacheable, do_pass) /*--------------------------------------------------------------------*/ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index b38eb8e..67fe7af 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -319,37 +319,37 @@ sp_variables = ( 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.do_stream', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.do_gzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.do_gunzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.do_pass', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.uncacheable', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'B' ), ('beresp.ttl', 'DURATION', From phk at varnish-cache.org Mon Apr 22 13:36:05 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 15:36:05 +0200 Subject: [master] 4118ad5 Move the backend timeout vars to busyobj Message-ID: commit 4118ad53f99a8400f1a6e4216b145d6c233f2184 Author: Poul-Henning Kamp Date: Mon Apr 22 13:35:54 2013 +0000 Move the backend timeout vars to busyobj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 3b5bcc7..307ae1a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -239,21 +239,19 @@ VRT_l_client_identity(struct req *req, const char *str, ...) #define BEREQ_TIMEOUT(which) \ void \ -VRT_l_bereq_##which(const struct req *req, double num) \ +VRT_l_bereq_##which(struct busyobj *bo, double num) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); \ - req->busyobj->which = (num > 0.0 ? num : 0.0); \ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ + bo->which = (num > 0.0 ? num : 0.0); \ } \ \ double \ -VRT_r_bereq_##which(const struct req *req) \ +VRT_r_bereq_##which(const struct busyobj *bo) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); \ - return(req->busyobj->which); \ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ + return (bo->which); \ } BEREQ_TIMEOUT(connect_timeout) diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 67fe7af..e6d78fe 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -271,19 +271,19 @@ sp_variables = ( 'DURATION', ( 'pipe', 'backend_fetch', 'pass', 'miss',), ( 'pipe', 'backend_fetch', 'pass', 'miss',), - 'cR' + 'B' ), ('bereq.first_byte_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'cR' + 'B' ), ('bereq.between_bytes_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'cR' + 'B' ), ('beresp.proto', 'STRING', From phk at varnish-cache.org Mon Apr 22 20:07:51 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 22:07:51 +0200 Subject: [master] c463be3 Move beresp.storage to busyobj Message-ID: commit c463be36739380fa04a3be234ffaf5b1bd06b714 Author: Poul-Henning Kamp Date: Mon Apr 22 20:07:41 2013 +0000 Move beresp.storage to busyobj diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3a0fb92..232e2f1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -537,6 +537,8 @@ struct busyobj { double first_byte_timeout; double between_bytes_timeout; + const char *storage_hint; + struct vsl_log vsl[1]; struct dstat *stats; }; @@ -645,8 +647,6 @@ struct req { struct objcore *objcore; /* Lookup stuff */ struct SHA256Context *sha256ctx; - /* This is only here so VRT can find it */ - const char *storage_hint; /* ESI delivery stuff */ int gzip_resp; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 17222a0..3c6c96d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -362,7 +362,7 @@ cnt_fetch(struct worker *wrk, struct req *req) AN(req->director); AZ(bo->vbc); AZ(bo->should_close); - AZ(req->storage_hint); + AZ(bo->storage_hint); HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp); @@ -445,10 +445,10 @@ cnt_fetch(struct worker *wrk, struct req *req) req->objcore = NULL; } assert(bo->refcount == 2); + bo->storage_hint = NULL; VBO_DerefBusyObj(wrk, &bo); VBO_DerefBusyObj(wrk, &req->busyobj); req->director = NULL; - req->storage_hint = NULL; switch (wrk->handling) { case VCL_RET_RESTART: @@ -601,11 +601,11 @@ cnt_fetchbody(struct worker *wrk, struct req *req) if (bo->exp.ttl < cache_param->shortlived || req->objcore == NULL) - req->storage_hint = TRANSIENT_STORAGE; + bo->storage_hint = TRANSIENT_STORAGE; AZ(bo->stats); bo->stats = &wrk->stats; - req->obj = STV_NewObject(bo, &req->objcore, req->storage_hint, l, + req->obj = STV_NewObject(bo, &req->objcore, bo->storage_hint, l, nhttp); if (req->obj == NULL) { /* @@ -631,7 +631,7 @@ cnt_fetchbody(struct worker *wrk, struct req *req) } CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - req->storage_hint = NULL; + bo->storage_hint = NULL; AZ(bo->fetch_obj); bo->fetch_obj = req->obj; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 307ae1a..5c5e72b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -288,26 +288,26 @@ VRT_r_beresp_backend_port(const struct req *req) } const char * -VRT_r_beresp_storage(const struct req *req) +VRT_r_beresp_storage(const struct busyobj *bo) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->storage_hint != NULL) - return (req->storage_hint); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + if (bo->storage_hint != NULL) + return (bo->storage_hint); else return (NULL); } void -VRT_l_beresp_storage(struct req *req, const char *str, ...) +VRT_l_beresp_storage(struct busyobj *bo, const char *str, ...) { va_list ap; char *b; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); va_start(ap, str); - b = VRT_String(req->busyobj->ws, NULL, str, ap); + b = VRT_String(bo->ws, NULL, str, ap); va_end(ap); - req->storage_hint = b; + bo->storage_hint = b; } /*--------------------------------------------------------------------*/ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index e6d78fe..eca1974 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -391,7 +391,7 @@ sp_variables = ( 'STRING', ( 'backend_response',), ( 'backend_response',), - 'R' + 'B' ), ('obj.proto', 'STRING', From phk at varnish-cache.org Mon Apr 22 20:32:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 22:32:58 +0200 Subject: [master] ee5ded3 Rearrange the ttl/grace/keep VRT functions Message-ID: commit ee5ded36bb236c4ec5717cbf77e437cc4cd4f6ac Author: Poul-Henning Kamp Date: Mon Apr 22 20:32:40 2013 +0000 Rearrange the ttl/grace/keep VRT functions diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5c5e72b..d2e5b63 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -405,12 +405,13 @@ VRT_r_##which##_##fld(const struct req *req) \ } static void -vrt_wsp_exp(struct req *req, unsigned xid, const struct exp *e) +vrt_wsp_exp(struct vsl_log *vsl, unsigned xid, double now, const struct exp *e) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - VSLb(req->vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f", - xid, e->ttl - (req->t_req - e->entered), e->grace, e->keep, - req->t_req, e->age + (req->t_req - e->entered)); + double dt; + + dt = now - e->entered; + VSLb(vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f", + xid, e->ttl - dt, e->grace, e->keep, now, e->age + dt); } VRT_DO_EXP(req, req->exp, ttl, 0, ) @@ -419,21 +420,24 @@ VRT_DO_EXP(req, req->exp, keep, 0, ) VRT_DO_EXP(obj, req->obj->exp, grace, 0, EXP_Rearm(req->obj); - vrt_wsp_exp(req, req->obj->vxid, &req->obj->exp);) + vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) VRT_DO_EXP(obj, req->obj->exp, ttl, (req->t_req - req->obj->exp.entered), EXP_Rearm(req->obj); - vrt_wsp_exp(req, req->obj->vxid, &req->obj->exp);) + vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) VRT_DO_EXP(obj, req->obj->exp, keep, 0, EXP_Rearm(req->obj); - vrt_wsp_exp(req, req->obj->vxid, &req->obj->exp);) + vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) VRT_DO_EXP(beresp, req->busyobj->exp, grace, 0, - vrt_wsp_exp(req, req->vsl->wid & VSL_IDENTMASK, &req->busyobj->exp);) + vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, + req->busyobj->exp.entered, &req->busyobj->exp);) VRT_DO_EXP(beresp, req->busyobj->exp, ttl, 0, - vrt_wsp_exp(req, req->vsl->wid & VSL_IDENTMASK, &req->busyobj->exp);) + vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, + req->busyobj->exp.entered, &req->busyobj->exp);) VRT_DO_EXP(beresp, req->busyobj->exp, keep, 0, - vrt_wsp_exp(req, req->vsl->wid & VSL_IDENTMASK, &req->busyobj->exp);) + vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, + req->busyobj->exp.entered, &req->busyobj->exp);) /*-------------------------------------------------------------------- * req.xid From phk at varnish-cache.org Mon Apr 22 20:46:51 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 22 Apr 2013 22:46:51 +0200 Subject: [master] 6bc1ffc Move beresp.ttl/grace/keep to busyobj Message-ID: commit 6bc1ffc3bd1e06d0b03fb68a99974fd7b64d8953 Author: Poul-Henning Kamp Date: Mon Apr 22 20:46:37 2013 +0000 Move beresp.ttl/grace/keep to busyobj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index d2e5b63..8cc2d69 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -386,10 +386,10 @@ VRT_r_req_restarts(const struct req *req) #define VRT_DO_EXP(which, exp, fld, offset, extra) \ \ void \ -VRT_l_##which##_##fld(struct req *req, double a) \ +VRT_l_##which##_##fld(struct CPAR *px, double a) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ if (a > 0.) \ a += offset; \ EXP_Set_##fld(&exp, a); \ @@ -397,10 +397,10 @@ VRT_l_##which##_##fld(struct req *req, double a) \ } \ \ double \ -VRT_r_##which##_##fld(const struct req *req) \ +VRT_r_##which##_##fld(const struct CPAR *px) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ + CHECK_OBJ_NOTNULL(px, CMAGIC); \ return(EXP_Get_##fld(&exp) - offset); \ } @@ -414,30 +414,38 @@ vrt_wsp_exp(struct vsl_log *vsl, unsigned xid, double now, const struct exp *e) xid, e->ttl - dt, e->grace, e->keep, now, e->age + dt); } -VRT_DO_EXP(req, req->exp, ttl, 0, ) -VRT_DO_EXP(req, req->exp, grace, 0, ) -VRT_DO_EXP(req, req->exp, keep, 0, ) - -VRT_DO_EXP(obj, req->obj->exp, grace, 0, - EXP_Rearm(req->obj); - vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) -VRT_DO_EXP(obj, req->obj->exp, ttl, - (req->t_req - req->obj->exp.entered), - EXP_Rearm(req->obj); - vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) -VRT_DO_EXP(obj, req->obj->exp, keep, 0, - EXP_Rearm(req->obj); - vrt_wsp_exp(req->vsl, req->obj->vxid, req->t_req, &req->obj->exp);) - -VRT_DO_EXP(beresp, req->busyobj->exp, grace, 0, - vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, - req->busyobj->exp.entered, &req->busyobj->exp);) -VRT_DO_EXP(beresp, req->busyobj->exp, ttl, 0, - vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, - req->busyobj->exp.entered, &req->busyobj->exp);) -VRT_DO_EXP(beresp, req->busyobj->exp, keep, 0, - vrt_wsp_exp(req->vsl, req->vsl->wid & VSL_IDENTMASK, - req->busyobj->exp.entered, &req->busyobj->exp);) +#define CPAR req +#define CMAGIC REQ_MAGIC +VRT_DO_EXP(req, px->exp, ttl, 0, ) +VRT_DO_EXP(req, px->exp, grace, 0, ) +VRT_DO_EXP(req, px->exp, keep, 0, ) + +VRT_DO_EXP(obj, px->obj->exp, grace, 0, + EXP_Rearm(px->obj); + vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) +VRT_DO_EXP(obj, px->obj->exp, ttl, + (px->t_req - px->obj->exp.entered), + EXP_Rearm(px->obj); + vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) +VRT_DO_EXP(obj, px->obj->exp, keep, 0, + EXP_Rearm(px->obj); + vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) +#undef CPAR +#undef CMAGIC + +#define CPAR busyobj +#define CMAGIC BUSYOBJ_MAGIC +VRT_DO_EXP(beresp, px->exp, grace, 0, + vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, + px->exp.entered, &px->exp);) +VRT_DO_EXP(beresp, px->exp, ttl, 0, + vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, + px->exp.entered, &px->exp);) +VRT_DO_EXP(beresp, px->exp, keep, 0, + vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, + px->exp.entered, &px->exp);) +#undef CPAR +#undef CMAGIC /*-------------------------------------------------------------------- * req.xid diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index eca1974..c609b9b 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -355,19 +355,19 @@ sp_variables = ( 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'R' + 'B' ), ('beresp.grace', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'R' + 'B' ), ('beresp.keep', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'R' + 'B' ), ('beresp.backend.name', 'STRING', From phk at varnish-cache.org Tue Apr 23 08:27:54 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 23 Apr 2013 10:27:54 +0200 Subject: [master] 0f80514 Move the beresp.backend.* variables to busyobj Message-ID: commit 0f80514b3485b8aad2bdc25bd7d26444e9b27d1c Author: Poul-Henning Kamp Date: Tue Apr 23 08:27:41 2013 +0000 Move the beresp.backend.* variables to busyobj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8cc2d69..474fe95 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -261,30 +261,30 @@ BEREQ_TIMEOUT(between_bytes_timeout) /*--------------------------------------------------------------------*/ const char * -VRT_r_beresp_backend_name(const struct req *req) +VRT_r_beresp_backend_name(const struct busyobj *bo) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC); - return(req->busyobj->vbc->backend->vcl_name); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); + return(bo->vbc->backend->vcl_name); } struct sockaddr_storage * -VRT_r_beresp_backend_ip(const struct req *req) +VRT_r_beresp_backend_ip(const struct busyobj *bo) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC); - return(req->busyobj->vbc->addr); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); + return(bo->vbc->addr); } long -VRT_r_beresp_backend_port(const struct req *req) +VRT_r_beresp_backend_port(const struct busyobj *bo) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->busyobj->vbc, VBC_MAGIC); - return (VTCP_port(req->busyobj->vbc->addr)); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); + return (VTCP_port(bo->vbc->addr)); } const char * diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index c609b9b..c68d60f 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -373,19 +373,19 @@ sp_variables = ( 'STRING', ( 'backend_response',), ( ), - 'cR' + 'cB' ), ('beresp.backend.ip', 'IP', ( 'backend_response',), ( ), - 'cR' + 'cB' ), ('beresp.backend.port', 'INT', ( 'backend_response',), ( ), - 'cR' + 'cB' ), ('beresp.storage', 'STRING', From phk at varnish-cache.org Tue Apr 23 09:20:09 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 23 Apr 2013 11:20:09 +0200 Subject: [master] 7f2cd24 Fix indentation in emitted C code Message-ID: commit 7f2cd24bc46da877329fc8a0bf02e75b1d5d80ac Author: Poul-Henning Kamp Date: Tue Apr 23 09:11:39 2013 +0000 Fix indentation in emitted C code diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index feea593..6a08e45 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -262,10 +262,12 @@ parse_ban(struct vcc *tl) ExpectErr(tl, '('); vcc_NextToken(tl); - Fb(tl, 1, "VRT_ban_string("); + Fb(tl, 1, "VRT_ban_string(\n"); + tl->indent += INDENT; vcc_Expr(tl, STRING); + tl->indent -= INDENT; ERRCHK(tl); - Fb(tl, 0, ");\n"); + Fb(tl, 1, ");\n"); ExpectErr(tl, ')'); vcc_NextToken(tl); From phk at varnish-cache.org Tue Apr 23 09:20:09 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 23 Apr 2013 11:20:09 +0200 Subject: [master] 2e1dcdf Use the argument provided workspace, rather than default to req->ws. Message-ID: commit 2e1dcdfde32da298799cf3205cb5751e35a92bd4 Author: Poul-Henning Kamp Date: Tue Apr 23 09:19:53 2013 +0000 Use the argument provided workspace, rather than default to req->ws. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 7ea7bcb..f6ad925 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -215,14 +215,14 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap) */ const char * -VRT_ReqString(struct req *req, const char *p, ...) +VRT_CollectString(struct ws *ws, const char *p, ...) { va_list ap; char *b; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ws, WS_MAGIC); va_start(ap, p); - b = VRT_String(req->ws, NULL, p, ap); + b = VRT_String(ws, NULL, p, ap); va_end(ap); return (b); } diff --git a/include/vrt.h b/include/vrt.h index e71308a..9dfc649 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -232,4 +232,4 @@ char *VRT_TIME_string(struct ws *, double); const char *VRT_BOOL_string(unsigned); const char *VRT_BACKEND_string(const struct director *d); -const char *VRT_ReqString(struct req *, const char *p, ...); +const char *VRT_CollectString(struct ws *, const char *p, ...); diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index e2a2256..7caf25e 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -914,7 +914,7 @@ vcc_expr_strfold(struct vcc *tl, struct expr **e, enum var_type fmt) if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) *e = vcc_expr_edit(STRING, - "\v+VRT_ReqString(req,\n\v1,\nvrt_magic_string_end)", + "\v+VRT_CollectString(ws,\n\v1,\nvrt_magic_string_end)\v-", *e, NULL); if (fmt == STRING_LIST && (*e)->fmt == STRING) (*e)->fmt = STRING_LIST; From phk at varnish-cache.org Wed Apr 24 07:36:19 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Apr 2013 09:36:19 +0200 Subject: [master] 705e38b Move backend trouble maintenance to cache_backend.c Message-ID: commit 705e38b6a545452407c19386596cbe5b8a884fa0 Author: Poul-Henning Kamp Date: Wed Apr 24 07:29:35 2013 +0000 Move backend trouble maintenance to cache_backend.c Move VRT interface to cache_vrt.c rather than cache_vrt_var.c, the latter is reserved for VCL variables. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index c6f0b9b..9d743c3 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -224,6 +224,38 @@ vbe_NewConn(void) } /*-------------------------------------------------------------------- + * Add backend trouble item + */ + +void +VBE_AddTrouble(const struct req *req, double dt) +{ + struct trouble *tp; + struct vbc *vbc; + struct backend *be; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); + vbc = req->busyobj->vbc; + if (vbc == NULL) + return; + CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); + be = vbc->backend; + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); + if (dt <= 0.) + return; + ALLOC_OBJ(tp, TROUBLE_MAGIC); + if (tp == NULL) + return; + memcpy(tp->digest, req->digest, sizeof tp->digest); + tp->timeout = req->t_req + dt; + Lck_Lock(&vbc->backend->mtx); + VTAILQ_INSERT_HEAD(&be->troublelist, tp, list); + be->n_trouble++; + Lck_Unlock(&vbc->backend->mtx); +} + +/*-------------------------------------------------------------------- * It evaluates if a backend is healthy _for_a_specific_object_. * That means that it relies on req->objcore->objhead. This is mainly for * saint-mode, but also takes backend->healthy into account. If diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index b87b8d4..670fcf8 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -138,6 +138,8 @@ struct backend { struct vbp_target *probe; unsigned healthy; enum admin_health admin_health; + + unsigned n_trouble; VTAILQ_HEAD(, trouble) troublelist; struct VSC_C_vbe *vsc; @@ -167,6 +169,7 @@ struct vbc { /* cache_backend.c */ void VBE_ReleaseConn(struct vbc *vc); +void VBE_AddTrouble(const struct req *req, double dt); /* cache_backend_cfg.c */ void VBE_DropRefConn(struct backend *); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index f6ad925..b2d5da6 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -385,6 +385,19 @@ VRT_BOOL_string(unsigned val) return (val ? "true" : "false"); } +/*-------------------------------------------------------------------- + * Add an objecthead to the saintmode list for the (hopefully) relevant + * backend. + */ + +void +VRT_l_beresp_saintmode(const struct req *req, double a) +{ + + VBE_AddTrouble(req, a); +} + + /*--------------------------------------------------------------------*/ void diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 474fe95..8060a50 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -128,66 +128,6 @@ VRT_DO_STATUS(beresp, px->beresp) /*--------------------------------------------------------------------*/ -/* XXX: review this */ -/* Add an objecthead to the saintmode list for the (hopefully) relevant - * backend. Some double-up asserting here to avoid assert-errors when there - * is no object. - */ -void -VRT_l_beresp_saintmode(const struct req *req, double a) -{ - struct trouble *new; - struct trouble *tr; - struct trouble *tr2; - struct vbc *vbc; - - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); - vbc = req->busyobj->vbc; - if (!vbc) - return; - CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); - if (!vbc->backend) - return; - CHECK_OBJ_NOTNULL(vbc->backend, BACKEND_MAGIC); - if (!req->objcore->objhead) - return; - CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - - /* Setting a negative holdoff period is a mistake. Detecting this - * when compiling the VCL would be better. - */ - assert(a > 0); - - ALLOC_OBJ(new, TROUBLE_MAGIC); - AN(new); - memcpy(new->digest, req->digest, sizeof new->digest); - new->timeout = req->t_req + a; - - /* Insert the new item on the list before the first item with a - * timeout at a later date (ie: sort by which entry will time out - * from the list - */ - Lck_Lock(&vbc->backend->mtx); - VTAILQ_FOREACH_SAFE(tr, &vbc->backend->troublelist, list, tr2) { - if (tr->timeout < new->timeout) { - VTAILQ_INSERT_BEFORE(tr, new, list); - new = NULL; - break; - } - } - - /* Insert the item at the end if the list is empty or all other - * items have a longer timeout. - */ - if (new) - VTAILQ_INSERT_TAIL(&vbc->backend->troublelist, new, list); - - Lck_Unlock(&vbc->backend->mtx); -} - -/*--------------------------------------------------------------------*/ - #define VBERESP(dir, type, onm, field) \ void \ VRT_l_##dir##_##onm(struct busyobj *bo, type a) \ From phk at varnish-cache.org Wed Apr 24 07:50:43 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 24 Apr 2013 09:50:43 +0200 Subject: [master] 2cbf11f Polish the health check a bit. Message-ID: commit 2cbf11f8478a16e4944136ab8adfa93a4d1a57e9 Author: Poul-Henning Kamp Date: Wed Apr 24 07:50:29 2013 +0000 Polish the health check a bit. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 9d743c3..e0f9348 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -271,10 +271,10 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req) { struct trouble *tr; struct trouble *tr2; - struct trouble *old; - unsigned i = 0, retval; + unsigned retval; unsigned int threshold; struct backend *backend; + VTAILQ_HEAD(, trouble) troublelist; double now; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -299,42 +299,35 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req) threshold = UINT_MAX; /* Saintmode is disabled, or list is empty */ - if (threshold == 0 || VTAILQ_EMPTY(&backend->troublelist)) + if (threshold == 0 || backend->n_trouble == 0) return (1); now = req->t_req; - old = NULL; retval = 1; + VTAILQ_INIT(&troublelist); Lck_Lock(&backend->mtx); VTAILQ_FOREACH_SAFE(tr, &backend->troublelist, list, tr2) { CHECK_OBJ_NOTNULL(tr, TROUBLE_MAGIC); if (tr->timeout < now) { VTAILQ_REMOVE(&backend->troublelist, tr, list); - old = tr; - retval = 1; - break; + VTAILQ_INSERT_HEAD(&troublelist, tr, list); + backend->n_trouble--; + continue; } if (!memcmp(tr->digest, req->digest, sizeof tr->digest)) { retval = 0; break; } - - /* If the threshold is at 1, a single entry on the list - * will disable the backend. Since 0 is disable, ++i - * instead of i++ to allow this behavior. - */ - if (++i >= threshold) { - retval = 0; - break; - } } + if (threshold <= backend->n_trouble) + retval = 0; Lck_Unlock(&backend->mtx); - if (old != NULL) - FREE_OBJ(old); + VTAILQ_FOREACH_SAFE(tr, &troublelist, list, tr2) + FREE_OBJ(tr); return (retval); } From phk at varnish-cache.org Thu Apr 25 07:39:52 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 25 Apr 2013 09:39:52 +0200 Subject: [master] 763a811 White-space OCD Message-ID: commit 763a81174259f4c514775b0e30609b2f43127e57 Author: Poul-Henning Kamp Date: Thu Apr 25 07:39:40 2013 +0000 White-space OCD diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index b2d5da6..4621695 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -387,7 +387,7 @@ VRT_BOOL_string(unsigned val) /*-------------------------------------------------------------------- * Add an objecthead to the saintmode list for the (hopefully) relevant - * backend. + * backend. */ void @@ -397,7 +397,6 @@ VRT_l_beresp_saintmode(const struct req *req, double a) VBE_AddTrouble(req, a); } - /*--------------------------------------------------------------------*/ void From tfheen at varnish-cache.org Thu Apr 25 11:38:10 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 25 Apr 2013 13:38:10 +0200 Subject: [3.0] 9c1a540 Require libedit/readline Message-ID: commit 9c1a540b5638a252ddcb1db17b0a5241e5f3b8c1 Author: Tollef Fog Heen Date: Tue Mar 12 11:15:58 2013 +0100 Require libedit/readline Remove a bunch of ifdef code and fix up proper configure check for libedit. Fixes #1277 diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 8e68715..c09a1c7 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -37,15 +37,15 @@ #include #include -#ifdef HAVE_LIBEDIT -# include -# ifdef HAVE_EDIT_READLINE_READLINE_H -# include -# elif HAVE_READLINE_READLINE_H -# include -# else -# include +#ifdef HAVE_EDIT_READLINE_READLINE_H +# include +#elif HAVE_READLINE_READLINE_H +# include +# ifdef HAVE_READLINE_HISTORY_H +# include # endif +#else +# include #endif #include "vcli.h" @@ -54,16 +54,12 @@ #include "varnishapi.h" #include "vss.h" -#ifdef HAVE_LIBEDIT #define RL_EXIT(status) \ do { \ rl_callback_handler_remove(); \ exit(status); \ } while (0) -#else -#define RL_EXIT(status) exit(status) -#endif static double timeout = 5; @@ -171,7 +167,6 @@ do_args(int sock, int argc, char * const *argv) exit(1); } -#ifdef HAVE_LIBEDIT /* Callback for readline, doesn't take a private pointer, so we need * to have a global variable. */ @@ -221,7 +216,6 @@ varnishadm_completion (const char *text, int start, int end) matches = rl_completion_matches(text, command_generator); return (matches); } -#endif /* * No arguments given, simply pass bytes on stdin/stdout and CLI socket @@ -235,11 +229,6 @@ pass(int sock) int i; char *answer = NULL; unsigned u, status; -#ifndef HAVE_LIBEDIT - int n; -#endif - -#ifdef HAVE_LIBEDIT _line_sock = sock; rl_already_prompted = 1; if (isatty(0)) { @@ -248,7 +237,6 @@ pass(int sock) rl_callback_handler_install("", send_line); } rl_attempted_completion_function = varnishadm_completion; -#endif fds[0].fd = sock; fds[0].events = POLLIN; @@ -309,25 +297,10 @@ pass(int sock) free(answer); answer = NULL; } -#ifdef HAVE_LIBEDIT rl_forced_update_display(); -#endif } if (fds[1].revents & POLLIN) { -#ifdef HAVE_LIBEDIT rl_callback_read_char(); -#else - n = read(fds[1].fd, buf, sizeof buf); - if (n == 0) { - AZ(shutdown(sock, SHUT_WR)); - fds[1].fd = -1; - } else if (n < 0) { - RL_EXIT(0); - } else { - buf[n] = '\0'; - cli_write(sock, buf); - } -#endif } } } diff --git a/configure.ac b/configure.ac index 403e301..054353c 100644 --- a/configure.ac +++ b/configure.ac @@ -156,7 +156,7 @@ PKG_CHECK_MODULES([LIBEDIT], [libedit], LIBEDIT_CFLAGS="" LIBEDIT_LIBS="-ledit ${CURSES_LIBS}" ], - [AC_MSG_WARN([libedit not found, disabling libedit support])], + [AC_MSG_ERROR([libedit or readline not found])], [${CURSES_LIBS}])]) # Checks for header files. From tfheen at varnish-cache.org Thu Apr 25 11:50:39 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 25 Apr 2013 13:50:39 +0200 Subject: [3.0] 282d713 Simplify libedit/readline detection somewhat. Message-ID: commit 282d713011ce70e68999eb50c779690b12cf8d3c Author: Tollef Fog Heen Date: Tue Mar 12 14:40:21 2013 +0100 Simplify libedit/readline detection somewhat. diff --git a/configure.ac b/configure.ac index 054353c..a17e139 100644 --- a/configure.ac +++ b/configure.ac @@ -149,15 +149,10 @@ AC_SUBST(PCRE_LIBS) PKG_CHECK_MODULES([LIBEDIT], [libedit], [AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])], - [AC_CHECK_HEADERS([readline/readline.h]) - AC_CHECK_HEADERS([edit/readline/readline.h]) - AC_CHECK_LIB(edit, el_init, - [ AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit]) - LIBEDIT_CFLAGS="" - LIBEDIT_LIBS="-ledit ${CURSES_LIBS}" - ], - [AC_MSG_ERROR([libedit or readline not found])], - [${CURSES_LIBS}])]) + [AX_LIB_READLINE]) +if test "$ac_cv_have_readline" = no; then + AC_MSG_ERROR([libedit or readline not found]) +fi # Checks for header files. AC_HEADER_STDC diff --git a/m4/ax_lib_readline.m4 b/m4/ax_lib_readline.m4 new file mode 100644 index 0000000..056f25c --- /dev/null +++ b/m4/ax_lib_readline.m4 @@ -0,0 +1,107 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_READLINE +# +# DESCRIPTION +# +# Searches for a readline compatible library. If found, defines +# `HAVE_LIBREADLINE'. If the found library has the `add_history' function, +# sets also `HAVE_READLINE_HISTORY'. Also checks for the locations of the +# necessary include files and sets `HAVE_READLINE_H' or +# `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or +# 'HAVE_HISTORY_H' if the corresponding include files exists. +# +# The libraries that may be readline compatible are `libedit', +# `libeditline' and `libreadline'. Sometimes we need to link a termcap +# library for readline to work, this macro tests these cases too by trying +# to link with `libtermcap', `libcurses' or `libncurses' before giving up. +# +# Here is an example of how to use the information provided by this macro +# to perform the necessary includes or declarations in a C file: +# +# #ifdef HAVE_LIBREADLINE +# # if defined(HAVE_READLINE_READLINE_H) +# # include +# # elif defined(HAVE_READLINE_H) +# # include +# # else /* !defined(HAVE_READLINE_H) */ +# extern char *readline (); +# # endif /* !defined(HAVE_READLINE_H) */ +# char *cmdline = NULL; +# #else /* !defined(HAVE_READLINE_READLINE_H) */ +# /* no readline */ +# #endif /* HAVE_LIBREADLINE */ +# +# #ifdef HAVE_READLINE_HISTORY +# # if defined(HAVE_READLINE_HISTORY_H) +# # include +# # elif defined(HAVE_HISTORY_H) +# # include +# # else /* !defined(HAVE_HISTORY_H) */ +# extern void add_history (); +# extern int write_history (); +# extern int read_history (); +# # endif /* defined(HAVE_READLINE_HISTORY_H) */ +# /* no history */ +# #endif /* HAVE_READLINE_HISTORY */ +# +# LICENSE +# +# Copyright (c) 2008 Ville Laurikari +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE]) +AC_DEFUN([AX_LIB_READLINE], [ + AC_CACHE_CHECK([for a readline compatible library], + ax_cv_lib_readline, [ + ORIG_LIBS="$LIBS" + for readline_lib in readline edit editline; do + for termcap_lib in "" termcap curses ncurses; do + if test -z "$termcap_lib"; then + TRY_LIB="-l$readline_lib" + else + TRY_LIB="-l$readline_lib -l$termcap_lib" + fi + LIBS="$ORIG_LIBS $TRY_LIB" + AC_TRY_LINK_FUNC(readline, ax_cv_lib_readline="$TRY_LIB") + if test -n "$ax_cv_lib_readline"; then + break + fi + done + if test -n "$ax_cv_lib_readline"; then + break + fi + done + if test -z "$ax_cv_lib_readline"; then + ax_cv_lib_readline="no" + fi + LIBS="$ORIG_LIBS" + ]) + + if test "$ax_cv_lib_readline" != "no"; then + LIBS="$LIBS $ax_cv_lib_readline" + AC_DEFINE(HAVE_LIBREADLINE, 1, + [Define if you have a readline compatible library]) + AC_CHECK_HEADERS(readline.h readline/readline.h) + AC_CACHE_CHECK([whether readline supports history], + ax_cv_lib_readline_history, [ + ax_cv_lib_readline_history="no" + AC_TRY_LINK_FUNC(add_history, ax_cv_lib_readline_history="yes") + ]) + if test "$ax_cv_lib_readline_history" = "yes"; then + AC_DEFINE(HAVE_READLINE_HISTORY, 1, + [Define if your readline library has \`add_history']) + AC_CHECK_HEADERS(history.h readline/history.h) + fi + fi +])dnl From tfheen at varnish-cache.org Thu Apr 25 12:55:37 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 25 Apr 2013 14:55:37 +0200 Subject: [3.0] 7ab7c49 Various code-polishings to make OmnitiOS happy. Message-ID: commit 7ab7c4998adbf604736e4eebe7e64c8993798eb8 Author: Poul-Henning Kamp Date: Thu Sep 6 12:05:04 2012 +0000 Various code-polishings to make OmnitiOS happy. Some of them are rather pedantic: "NULL" vs "(char*)0" -- Really ? diff --git a/bin/varnishd/cache_waiter_ports.c b/bin/varnishd/cache_waiter_ports.c index e599260..364dd2c 100644 --- a/bin/varnishd/cache_waiter_ports.c +++ b/bin/varnishd/cache_waiter_ports.c @@ -159,7 +159,8 @@ vca_main(void *arg) while (1) { port_event_t ev[MAX_EVENTS]; - int nevents, ei, ret; + uint_t nevents; + int ei, ret; double now, deadline; /* @@ -242,6 +243,7 @@ vca_main(void *arg) timeout = &max_ts; } } + NEEDLESS_RETURN(NULL); } static void diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index ee74452..9f2a94d 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -478,7 +478,7 @@ mgt_sigchld(const struct vev *e, int what) assert(r == child_pid); vsb = VSB_new_auto(); XXXAN(vsb); - VSB_printf(vsb, "Child (%d) %s", r, status ? "died" : "ended"); + VSB_printf(vsb, "Child (%ld) %s", (long)r, status ? "died" : "ended"); if (WIFEXITED(status) && WEXITSTATUS(status)) { VSB_printf(vsb, " status=%d", WEXITSTATUS(status)); exit_status |= 0x20; diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c index b39c245..cb7e6a3 100644 --- a/bin/varnishd/mgt_vcc.c +++ b/bin/varnishd/mgt_vcc.c @@ -174,7 +174,7 @@ run_vcc(void *priv) static void run_cc(void *priv) { - (void)execl("/bin/sh", "/bin/sh", "-c", priv, NULL); + (void)execl("/bin/sh", "/bin/sh", "-c", priv, (char*)0); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index 8acbc20..8e5910a 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -321,7 +321,7 @@ smp_open(const struct stevedore *st) /* We trust the parent to give us a valid silo, for good measure: */ AZ(smp_valid_silo(sc)); - AZ(mprotect(sc->base, 4096, PROT_READ)); + AZ(mprotect((void*)sc->base, 4096, PROT_READ)); sc->ident = SIGN_DATA(&sc->idn); diff --git a/bin/varnishd/storage_persistent_mgt.c b/bin/varnishd/storage_persistent_mgt.c index 3bd5809..f1cfee6 100644 --- a/bin/varnishd/storage_persistent_mgt.c +++ b/bin/varnishd/storage_persistent_mgt.c @@ -168,7 +168,7 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av) else target = NULL; - sc->base = mmap(target, sc->mediasize, PROT_READ|PROT_WRITE, + sc->base = (void*)mmap(target, sc->mediasize, PROT_READ|PROT_WRITE, MAP_NOCORE | MAP_NOSYNC | MAP_SHARED, sc->fd, 0); if (sc->base == MAP_FAILED) diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 56db682..fcd299c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -390,10 +390,10 @@ varnish_launch(struct varnish *v) AZ(close(v->fds[3])); for (i = 3; i vl, 3, "PID: %d", v->pid); + vtc_log(v->vl, 3, "PID: %ld", (long)v->pid); } AZ(close(v->fds[0])); AZ(close(v->fds[3])); From tfheen at varnish-cache.org Fri Apr 26 12:36:41 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 26 Apr 2013 14:36:41 +0200 Subject: [master] 9e6b75d Add %D and %T support to varnishncsa Message-ID: commit 9e6b75dc46ae97aee8522cdb983bd6f3f4e8ce40 Author: Tollef Fog Heen Date: Fri Apr 26 14:36:24 2013 +0200 Add %D and %T support to varnishncsa diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 0b039b6..1a22554 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -97,9 +97,11 @@ static struct logline { char *df_h; /* %h (host name / IP adress)*/ char *df_m; /* %m, Request method*/ char *df_s; /* %s, Status */ - struct tm df_t; /* %t, Date and time */ + struct tm df_t; /* %t, Date and time, received */ char *df_u; /* %u, Remote user */ char *df_ttfb; /* Time to first byte */ + double df_D; /* %D, time taken to serve the request, + in microseconds, also used for %T */ const char *df_hitmiss; /* Whether this is a hit or miss */ const char *df_handling; /* How the request was handled (hit/miss/pass/pipe) */ @@ -400,7 +402,6 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, const char *ptr, unsigned len) { const char *end, *next, *split; - long l; time_t t; assert(spec & VSL_S_CLIENT); @@ -557,18 +558,20 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_ReqEnd: { char ttfb[64]; + double t_start, t_end; if (!lp->active) break; if (lp->df_ttfb != NULL || - sscanf(ptr, "%*u %*u.%*u %ld.%*u %*u.%*u %s", &l, ttfb) - != 2) { + sscanf(ptr, "%*u %lf %lf %*u.%*u %s", &t_start, &t_end, ttfb) + != 3) { clean_logline(lp); break; } if (lp->df_ttfb != NULL) free(lp->df_ttfb); lp->df_ttfb = strdup(ttfb); - t = l; + lp->df_D = t_end - t_start; + t = t_start; localtime_r(&t, &lp->df_t); /* got it all */ lp->complete = 1; @@ -669,6 +672,10 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, VSB_cat(os, lp->df_b ? lp->df_b : "-"); break; + case 'D': + /* %D */ + VSB_printf(os, "%f", lp->df_D); + case 'H': VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0"); break; @@ -724,6 +731,11 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, VSB_cat(os, tbuf); break; + case 'T': + /* %T */ + VSB_printf(os, "%d", (int)lp->df_D); + break; + case 'U': VSB_cat(os, lp->df_U ? lp->df_U : "-"); break; From tfheen at varnish-cache.org Fri Apr 26 12:49:01 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 26 Apr 2013 14:49:01 +0200 Subject: [master] 75d112c Add missing break Message-ID: commit 75d112c17b05c46393b8f72eff5db0598ef925bf Author: Tollef Fog Heen Date: Fri Apr 26 14:48:48 2013 +0200 Add missing break diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 1a22554..3c66c7b 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -675,6 +675,7 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, case 'D': /* %D */ VSB_printf(os, "%f", lp->df_D); + break; case 'H': VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0"); From tfheen at varnish-cache.org Fri Apr 26 12:49:03 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 26 Apr 2013 14:49:03 +0200 Subject: [3.0] 86c5929 Add %D and %T support to varnishncsa Message-ID: commit 86c59292aec3288b317a84266d48ac4be7d415c6 Author: Tollef Fog Heen Date: Fri Apr 26 14:36:24 2013 +0200 Add %D and %T support to varnishncsa diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index f9fbfa7..9bd2423 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -95,9 +95,11 @@ static struct logline { char *df_h; /* %h (host name / IP adress)*/ char *df_m; /* %m, Request method*/ char *df_s; /* %s, Status */ - struct tm df_t; /* %t, Date and time */ + struct tm df_t; /* %t, Date and time, received */ char *df_u; /* %u, Remote user */ char *df_ttfb; /* Time to first byte */ + double df_D; /* %D, time taken to serve the request, + in microseconds, also used for %T */ const char *df_hitmiss; /* Whether this is a hit or miss */ const char *df_handling; /* How the request was handled (hit/miss/pass/pipe) */ int active; /* Is log line in an active trans */ @@ -399,7 +401,6 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, const char *ptr, unsigned len) { const char *end, *next, *split; - long l; time_t t; assert(spec & VSL_S_CLIENT); @@ -551,16 +552,19 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, case SLT_ReqEnd: { char ttfb[64]; + double t_start, t_end; if (!lp->active) break; - if (lp->df_ttfb != NULL || sscanf(ptr, "%*u %*u.%*u %ld.%*u %*u.%*u %s", &l, ttfb) != 2) { + if (lp->df_ttfb != NULL || + sscanf(ptr, "%*u %lf %lf %*u.%*u %s", &t_start, &t_end, ttfb) != 3) { clean_logline(lp); break; } if (lp->df_ttfb != NULL) free(lp->df_ttfb); lp->df_ttfb = strdup(ttfb); - t = l; + lp->df_D = t_end - t_start; + t = t_start; localtime_r(&t, &lp->df_t); /* got it all */ lp->complete = 1; @@ -659,6 +663,11 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, VSB_cat(os, lp->df_b ? lp->df_b : "-"); break; + case 'D': + /* %D */ + VSB_printf(os, "%f", lp->df_D); + break; + case 'H': VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0"); break; @@ -712,6 +721,11 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, VSB_cat(os, tbuf); break; + case 'T': + /* %T */ + VSB_printf(os, "%d", (int)lp->df_D); + break; + case 'U': VSB_cat(os, lp->df_U ? lp->df_U : "-"); break; From perbu at varnish-cache.org Mon Apr 29 07:46:30 2013 From: perbu at varnish-cache.org (Per Buer) Date: Mon, 29 Apr 2013 09:46:30 +0200 Subject: [master] d274585 remove old cruft Message-ID: commit d274585f71b557f816569a3ad8771420dd59e9fd Author: Per Buer Date: Mon Apr 29 09:46:27 2013 +0200 remove old cruft diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 2bf2bd8..6f0fe9b 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -48,8 +48,7 @@ file syntax: file[,path[,size[,granularity]]] The file backend stores objects in memory backed by a file on disk -with mmap. This is the default storage backend and unless you specify -another storage this one will used along with Transient storage. +with mmap. The path parameter specifies either the path to the backing file or the path to a directory in which varnishd will create the backing From phk at varnish-cache.org Mon Apr 29 08:16:43 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 10:16:43 +0200 Subject: [master] 1915084 Give the busyobj a copy of req->digest, and move adding saintmode entries to use busyobj. Message-ID: commit 19150844249c856daca1e66a4a2496fef11b3e67 Author: Poul-Henning Kamp Date: Mon Apr 29 08:16:20 2013 +0000 Give the busyobj a copy of req->digest, and move adding saintmode entries to use busyobj. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 232e2f1..b15eaba 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -516,6 +516,7 @@ struct busyobj { struct http *bereq; struct http *beresp; struct object *fetch_obj; + unsigned char digest[DIGEST_LEN]; struct exp exp; struct http_conn htc; diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index e0f9348..3b1636b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -228,27 +228,24 @@ vbe_NewConn(void) */ void -VBE_AddTrouble(const struct req *req, double dt) +VBE_AddTrouble(const struct busyobj *bo, double expires) { struct trouble *tp; struct vbc *vbc; struct backend *be; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); - vbc = req->busyobj->vbc; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vbc = bo->vbc; if (vbc == NULL) return; CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); be = vbc->backend; CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); - if (dt <= 0.) - return; ALLOC_OBJ(tp, TROUBLE_MAGIC); if (tp == NULL) return; - memcpy(tp->digest, req->digest, sizeof tp->digest); - tp->timeout = req->t_req + dt; + memcpy(tp->digest, bo->digest, sizeof tp->digest); + tp->timeout = expires; Lck_Lock(&vbc->backend->mtx); VTAILQ_INSERT_HEAD(&be->troublelist, tp, list); be->n_trouble++; diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 670fcf8..a291604 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -169,7 +169,7 @@ struct vbc { /* cache_backend.c */ void VBE_ReleaseConn(struct vbc *vc); -void VBE_AddTrouble(const struct req *req, double dt); +void VBE_AddTrouble(const struct busyobj *, double expires); /* cache_backend_cfg.c */ void VBE_DropRefConn(struct backend *); diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index dfda90f..9131cd0 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -137,6 +137,8 @@ VBO_GetBusyObj(struct worker *wrk, struct req *req) WS_Init(bo->ws, "bo", p, bo->end - p); + memcpy(bo->digest, req->digest, sizeof bo->digest); + bo->do_stream = 1; return (bo); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4621695..aa16783 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -391,10 +391,11 @@ VRT_BOOL_string(unsigned val) */ void -VRT_l_beresp_saintmode(const struct req *req, double a) +VRT_l_beresp_saintmode(const struct busyobj *bo, double a) { - VBE_AddTrouble(req, a); + if (a > 0.) + VBE_AddTrouble(bo, a + VTIM_real()); } /*--------------------------------------------------------------------*/ diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index c68d60f..a346767 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -295,7 +295,7 @@ sp_variables = ( 'DURATION', ( ), ( 'backend_response',), - 'cR' + 'cB' ), ('beresp.status', 'INT', From tfheen at varnish-cache.org Mon Apr 29 11:23:05 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 29 Apr 2013 13:23:05 +0200 Subject: [3.0] d9bc81c Add support for banning on http.status Message-ID: commit d9bc81ce8a1c3a444ec0c1a1632927633d4eae33 Author: Tollef Fog Heen Date: Mon Jan 2 12:58:03 2012 +0100 Add support for banning on http.status Fixes: #1076 diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index c458ba0..6062f98 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -97,9 +97,10 @@ static bgthread_t ban_lurker; #define BAN_OPER_MATCH 0x12 #define BAN_OPER_NMATCH 0x13 -#define BAN_ARG_URL 0x18 -#define BAN_ARG_REQHTTP 0x19 -#define BAN_ARG_OBJHTTP 0x1a +#define BAN_ARG_URL 0x18 +#define BAN_ARG_REQHTTP 0x19 +#define BAN_ARG_OBJHTTP 0x1a +#define BAN_ARG_OBJSTATUS 0x1b /*-------------------------------------------------------------------- * Variables we can purge on @@ -582,6 +583,7 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, struct ban_test bt; const uint8_t *be; char *arg1; + char buf[10]; be = bs + ban_len(bs); bs += 13; @@ -599,6 +601,10 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, case BAN_ARG_OBJHTTP: (void)http_GetHdr(objhttp, bt.arg1_spec, &arg1); break; + case BAN_ARG_OBJSTATUS: + arg1 = buf; + sprintf(buf, "%d", objhttp->status); + break; default: INCOMPL(); } diff --git a/include/ban_vars.h b/include/ban_vars.h index 669b9b1..65b17e0 100644 --- a/include/ban_vars.h +++ b/include/ban_vars.h @@ -35,3 +35,4 @@ PVAR("req.url", PVAR_REQ, BAN_ARG_URL) PVAR("req.http.", PVAR_REQ|PVAR_HTTP, BAN_ARG_REQHTTP) PVAR("obj.http.", PVAR_HTTP, BAN_ARG_OBJHTTP) +PVAR("obj.status", 0, BAN_ARG_OBJSTATUS) From phk at varnish-cache.org Mon Apr 29 12:45:52 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 14:45:52 +0200 Subject: [master] b094d58 Give the busyobj a copy (+ref) of the req's vcl and director. Message-ID: commit b094d583d10a696022e095345f58260f06f602b8 Author: Poul-Henning Kamp Date: Mon Apr 29 12:45:25 2013 +0000 Give the busyobj a copy (+ref) of the req's vcl and director. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b15eaba..50128ce 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -539,6 +539,8 @@ struct busyobj { double between_bytes_timeout; const char *storage_hint; + struct director *director; + struct VCL_conf *vcl; struct vsl_log vsl[1]; struct dstat *stats; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 9131cd0..ffe108a 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -141,6 +141,10 @@ VBO_GetBusyObj(struct worker *wrk, struct req *req) bo->do_stream = 1; + bo->director = req->director; + bo->vcl = req->vcl; + VCL_Ref(bo->vcl); + return (bo); } @@ -183,6 +187,8 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) (void)HSH_Deref(&wrk->stats, NULL, &bo->fetch_obj); } + VCL_Rel(&bo->vcl); + memset(&bo->refcount, 0, sizeof *bo - offsetof(struct busyobj, refcount)); From phk at varnish-cache.org Mon Apr 29 13:11:07 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 15:11:07 +0200 Subject: [master] 95c563e Introduce the bereq.backend* variables. Message-ID: commit 95c563e59c15536595969f8fe53b8b4cc9f17d5e Author: Poul-Henning Kamp Date: Mon Apr 29 13:10:21 2013 +0000 Introduce the bereq.backend* variables. NB: bereq.backend.healthy always fails right now. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8060a50..9395c73 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -268,6 +268,50 @@ VRT_r_req_backend(const struct req *req) return (req->director); } +unsigned +VRT_r_req_backend_healthy(const struct req *req) +{ + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + /* + * XXX: Not optimal, but we do not have a backend in vcl_deliver + * XXX: and we have to return something. + */ + if (req->director == NULL) + return (0); + CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC); + return (VDI_Healthy(req->director, req)); +} + +/*--------------------------------------------------------------------*/ + +void +VRT_l_bereq_backend(struct busyobj *bo, struct director *be) +{ + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(bo->director); + bo->director = be; +} + +struct director * +VRT_r_bereq_backend(const struct busyobj *bo) +{ + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(bo->director); + return (bo->director); +} + +unsigned +VRT_r_bereq_backend_healthy(const struct busyobj *bo) +{ + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->director, DIRECTOR_MAGIC); + //XXX return (VDI_Healthy(bo->director, req)); + return (0); +} + /*--------------------------------------------------------------------*/ void @@ -517,17 +561,3 @@ VRT_r_obj_uncacheable(const struct req *req) CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); return (req->obj->objcore->flags & OC_F_PASS ? 1 : 0); } - -unsigned -VRT_r_req_backend_healthy(const struct req *req) -{ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - /* - * XXX: Not optimal, but we do not have a backend in vcl_deliver - * XXX: and we have to return something. - */ - if (req->director == NULL) - return (0); - CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC); - return (VDI_Healthy(req->director, req)); -} diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index a346767..bd5e6ab 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -165,12 +165,6 @@ sp_variables = ( ( 'proc',), 'cR' ), - ('req.backend', - 'BACKEND', - ( 'proc',), - ( 'proc',), - 'R' - ), ('req.restarts', 'INT', ( 'proc',), @@ -219,6 +213,12 @@ sp_variables = ( ( ), 'R' ), + ('req.backend', + 'BACKEND', + ( 'proc',), + ( 'proc',), + 'R' + ), ('req.backend.healthy', 'BOOL', ( 'proc',), @@ -237,6 +237,18 @@ sp_variables = ( ( 'recv',), 'R' ), + ('bereq.backend', + 'BACKEND', + ( 'backend_fetch', 'backend_response'), + ( 'backend_fetch', 'backend_response'), + 'B' + ), + ('bereq.backend.healthy', + 'BOOL', + ( 'backend_fetch', 'backend_response'), + ( ), + 'B' + ), ('bereq.method', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), From phk at varnish-cache.org Mon Apr 29 13:36:03 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 15:36:03 +0200 Subject: [master] 928dd02 Pass the digest to the backend->healthy() check, rather than the req* Message-ID: commit 928dd021e709f00f97ae8601510f99c8f515a19e Author: Poul-Henning Kamp Date: Mon Apr 29 13:35:40 2013 +0000 Pass the digest to the backend->healthy() check, rather than the req* diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 50128ce..e24fe84 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -516,7 +516,7 @@ struct busyobj { struct http *bereq; struct http *beresp; struct object *fetch_obj; - unsigned char digest[DIGEST_LEN]; + uint8_t digest[DIGEST_LEN]; struct exp exp; struct http_conn htc; @@ -615,7 +615,7 @@ struct req { uint8_t *vary_l; uint8_t *vary_e; - unsigned char digest[DIGEST_LEN]; + uint8_t digest[DIGEST_LEN]; enum sess_close doclose; struct exp exp; diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 3b1636b..45d9943 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -42,6 +42,7 @@ #include "cache_backend.h" #include "vrt.h" #include "vtcp.h" +#include "vtim.h" static struct mempool *vbcpool; @@ -264,7 +265,7 @@ VBE_AddTrouble(const struct busyobj *bo, double expires) */ static unsigned int -vbe_Healthy(const struct vdi_simple *vs, const struct req *req) +vbe_Healthy(const struct vdi_simple *vs, const uint8_t *digest) { struct trouble *tr; struct trouble *tr2; @@ -274,7 +275,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req) VTAILQ_HEAD(, trouble) troublelist; double now; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + AN(digest); CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); backend = vs->backend; CHECK_OBJ_NOTNULL(backend, BACKEND_MAGIC); @@ -299,7 +300,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req) if (threshold == 0 || backend->n_trouble == 0) return (1); - now = req->t_req; + now = VTIM_real(); retval = 1; VTAILQ_INIT(&troublelist); @@ -314,7 +315,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req) continue; } - if (!memcmp(tr->digest, req->digest, sizeof tr->digest)) { + if (!memcmp(tr->digest, digest, sizeof tr->digest)) { retval = 0; break; } @@ -382,7 +383,7 @@ vbe_GetVbe(struct req *req, struct vdi_simple *vs) VBE_ReleaseConn(vc); } - if (!vbe_Healthy(vs, req)) { + if (!vbe_Healthy(vs, req->digest)) { VSC_C_main->backend_unhealthy++; return (NULL); } @@ -472,13 +473,13 @@ vdi_simple_getfd(const struct director *d, struct req *req) } static unsigned -vdi_simple_healthy(const struct director *d, const struct req *req) +vdi_simple_healthy(const struct director *d, const uint8_t *digest) { struct vdi_simple *vs; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - return (vbe_Healthy(vs, req)); + return (vbe_Healthy(vs, digest)); } static void diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index a291604..13d452e 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -77,7 +77,7 @@ struct vrt_backend_probe; typedef struct vbc *vdi_getfd_f(const struct director *, struct req *); typedef void vdi_fini_f(const struct director *); -typedef unsigned vdi_healthy(const struct director *, const struct req *); +typedef unsigned vdi_healthy(const struct director *, const uint8_t *digest); struct director { unsigned magic; @@ -97,7 +97,7 @@ struct director { struct trouble { unsigned magic; #define TROUBLE_MAGIC 0x4211ab21 - unsigned char digest[DIGEST_LEN]; + uint8_t digest[DIGEST_LEN]; double timeout; VTAILQ_ENTRY(trouble) list; }; diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index ab43cf1..68e6e99 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -128,5 +128,5 @@ VDI_Healthy(const struct director *d, const struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->healthy(d, req)); + return (d->healthy(d, req->digest)); } diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index ec6a4f2..8a3d08b 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -90,7 +90,7 @@ struct objhead { int refcnt; struct lock mtx; VTAILQ_HEAD(,objcore) objcs; - unsigned char digest[DIGEST_LEN]; + uint8_t digest[DIGEST_LEN]; struct waitinglist *waitinglist; /*---------------------------------------------------- diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 76cfb4e..af25ac3 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -45,12 +45,12 @@ struct vmod_directors_fallback { }; static unsigned __match_proto__(vdi_healthy) -vmod_rr_healthy(const struct director *dir, const struct req *req) +vmod_rr_healthy(const struct director *dir, const uint8_t *digest) { struct vmod_directors_fallback *rr; CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); - return (vdir_any_healthy(rr->vd, req)); + return (vdir_any_healthy(rr->vd, digest)); } static struct vbc * __match_proto__(vdi_getfd_f) @@ -65,7 +65,7 @@ vmod_rr_getfd(const struct director *dir, struct req *req) for (u = 0; u < rr->vd->n_backend; u++) { be = rr->vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req)) + if (be->healthy(be, req->digest)) break; } vdir_unlock(rr->vd); diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 61eb677..d12b5b2 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -50,12 +50,12 @@ struct vmod_directors_random { }; static unsigned __match_proto__(vdi_healthy) -vmod_rr_healthy(const struct director *dir, const struct req *req) +vmod_rr_healthy(const struct director *dir, const uint8_t *digest) { struct vmod_directors_random *rr; CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); - return (vdir_any_healthy(rr->vd, req)); + return (vdir_any_healthy(rr->vd, digest)); } static struct vbc * __match_proto__(vdi_getfd_f) diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index 98df225..35e2454 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -46,12 +46,12 @@ struct vmod_directors_round_robin { }; static unsigned __match_proto__(vdi_healthy) -vmod_rr_healthy(const struct director *dir, const struct req *req) +vmod_rr_healthy(const struct director *dir, const uint8_t *digest) { struct vmod_directors_round_robin *rr; CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); - return (vdir_any_healthy(rr->vd, req)); + return (vdir_any_healthy(rr->vd, digest)); } static struct vbc * __match_proto__(vdi_getfd_f) @@ -68,7 +68,7 @@ vmod_rr_getfd(const struct director *dir, struct req *req) be = rr->vd->backend[rr->nxt]; rr->nxt++; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req)) + if (be->healthy(be, req->digest)) break; } vdir_unlock(rr->vd); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 0a8e954..c921cf0 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -128,7 +128,7 @@ vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight) } unsigned -vdir_any_healthy(struct vdir *vd, const struct req *req) +vdir_any_healthy(struct vdir *vd, const uint8_t *digest) { unsigned retval = 0; VCL_BACKEND be; @@ -139,7 +139,7 @@ vdir_any_healthy(struct vdir *vd, const struct req *req) for (u = 0; u < vd->n_backend; u++) { be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req)) { + if (be->healthy(be, digest)) { retval = 1; break; } @@ -185,7 +185,7 @@ vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops) u = vdir_pick_by_weight(vd, w * tw, vbm); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req)) + if (be->healthy(be, req->digest)) break; if (l == 0) { vbm = vd->vbm; diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 76795d7..1bd8648 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -47,6 +47,6 @@ void vdir_delete(struct vdir **vdp); void vdir_lock(struct vdir *vd); void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight); -unsigned vdir_any_healthy(struct vdir *vd, const struct req *); +unsigned vdir_any_healthy(struct vdir *vd, const uint8_t *digest); VCL_BACKEND vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops); From phk at varnish-cache.org Mon Apr 29 13:43:28 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 15:43:28 +0200 Subject: [master] da10ea3 Make VDI_Healthy() req/busyobj agnostic. Message-ID: commit da10ea304ca9c20afaf36bc3eb672968b42ae758 Author: Poul-Henning Kamp Date: Mon Apr 29 13:43:13 2013 +0000 Make VDI_Healthy() req/busyobj agnostic. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e24fe84..e77ebc8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -735,7 +735,7 @@ void VBE_DiscardHealth(const struct director *vdi); struct vbc *VDI_GetFd(const struct director *, struct req *); -int VDI_Healthy(const struct director *, const struct req *); +int VDI_Healthy(const struct director *, const uint8_t *digest); void VDI_CloseFd(struct vbc **vbp); void VDI_RecycleFd(struct vbc **vbp); void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 68e6e99..f4a21c9 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -123,10 +123,9 @@ VDI_GetFd(const struct director *d, struct req *req) */ int -VDI_Healthy(const struct director *d, const struct req *req) +VDI_Healthy(const struct director *d, const uint8_t *digest) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->healthy(d, req->digest)); + return (d->healthy(d, digest)); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3c6c96d..cefc1ce 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -779,7 +779,7 @@ VSLb(req->vsl, SLT_Debug, "XXXX EXP\n"); VSLb(req->vsl, SLT_Debug, "XXXX EXPBUSY\n"); AN(oc); AN(boc); - if (VDI_Healthy(req->director, req)) { + if (VDI_Healthy(req->director, req->digest)) { VSLb(req->vsl, SLT_Debug, "deref oc\n"); (void)HSH_Deref(&wrk->stats, oc, NULL); oc = boc; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 9395c73..605f44f 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -279,7 +279,7 @@ VRT_r_req_backend_healthy(const struct req *req) if (req->director == NULL) return (0); CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC); - return (VDI_Healthy(req->director, req)); + return (VDI_Healthy(req->director, req->digest)); } /*--------------------------------------------------------------------*/ @@ -308,8 +308,7 @@ VRT_r_bereq_backend_healthy(const struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->director, DIRECTOR_MAGIC); - //XXX return (VDI_Healthy(bo->director, req)); - return (0); + return (VDI_Healthy(bo->director, bo->digest)); } /*--------------------------------------------------------------------*/ From phk at varnish-cache.org Mon Apr 29 14:35:09 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 16:35:09 +0200 Subject: [master] a5f32fd Start sorting VCL variables into "client", "backend" or "both". Message-ID: commit a5f32fd8f201e0d1f25dc7236bde37b7fa815d74 Author: Poul-Henning Kamp Date: Mon Apr 29 14:34:30 2013 +0000 Start sorting VCL variables into "client", "backend" or "both". Fix some test-cases to match, generally s/req.*/bereq.*/ diff --git a/bin/varnishtest/tests/c00001.vtc b/bin/varnishtest/tests/c00001.vtc index 860e827..7497ec3 100644 --- a/bin/varnishtest/tests/c00001.vtc +++ b/bin/varnishtest/tests/c00001.vtc @@ -22,7 +22,7 @@ varnish v1 -vcl+backend { set beresp.http.Snafu6 = regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p\"); set beresp.http.Snafu7 = - regsub(beresp.http.Foobar, "ar", req.http.nosuchheader); + regsub(beresp.http.Foobar, "ar", bereq.http.nosuchheader); } } -start diff --git a/bin/varnishtest/tests/c00032.vtc b/bin/varnishtest/tests/c00032.vtc index a3b5c92..d5d06e3 100644 --- a/bin/varnishtest/tests/c00032.vtc +++ b/bin/varnishtest/tests/c00032.vtc @@ -20,8 +20,8 @@ varnish v1 -vcl+backend { } } - sub vcl_backend_response { - if (beresp.status == 400) { + sub vcl_deliver { + if (resp.status == 400) { rollback; set req.url = "/bar"; return (restart); diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc index a4dfa7e..db4ed17 100644 --- a/bin/varnishtest/tests/g00003.vtc +++ b/bin/varnishtest/tests/g00003.vtc @@ -21,7 +21,7 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { sub vcl_backend_response { set beresp.do_gunzip = true; - if (req.url == "/foobar") { + if (bereq.url == "/foobar") { set beresp.do_gzip = true; } } diff --git a/bin/varnishtest/tests/g00004.vtc b/bin/varnishtest/tests/g00004.vtc index 286fc98..703cacc 100644 --- a/bin/varnishtest/tests/g00004.vtc +++ b/bin/varnishtest/tests/g00004.vtc @@ -22,7 +22,7 @@ varnish v1 \ sub vcl_backend_response { set beresp.do_stream = false; - if (req.url == "/gunzip") { + if (bereq.url == "/gunzip") { set beresp.do_gunzip = true; } } diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc index 07d6c2c..d72c627 100644 --- a/bin/varnishtest/tests/p00008.vtc +++ b/bin/varnishtest/tests/p00008.vtc @@ -20,7 +20,7 @@ varnish v1 \ -vcl+backend { sub vcl_backend_response { set beresp.storage = "per1"; - if (req.url ~ "silo2") { + if (bereq.url ~ "silo2") { set beresp.storage = "per2"; } } diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index eb5f3d5..2d323b0 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -64,9 +64,9 @@ varnish v1 -vcl { if (beresp.ttl > 1d) { set beresp.ttl = 1d; } - if (req.backend == b) { + if (bereq.backend == b) { set beresp.ttl = 1d; - } else if (req.backend != b) { + } else if (bereq.backend != b) { set beresp.ttl = 1h; } } diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index bd5e6ab..a4b3b7a 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -78,126 +78,128 @@ tokens = { # Our methods and actions returns =( - ('recv', ('error', 'pass', 'pipe', 'lookup',)), - ('pipe', ('error', 'pipe',)), - ('pass', ('error', 'restart', 'pass',)), - ('hash', ('hash',)), - ('miss', ('error', 'restart', 'pass', 'fetch',)), - ('lookup', ('error', 'restart', 'pass', 'deliver',)), - ('backend_fetch', ('error', 'fetch', 'pass',)), - ('backend_response', ('error', 'restart', 'deliver',)), - ('deliver', ('restart', 'deliver',)), - ('error', ('restart', 'deliver',)), - ('init', ('ok',)), - ('fini', ('ok',)), + ('recv', "C", ('error', 'pass', 'pipe', 'lookup',)), + ('pipe', "C", ('error', 'pipe',)), + ('pass', "C", ('error', 'restart', 'pass',)), + ('hash', "C", ('hash',)), + ('miss', "C", ('error', 'restart', 'pass', 'fetch',)), + ('lookup', "C", ('error', 'restart', 'pass', 'deliver',)), + ('backend_fetch', "B", ('error', 'fetch', 'pass',)), + ('backend_response', "B", ('error', 'restart', 'deliver',)), + ('deliver', "C", ('restart', 'deliver',)), + ('error', "C", ('restart', 'deliver',)), + ('init', "", ('ok',)), + ('fini', "", ('ok',)), ) ####################################################################### # Variables available in sessions # # 'all' means all methods -# 'proc' means all methods but 'init' and 'fini' +# 'client' means all methods tagged "C" +# 'backend' means all methods tagged "B" +# 'both' means all methods tagged "B" or "C" sp_variables = ( ('client.ip', 'IP', - ( 'proc',), + ( 'both',), ( ), 'R' ), ('client.identity', 'STRING', - ( 'proc',), - ( 'proc',), + ( 'both',), + ( 'both',), 'R' ), ('server.ip', 'IP', - ( 'proc',), + ( 'client',), ( ), 'R' ), ('server.hostname', 'STRING', - ( 'proc',), + ( 'client',), ( ), 'R' ), ('server.identity', 'STRING', - ( 'proc',), + ( 'client',), ( ), 'R' ), ('server.port', 'INT', - ( 'proc',), + ( 'client',), ( ), 'R' ), ('req.method', 'STRING', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'cR' ), ('req.request', 'STRING', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'cR' ), ('req.url', 'STRING', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'cR' ), ('req.proto', 'STRING', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'cR' ), ('req.http.', 'HEADER', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'cR' ), ('req.restarts', 'INT', - ( 'proc',), + ( 'client',), ( ), 'cR' ), ('req.esi_level', 'INT', - ( 'proc',), + ( 'client',), ( ), 'cR' ), ('req.ttl', 'DURATION', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'R' ), ('req.grace', 'DURATION', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'R' ), ('req.keep', 'DURATION', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'R' ), ('req.xid', 'STRING', - ( 'proc',), + ( 'client',), ( ), 'R' ), @@ -209,19 +211,19 @@ sp_variables = ( ), ('req.can_gzip', 'BOOL', - ( 'proc',), + ( 'client',), ( ), 'R' ), ('req.backend', 'BACKEND', - ( 'proc',), - ( 'proc',), + ( 'client',), + ( 'client',), 'R' ), ('req.backend.healthy', 'BOOL', - ( 'proc',), + ( 'client',), ( ), 'R' ), @@ -239,13 +241,13 @@ sp_variables = ( ), ('bereq.backend', 'BACKEND', - ( 'backend_fetch', 'backend_response'), - ( 'backend_fetch', 'backend_response'), + ( 'backend', ), + ( 'backend', ), 'B' ), ('bereq.backend.healthy', 'BOOL', - ( 'backend_fetch', 'backend_response'), + ( 'backend', ), ( ), 'B' ), @@ -710,9 +712,16 @@ fo.close() rets = dict() vcls = list() +vcls_client = list() +vcls_backend = list() for i in returns: vcls.append(i[0]) for j in i[1]: + if j == "B": + vcls_backend.append(i[0]) + elif j == "C": + vcls_client.append(i[0]) + for j in i[2]: rets[j] = True ####################################################################### @@ -730,7 +739,7 @@ for i in l: fo.write("VCL_RET_MAC(%s, %s" % (i.lower(), i.upper())) s=", " for j in returns: - if i in j[1]: + if i in j[2]: fo.write("%sVCL_MET_%s" % (s, j[0].upper())) s = " | " fo.write(")\n") @@ -740,7 +749,7 @@ fo.write("\n#ifdef VCL_MET_MAC\n") for i in returns: fo.write("VCL_MET_MAC(%s,%s,\n" % (i[0].lower(), i[0].upper())) p = " (" - for j in i[1]: + for j in i[2]: fo.write(" %s(1U << VCL_RET_%s)\n" % (p, j.upper())) p = "| " fo.write("))\n") @@ -827,11 +836,13 @@ def restrict(fo, spec): return if spec[0] == 'all': spec = vcls - if spec[0] == 'proc': - spec = list() - for i in vcls: - if i != "init" and i != "fini": - spec.append(i) + if spec[0] == 'client': + spec = vcls_client + if spec[0] == 'backend': + spec = vcls_backend + if spec[0] == 'both': + spec = vcls_client + spec += vcls_backend p = "" n = 0 for j in spec: From phk at varnish-cache.org Mon Apr 29 15:19:56 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 17:19:56 +0200 Subject: [master] 8b86482 Start moving the backend->getfd() stuff from req to busyobj Message-ID: commit 8b86482c57b6599c60bb43e090af8e3de96cc27f Author: Poul-Henning Kamp Date: Mon Apr 29 15:19:32 2013 +0000 Start moving the backend->getfd() stuff from req to busyobj diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 45d9943..693f631 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -88,10 +88,10 @@ VBE_ReleaseConn(struct vbc *vc) MPL_Free(vbcpool, vc); } -#define FIND_TMO(tmx, dst, req, be) \ +#define FIND_TMO(tmx, dst, bo, be) \ do { \ - CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); \ - dst = req->busyobj->tmx; \ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ + dst = bo->tmx; \ if (dst == 0.0) \ dst = be->tmx; \ if (dst == 0.0) \ @@ -108,20 +108,21 @@ VBE_ReleaseConn(struct vbc *vc) */ static int -vbe_TryConnect(const struct req *req, int pf, const struct sockaddr_storage *sa, - socklen_t salen, const struct vdi_simple *vs) +vbe_TryConnect(const struct busyobj *bo, int pf, + const struct sockaddr_storage *sa, socklen_t salen, + const struct vdi_simple *vs) { int s, i, tmo; double tmod; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); s = socket(pf, SOCK_STREAM, 0); if (s < 0) return (s); - FIND_TMO(connect_timeout, tmod, req, vs->vrt); + FIND_TMO(connect_timeout, tmod, bo, vs->vrt); tmo = (int)(tmod * 1000.0); @@ -138,13 +139,14 @@ vbe_TryConnect(const struct req *req, int pf, const struct sockaddr_storage *sa, /*--------------------------------------------------------------------*/ static void -bes_conn_try(struct req *req, struct vbc *vc, const struct vdi_simple *vs) +bes_conn_try(struct busyobj *bo, struct vbc *vc, const struct vdi_simple *vs) { int s; struct backend *bp = vs->backend; char abuf1[VTCP_ADDRBUFSIZE]; char pbuf1[VTCP_PORTBUFSIZE]; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); Lck_Lock(&bp->mtx); @@ -158,17 +160,17 @@ bes_conn_try(struct req *req, struct vbc *vc, const struct vdi_simple *vs) /* release lock during stuff that can take a long time */ if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = vbe_TryConnect(req, PF_INET6, bp->ipv6, bp->ipv6len, vs); + s = vbe_TryConnect(bo, PF_INET6, bp->ipv6, bp->ipv6len, vs); vc->addr = bp->ipv6; vc->addrlen = bp->ipv6len; } if (s == -1 && bp->ipv4 != NULL) { - s = vbe_TryConnect(req, PF_INET, bp->ipv4, bp->ipv4len, vs); + s = vbe_TryConnect(bo, PF_INET, bp->ipv4, bp->ipv4len, vs); vc->addr = bp->ipv4; vc->addrlen = bp->ipv4len; } if (s == -1 && !cache_param->prefer_ipv6 && bp->ipv6 != NULL) { - s = vbe_TryConnect(req, PF_INET6, bp->ipv6, bp->ipv6len, vs); + s = vbe_TryConnect(bo, PF_INET6, bp->ipv6, bp->ipv6len, vs); vc->addr = bp->ipv6; vc->addrlen = bp->ipv6len; } @@ -183,10 +185,9 @@ bes_conn_try(struct req *req, struct vbc *vc, const struct vdi_simple *vs) vc->addrlen = 0; } else { VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - VSLb(req->vsl, SLT_BackendOpen, "%d %s %s %s ", + VSLb(bo->vsl, SLT_BackendOpen, "%d %s %s %s ", vc->fd, vs->backend->display_name, abuf1, pbuf1); } - } /*-------------------------------------------------------------------- @@ -335,12 +336,12 @@ vbe_Healthy(const struct vdi_simple *vs, const uint8_t *digest) */ static struct vbc * -vbe_GetVbe(struct req *req, struct vdi_simple *vs) +vbe_GetVbe(struct busyobj *bo, struct vdi_simple *vs) { struct vbc *vc; struct backend *bp; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); bp = vs->backend; CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); @@ -362,20 +363,20 @@ vbe_GetVbe(struct req *req, struct vdi_simple *vs) if (vbe_CheckFd(vc->fd)) { /* XXX locking of stats */ VSC_C_main->backend_reuse += 1; - VSLb(req->vsl, SLT_Backend, "%d %s %s", - vc->fd, req->director->vcl_name, + VSLb(bo->vsl, SLT_Backend, "%d %s %s", + vc->fd, bo->director->vcl_name, bp->display_name); vc->vdis = vs; vc->recycled = 1; return (vc); } VSC_C_main->backend_toolate++; - VSLb(req->vsl, SLT_BackendClose, "%d %s toolate", + VSLb(bo->vsl, SLT_BackendClose, "%d %s toolate", vc->fd, bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - VSL_Flush(req->vsl, 0); + VSL_Flush(bo->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -383,7 +384,7 @@ vbe_GetVbe(struct req *req, struct vdi_simple *vs) VBE_ReleaseConn(vc); } - if (!vbe_Healthy(vs, req->digest)) { + if (!vbe_Healthy(vs, bo->digest)) { VSC_C_main->backend_unhealthy++; return (NULL); } @@ -397,7 +398,7 @@ vbe_GetVbe(struct req *req, struct vdi_simple *vs) vc = vbe_NewConn(); assert(vc->fd == -1); AZ(vc->backend); - bes_conn_try(req, vc, vs); + bes_conn_try(bo, vc, vs); if (vc->fd < 0) { VBE_ReleaseConn(vc); VSC_C_main->backend_fail++; @@ -405,8 +406,8 @@ vbe_GetVbe(struct req *req, struct vdi_simple *vs) } vc->backend = bp; VSC_C_main->backend_conn++; - VSLb(req->vsl, SLT_Backend, "%d %s %s", - vc->fd, req->director->vcl_name, bp->display_name); + VSLb(bo->vsl, SLT_Backend, "%d %s %s", + vc->fd, bo->director->vcl_name, bp->display_name); vc->vdis = vs; return (vc); } @@ -462,12 +463,12 @@ vdi_simple_getfd(const struct director *d, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - vc = vbe_GetVbe(req, vs); + vc = vbe_GetVbe(req->busyobj, vs); if (vc != NULL) { FIND_TMO(first_byte_timeout, - vc->first_byte_timeout, req, vs->vrt); + vc->first_byte_timeout, req->busyobj, vs->vrt); FIND_TMO(between_bytes_timeout, - vc->between_bytes_timeout, req, vs->vrt); + vc->between_bytes_timeout, req->busyobj, vs->vrt); } return (vc); } From phk at varnish-cache.org Mon Apr 29 15:36:30 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 29 Apr 2013 17:36:30 +0200 Subject: [master] 860d7de Push the req->busyobj change all the way up through getfd. Message-ID: commit 860d7de5ded545042fb5a64ef1f8986a05421247 Author: Poul-Henning Kamp Date: Mon Apr 29 15:36:03 2013 +0000 Push the req->busyobj change all the way up through getfd. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e77ebc8..ccbd56c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -734,7 +734,7 @@ void VBE_UseHealth(const struct director *vdi); void VBE_DiscardHealth(const struct director *vdi); -struct vbc *VDI_GetFd(const struct director *, struct req *); +struct vbc *VDI_GetFd(const struct director *, struct busyobj *); int VDI_Healthy(const struct director *, const uint8_t *digest); void VDI_CloseFd(struct vbc **vbp); void VDI_RecycleFd(struct vbc **vbp); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 693f631..f3ae536 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -455,20 +455,20 @@ VBE_DiscardHealth(const struct director *vdi) */ static struct vbc * __match_proto__(vdi_getfd_f) -vdi_simple_getfd(const struct director *d, struct req *req) +vdi_simple_getfd(const struct director *d, struct busyobj *bo) { struct vdi_simple *vs; struct vbc *vc; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC); - vc = vbe_GetVbe(req->busyobj, vs); + vc = vbe_GetVbe(bo, vs); if (vc != NULL) { FIND_TMO(first_byte_timeout, - vc->first_byte_timeout, req->busyobj, vs->vrt); + vc->first_byte_timeout, bo, vs->vrt); FIND_TMO(between_bytes_timeout, - vc->between_bytes_timeout, req->busyobj, vs->vrt); + vc->between_bytes_timeout, bo, vs->vrt); } return (vc); } diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 13d452e..97f7898 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -75,7 +75,7 @@ struct vrt_backend_probe; * backends to use. */ -typedef struct vbc *vdi_getfd_f(const struct director *, struct req *); +typedef struct vbc *vdi_getfd_f(const struct director *, struct busyobj *); typedef void vdi_fini_f(const struct director *); typedef unsigned vdi_healthy(const struct director *, const uint8_t *digest); diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index f4a21c9..366b864 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -101,17 +101,17 @@ VDI_RecycleFd(struct vbc **vbp) /* Get a connection --------------------------------------------------*/ struct vbc * -VDI_GetFd(const struct director *d, struct req *req) +VDI_GetFd(const struct director *d, struct busyobj *bo) { struct vbc *vc; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); if (d == NULL) - d = req->director; + d = bo->director; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - vc = d->getfd(d, req); + vc = d->getfd(d, bo); if (vc != NULL) - vc->vsl = req->busyobj->vsl; + vc->vsl = bo->vsl; return (vc); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f4befdf..951e367 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -383,7 +383,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody) hp = bo->bereq; - bo->vbc = VDI_GetFd(NULL, req); + bo->vbc = VDI_GetFd(NULL, bo); if (bo->vbc == NULL) { VSLb(req->vsl, SLT_FetchError, "no backend connection"); return (-1); diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 36c48ad..e76151b 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -75,7 +75,7 @@ PipeRequest(struct req *req) bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - vc = VDI_GetFd(NULL, req); + vc = VDI_GetFd(NULL, bo); if (vc == NULL) return; bo->vbc = vc; /* For panic dumping */ diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index af25ac3..7907700 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -54,7 +54,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) } static struct vbc * __match_proto__(vdi_getfd_f) -vmod_rr_getfd(const struct director *dir, struct req *req) +vmod_rr_getfd(const struct director *dir, struct busyobj *bo) { struct vmod_directors_fallback *rr; unsigned u; @@ -65,13 +65,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req) for (u = 0; u < rr->vd->n_backend; u++) { be = rr->vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req->digest)) + if (be->healthy(be, bo->digest)) break; } vdir_unlock(rr->vd); if (u == rr->vd->n_backend || be == NULL) return (NULL); - return (be->getfd(be, req)); + return (be->getfd(be, bo)); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index ea011a3..ac9bd41 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -118,6 +118,6 @@ vmod_hash_backend(struct req *req, struct vmod_directors_hash *rr, const char *a r = vbe32dec(sha256); r = scalbn(r, -32); - be = vdir_pick_be(rr->vd, req, r, rr->nloops); + be = vdir_pick_be(rr->vd, req->busyobj, r, rr->nloops); return (be); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index d12b5b2..d51c170 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -59,7 +59,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) } static struct vbc * __match_proto__(vdi_getfd_f) -vmod_rr_getfd(const struct director *dir, struct req *req) +vmod_rr_getfd(const struct director *dir, struct busyobj *bo) { struct vmod_directors_random *rr; VCL_BACKEND be; @@ -67,10 +67,10 @@ vmod_rr_getfd(const struct director *dir, struct req *req) CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); r = scalbn(random(), -31); - be = vdir_pick_be(rr->vd, req, r, rr->nloops); + be = vdir_pick_be(rr->vd, bo, r, rr->nloops); if (be == NULL) return (NULL); - return (be->getfd(be, req)); + return (be->getfd(be, bo)); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index 35e2454..fb4ba92 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -55,7 +55,7 @@ vmod_rr_healthy(const struct director *dir, const uint8_t *digest) } static struct vbc * __match_proto__(vdi_getfd_f) -vmod_rr_getfd(const struct director *dir, struct req *req) +vmod_rr_getfd(const struct director *dir, struct busyobj *bo) { struct vmod_directors_round_robin *rr; unsigned u; @@ -68,13 +68,13 @@ vmod_rr_getfd(const struct director *dir, struct req *req) be = rr->vd->backend[rr->nxt]; rr->nxt++; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req->digest)) + if (be->healthy(be, bo->digest)) break; } vdir_unlock(rr->vd); if (u == rr->vd->n_backend || be == NULL) return (NULL); - return (be->getfd(be, req)); + return (be->getfd(be, bo)); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index c921cf0..62b0033 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -169,7 +169,8 @@ vdir_pick_by_weight(const struct vdir *vd, double w, } VCL_BACKEND -vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops) +vdir_pick_be(struct vdir *vd, const struct busyobj *bo, double w, + unsigned nloops) { struct vbitmap *vbm = NULL; unsigned u, v, l; @@ -185,7 +186,7 @@ vdir_pick_be(struct vdir *vd, const struct req *req, double w, unsigned nloops) u = vdir_pick_by_weight(vd, w * tw, vbm); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (be->healthy(be, req->digest)) + if (be->healthy(be, bo->digest)) break; if (l == 0) { vbm = vd->vbm; diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 1bd8648..fa7a458 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -48,5 +48,5 @@ void vdir_lock(struct vdir *vd); void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight); unsigned vdir_any_healthy(struct vdir *vd, const uint8_t *digest); -VCL_BACKEND vdir_pick_be(struct vdir *vd, const struct req *req, double w, +VCL_BACKEND vdir_pick_be(struct vdir *vd, const struct busyobj *, double w, unsigned nloops); From phk at varnish-cache.org Tue Apr 30 09:04:01 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 11:04:01 +0200 Subject: [master] 8a3dfdf The arguments we pass to the VCL and VRT code is getting out of hand and I've already forgot about them one important place already. Message-ID: commit 8a3dfdf3291190193616f5047ddda5a01dfad063 Author: Poul-Henning Kamp Date: Tue Apr 30 09:02:04 2013 +0000 The arguments we pass to the VCL and VRT code is getting out of hand and I've already forgot about them one important place already. Introduce a "VRT_context", which is a container holding all the bits we want to pass to VCL and VRT. Implement it first for VRT_count(), which is, BTW, how I realized I had forgotten to pass all the new arguments to user defined functions. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 43ecc7c..7dd3c8b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -39,6 +39,7 @@ #include "cache.h" #include "vcl.h" +#include "vrt.h" #include "vcli.h" #include "vcli_priv.h" @@ -172,8 +173,13 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) { struct vcls *vcl; struct VCL_conf const *cnf; + struct vrt_ctx ctx; ASSERT_CLI(); + + memset(&ctx, 0, sizeof ctx); + ctx.magic = VRT_CTX_MAGIC; + vcl = vcl_find(name); if (vcl != NULL) { VCLI_Out(cli, "Config '%s' already loaded", name); @@ -214,7 +220,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(NULL, NULL, NULL, NULL); + (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -232,13 +238,16 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) static void VCL_Nuke(struct vcls *vcl) { + struct vrt_ctx ctx; + memset(&ctx, 0, sizeof ctx); + ctx.magic = VRT_CTX_MAGIC; ASSERT_CLI(); assert(vcl != vcl_active); assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(NULL, NULL, NULL, NULL); + (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -368,18 +377,26 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, { char *aws; struct vsl_log *vsl; + struct vrt_ctx ctx; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + memset(&ctx, 0, sizeof ctx); + ctx.magic = VRT_CTX_MAGIC; if (req != NULL) { AZ(bo); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); vsl = req->vsl; + ctx.vsl = vsl; + ctx.vcl = req->vcl; } else { AZ(req); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vsl = bo->vsl; + ctx.vsl = vsl; + ctx.vcl = bo->vcl; } + ctx.ws = ws; if (method == VCL_MET_BACKEND_FETCH || method == VCL_MET_PASS || method == VCL_MET_MISS || @@ -394,7 +411,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, wrk->handling = 0; wrk->cur_method = method; VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); - (void)func(wrk, req, bo, ws); + (void)func(&ctx, wrk, req, bo, ws); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method = 0; WS_Reset(wrk->aws, aws); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index aa16783..4f87829 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -86,14 +86,13 @@ VRT_error(struct req *req, unsigned code, const char *reason) /*--------------------------------------------------------------------*/ void -VRT_count(struct req *req, unsigned u) +VRT_count(const struct vrt_ctx *ctx, unsigned u) { - if (req == NULL) - return; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - VSLb(req->vsl, SLT_VCL_trace, "%u %u.%u", u, - req->vcl->ref[u].line, req->vcl->ref[u].pos); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->vsl != NULL) + VSLb(ctx->vsl, SLT_VCL_trace, "%u %u.%u", u, + ctx->vcl->ref[u].line, ctx->vcl->ref[u].pos); } /*--------------------------------------------------------------------*/ diff --git a/include/vrt.h b/include/vrt.h index 9dfc649..acf736b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -32,7 +32,10 @@ */ struct req; +struct busyobj; struct worker; +struct vsl_log; +struct http; struct ws; struct vsb; struct cli; @@ -58,6 +61,29 @@ typedef const char * VCL_STRING; typedef double VCL_TIME; typedef void VCL_VOID; +/*********************************************************************** + * This is the composite argument we pass to compiled VCL and VRT + * functions. + */ + +struct vrt_ctx { + unsigned magic; +#define VRT_CTX_MAGIC 0x6bb8f0db + + struct vsl_log *vsl; + struct VCL_conf *vcl; + struct ws *ws; + + struct req *req; + struct http *http_req; + struct http *http_obj; + struct http *http_resp; + + struct busyobj *bo; + struct http *http_bereq; + struct http *http_beresp; +}; + /***********************************************************************/ enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ, HDR_BERESP }; @@ -172,7 +198,7 @@ const char *VRT_regsub(struct req *, int all, const char *, void VRT_ban_string(const char *); void VRT_purge(const struct worker *, struct req *, double ttl, double grace); -void VRT_count(struct req *, unsigned); +void VRT_count(const struct vrt_ctx *, unsigned); int VRT_rewrite(const char *, const char *); void VRT_error(struct req *, unsigned, const char *); int VRT_switch_config(const char *); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index a4b3b7a..1a1c2bd 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -765,6 +765,7 @@ file_header(fo) fo.write(""" struct sess; +struct vrt_ctx; struct req; struct busyobj; struct ws; @@ -773,7 +774,7 @@ struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(struct worker *, struct req *, struct busyobj *, +typedef int vcl_func_f(struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *, struct ws *); """) diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index 6a08e45..217aee4 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -46,7 +46,7 @@ parse_call(struct vcc *tl) ExpectErr(tl, ID); vcc_AddCall(tl, tl->t); vcc_AddRef(tl, tl->t, SYM_SUB); - Fb(tl, 1, "if (VGC_function_%.*s(req))\n", PF(tl->t)); + Fb(tl, 1, "if (VGC_function_%.*s(ctx, req))\n", PF(tl->t)); Fb(tl, 1, "\treturn (1);\n"); vcc_NextToken(tl); return; diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 30a71cb..d6dd786 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -693,7 +693,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) for (i = 0; i < VCL_MET_MAX; i++) { Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); Fc(tl, 1, - "VGC_function_%s(struct worker *wrk," + "VGC_function_%s(struct vrt_ctx *ctx, struct worker *wrk," " struct req *req, struct busyobj *bo, struct ws *ws)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index af97241..75e976f 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -47,7 +47,7 @@ static void vcc_Compound(struct vcc *tl); } while (0) #define C(tl, sep) do { \ - Fb(tl, 1, "VRT_count(req, %u)%s\n", ++tl->cnt, sep); \ + Fb(tl, 1, "VRT_count(ctx, %u)%s\n", ++tl->cnt, sep); \ tl->t->cnt = tl->cnt; \ } while (0) @@ -237,10 +237,10 @@ vcc_Function(struct vcc *tl) } tl->curproc = vcc_AddProc(tl, tl->t); Fh(tl, 0, "static int VGC_function_%.*s " - "(struct req *);\n", PF(tl->t)); + "(struct vrt_ctx *ctx, struct req *);\n", PF(tl->t)); Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_t)\n"); - Fc(tl, 1, "VGC_function_%.*s(struct req *req)\n", - PF(tl->t)); + Fc(tl, 1, "VGC_function_%.*s(struct vrt_ctx *ctx, " + "struct req *req)\n", PF(tl->t)); } vcc_NextToken(tl); tl->indent += INDENT; From phk at varnish-cache.org Tue Apr 30 09:37:29 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 11:37:29 +0200 Subject: [master] 2e3b542 Make the VRT_[GS]etHdr() take vrt_ctx arg. Message-ID: commit 2e3b542dc27671ca2c3233544f34463e44212725 Author: Poul-Henning Kamp Date: Tue Apr 30 09:37:04 2013 +0000 Make the VRT_[GS]etHdr() take vrt_ctx arg. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 7dd3c8b..d17d6aa 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -376,7 +376,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, struct ws *ws, unsigned method, vcl_func_f *func) { char *aws; - struct vsl_log *vsl; + struct vsl_log *vsl = NULL; struct vrt_ctx ctx; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -389,14 +389,11 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, vsl = req->vsl; ctx.vsl = vsl; ctx.vcl = req->vcl; - } else { - AZ(req); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - vsl = bo->vsl; - ctx.vsl = vsl; - ctx.vcl = bo->vcl; + ctx.http_req = req->http; + ctx.http_resp = req->resp; + if (req->obj) + ctx.http_obj = req->obj->http; } - ctx.ws = ws; if (method == VCL_MET_BACKEND_FETCH || method == VCL_MET_PASS || method == VCL_MET_MISS || @@ -407,9 +404,20 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); } + if (bo != NULL) { + // AZ(req); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vsl = bo->vsl; + ctx.vsl = vsl; + ctx.vcl = bo->vcl; + ctx.http_bereq = bo->bereq; + ctx.http_beresp = bo->beresp; + } + ctx.ws = ws; aws = WS_Snapshot(wrk->aws); wrk->handling = 0; wrk->cur_method = method; + AN(vsl); VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); (void)func(&ctx, wrk, req, bo, ws); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4f87829..8449a6a 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -107,43 +107,42 @@ VRT_acl_log(struct req *req, const char *msg) /*--------------------------------------------------------------------*/ static struct http * -vrt_selecthttp(const struct req *req, enum gethdr_e where) +vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where) { struct http *hp; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); switch (where) { case HDR_REQ: - hp = req->http; + hp = ctx->http_req; break; case HDR_BEREQ: - hp = req->busyobj->bereq; + hp = ctx->http_bereq; break; case HDR_BERESP: - hp = req->busyobj->beresp; + hp = ctx->http_beresp; break; case HDR_RESP: - hp = req->resp; + hp = ctx->http_resp; break; case HDR_OBJ: - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - hp = req->obj->http; + hp = ctx->http_obj; break; default: INCOMPL(); } - CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); return (hp); } char * -VRT_GetHdr(const struct req *req, const struct gethdr_s *hs) +VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs) { char *p; struct http *hp; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - hp = vrt_selecthttp(req, hs->where); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + hp = vrt_selecthttp(ctx, hs->where); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (!http_GetHdr(hp, hs->what, &p)) return (NULL); return (p); @@ -229,23 +228,25 @@ VRT_CollectString(struct ws *ws, const char *p, ...) /*--------------------------------------------------------------------*/ void -VRT_SetHdr(struct req *req , const struct gethdr_s *hs, const char *p, ...) +VRT_SetHdr(const struct vrt_ctx *ctx , const struct gethdr_s *hs, + const char *p, ...) { struct http *hp; va_list ap; char *b; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(hs); AN(hs->what); - hp = vrt_selecthttp(req, hs->where); + hp = vrt_selecthttp(ctx, hs->where); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); va_start(ap, p); if (p == vrt_magic_string_unset) { http_Unset(hp, hs->what); } else { b = VRT_String(hp->ws, hs->what + 1, p, ap); if (b == NULL) { - VSLb(req->vsl, SLT_LostHeader, "%s", hs->what + 1); + VSLb(ctx->vsl, SLT_LostHeader, "%s", hs->what + 1); } else { http_Unset(hp, hs->what); http_SetHeader(hp, b); diff --git a/include/vrt.h b/include/vrt.h index acf736b..b0e752f 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -204,8 +204,8 @@ void VRT_error(struct req *, unsigned, const char *); int VRT_switch_config(const char *); const struct gethdr_s *VRT_MkGethdr(struct req *,enum gethdr_e, const char *); -char *VRT_GetHdr(const struct req *, const struct gethdr_s *); -void VRT_SetHdr(struct req *, const struct gethdr_s *, const char *, ...); +char *VRT_GetHdr(const struct vrt_ctx *, const struct gethdr_s *); +void VRT_SetHdr(const struct vrt_ctx *, const struct gethdr_s *, const char *, ...); void VRT_handling(struct worker *, unsigned hand); void VRT_hashdata(struct req *, const char *str, ...); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 1a1c2bd..140635b 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -165,7 +165,7 @@ sp_variables = ( 'HEADER', ( 'client',), ( 'client',), - 'cR' + 'C' ), ('req.restarts', 'INT', @@ -279,7 +279,7 @@ sp_variables = ( 'HEADER', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cR' + 'C' ), ('bereq.connect_timeout', 'DURATION', @@ -327,7 +327,7 @@ sp_variables = ( 'HEADER', ( 'backend_response',), ( 'backend_response',), - 'cR' + 'C' ), ('beresp.do_esi', 'BOOL', @@ -435,7 +435,7 @@ sp_variables = ( 'HEADER', ( 'lookup', 'error',), ( 'error',), # XXX ? - 'cR' + 'C' ), ('obj.ttl', 'DURATION', @@ -489,7 +489,7 @@ sp_variables = ( 'HEADER', ( 'deliver',), ( 'deliver',), - 'cR' + 'C' ), ('now', 'TIME', @@ -885,6 +885,8 @@ def mk_proto(c, r=False): s += " const" elif i == "c": pass + elif i == "C": + s += "const struct vrt_ctx *" elif i == "R": if r: s += " const" diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 7caf25e..715a4c9 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -418,7 +418,7 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) case BYTES: p = "VRT_REAL_string(ws, \v1)"; break; /* XXX */ case REAL: p = "VRT_REAL_string(ws, \v1)"; break; case TIME: p = "VRT_TIME_string(ws, \v1)"; break; - case HEADER: p = "VRT_GetHdr(req, \v1)"; break; + case HEADER: p = "VRT_GetHdr(ctx, \v1)"; break; case ENUM: case STRING: case STRING_LIST: diff --git a/lib/libvcl/vcc_var.c b/lib/libvcl/vcc_var.c index 5afec43..74713b8 100644 --- a/lib/libvcl/vcc_var.c +++ b/lib/libvcl/vcc_var.c @@ -78,7 +78,7 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) bprintf(buf, "&VGC_%s_%s", vh->rname, cnam); v->rname = TlDup(tl, buf); - bprintf(buf, "VRT_SetHdr(req, %s, ", v->rname); + bprintf(buf, "VRT_SetHdr(ctx, %s, ", v->rname); v->lname = TlDup(tl, buf); sym = VCC_AddSymbolTok(tl, t, SYM_VAR); From phk at varnish-cache.org Tue Apr 30 09:52:06 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 11:52:06 +0200 Subject: [master] 1c759b8 Move acls to vrt_ctx Message-ID: commit 1c759b879db8551b5d3689c80ca726eb2603bb2a Author: Poul-Henning Kamp Date: Tue Apr 30 09:51:58 2013 +0000 Move acls to vrt_ctx diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 8449a6a..8d361b1 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -98,10 +98,11 @@ VRT_count(const struct vrt_ctx *ctx, unsigned u) /*--------------------------------------------------------------------*/ void -VRT_acl_log(struct req *req, const char *msg) +VRT_acl_log(const struct vrt_ctx *ctx, const char *msg) { - VSLb(req->vsl, SLT_VCL_acl, "%s", msg); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + VSLb(ctx->vsl, SLT_VCL_acl, "%s", msg); } /*--------------------------------------------------------------------*/ diff --git a/include/vrt.h b/include/vrt.h index b0e752f..2e230ad 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -182,7 +182,7 @@ struct vrt_ref { /* ACL related */ #define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */ -void VRT_acl_log(struct req *, const char *msg); +void VRT_acl_log(const struct vrt_ctx *, const char *msg); /* req related */ diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c index d3db319..9c9e117 100644 --- a/lib/libvcl/vcc_acl.c +++ b/lib/libvcl/vcc_acl.c @@ -357,7 +357,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) const char *oc; Fh(tl, 0, "\nstatic int\n"); - Fh(tl, 0, "match_acl_%s_%s(struct req *req, const void *p)\n", + Fh(tl, 0, "match_acl_%s_%s(const struct vrt_ctx *ctx, const void *p)\n", anon ? "anon" : "named", acln); Fh(tl, 0, "{\n"); Fh(tl, 0, "\tconst unsigned char *a;\n"); @@ -372,7 +372,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) Fh(tl, 0, "\telse if (fam == %d)\n", PF_INET6); Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in6, sin6_addr)); Fh(tl, 0, "\telse {\n"); - Fh(tl, 0, "\t\tVRT_acl_log(req, \"NO_FAM %s\");\n", acln); + Fh(tl, 0, "\t\tVRT_acl_log(ctx, \"NO_FAM %s\");\n", acln); Fh(tl, 0, "\t\treturn(0);\n"); Fh(tl, 0, "\t}\n\n"); depth = -1; @@ -424,7 +424,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) i = (ae->mask + 7) / 8; if (!anon) { - Fh(tl, 0, "\t%*sVRT_acl_log(req, \"%sMATCH %s \" ", + Fh(tl, 0, "\t%*sVRT_acl_log(ctx, \"%sMATCH %s \" ", -i, "", ae->not ? "NEG_" : "", acln); EncToken(tl->fh, ae->t_addr); if (ae->t_mask != NULL) @@ -441,7 +441,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) /* Deny by default */ if (!anon) - Fh(tl, 0, "\tVRT_acl_log(req, \"NO_MATCH %s\");\n", acln); + Fh(tl, 0, "\tVRT_acl_log(ctx, \"NO_MATCH %s\");\n", acln); Fh(tl, 0, "\treturn (0);\n}\n"); } @@ -457,7 +457,7 @@ vcc_Acl_Hack(struct vcc *tl, char *b) bprintf(acln, "%u", tl->unique++); vcc_acl_entry(tl); vcc_acl_emit(tl, acln, 1); - sprintf(b, "%smatch_acl_anon_%s(req, \v1)", + sprintf(b, "%smatch_acl_anon_%s(ctx, \v1)", (tcond == T_NEQ ? "!" : ""), acln); } diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 715a4c9..ab3175e 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -1012,7 +1012,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) vcc_NextToken(tl); ExpectErr(tl, ID); vcc_AddRef(tl, tl->t, SYM_ACL); - bprintf(buf, "%smatch_acl_named_%.*s(req, \v1)", + bprintf(buf, "%smatch_acl_named_%.*s(ctx, \v1)", not, PF(tl->t)); vcc_NextToken(tl); *e = vcc_expr_edit(BOOL, buf, *e, NULL); From phk at varnish-cache.org Tue Apr 30 10:25:07 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 12:25:07 +0200 Subject: [master] f492465 Replace the newly introduced "ws" argument to VCL/VRT, with the even newer vrt_ctx argument. Message-ID: commit f4924656a137ea5cfe14e8c0fdfb606f57844a05 Author: Poul-Henning Kamp Date: Tue Apr 30 10:24:27 2013 +0000 Replace the newly introduced "ws" argument to VCL/VRT, with the even newer vrt_ctx argument. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index d17d6aa..cb7f095 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -220,7 +220,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL, NULL); + (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -247,7 +247,7 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL, NULL); + (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -419,7 +419,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, wrk->cur_method = method; AN(vsl); VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); - (void)func(&ctx, wrk, req, bo, ws); + (void)func(&ctx, wrk, req, bo); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method = 0; WS_Reset(wrk->aws, aws); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 8d361b1..58b7df1 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -214,14 +214,15 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap) */ const char * -VRT_CollectString(struct ws *ws, const char *p, ...) +VRT_CollectString(const struct vrt_ctx *ctx, const char *p, ...) { va_list ap; char *b; - CHECK_OBJ_NOTNULL(ws, WS_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); va_start(ap, p); - b = VRT_String(ws, NULL, p, ap); + b = VRT_String(ctx->ws, NULL, p, ap); va_end(ap); return (b); } @@ -303,7 +304,7 @@ VRT_r_now() /*--------------------------------------------------------------------*/ char * -VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa) +VRT_IP_string(const struct vrt_ctx *ctx, const struct sockaddr_storage *sa) { char *p; const struct sockaddr_in *si4; @@ -311,7 +312,7 @@ VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa) const void *addr; int len; - CHECK_OBJ_NOTNULL(ws, WS_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); switch (sa->ss_family) { case AF_INET: len = INET_ADDRSTRLEN; @@ -327,44 +328,44 @@ VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa) INCOMPL(); } XXXAN(len); - AN(p = WS_Alloc(ws, len)); + AN(p = WS_Alloc(ctx->ws, len)); AN(inet_ntop(sa->ss_family, addr, p, len)); return (p); } char * -VRT_INT_string(struct ws *ws, long num) +VRT_INT_string(const struct vrt_ctx *ctx, long num) { char *p; int size; - CHECK_OBJ_NOTNULL(ws, WS_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); size = snprintf(NULL, 0, "%ld", num) + 1; - AN(p = WS_Alloc(ws, size)); + AN(p = WS_Alloc(ctx->ws, size)); assert(snprintf(p, size, "%ld", num) < size); return (p); } char * -VRT_REAL_string(struct ws *ws, double num) +VRT_REAL_string(const struct vrt_ctx *ctx, double num) { char *p; int size; - CHECK_OBJ_NOTNULL(ws, WS_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); size = snprintf(NULL, 0, "%.3f", num) + 1; - AN(p = WS_Alloc(ws, size)); + AN(p = WS_Alloc(ctx->ws, size)); assert(snprintf(p, size, "%.3f", num) < size); return (p); } char * -VRT_TIME_string(struct ws *ws, double t) +VRT_TIME_string(const struct vrt_ctx *ctx, double t) { char *p; - CHECK_OBJ_NOTNULL(ws, WS_MAGIC); - p = WS_Alloc(ws, VTIM_FORMAT_SIZE); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + p = WS_Alloc(ctx->ws, VTIM_FORMAT_SIZE); if (p != NULL) VTIM_format(t, p); return (p); diff --git a/include/vrt.h b/include/vrt.h index 2e230ad..031a9e1 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -251,11 +251,11 @@ int VRT_Stv(const char *nm); /* Convert things to string */ -char *VRT_IP_string(struct ws *, const struct sockaddr_storage *sa); -char *VRT_INT_string(struct ws *, long); -char *VRT_REAL_string(struct ws *, double); -char *VRT_TIME_string(struct ws *, double); +char *VRT_IP_string(const struct vrt_ctx *, const struct sockaddr_storage *sa); +char *VRT_INT_string(const struct vrt_ctx *, long); +char *VRT_REAL_string(const struct vrt_ctx *, double); +char *VRT_TIME_string(const struct vrt_ctx *, double); const char *VRT_BOOL_string(unsigned); const char *VRT_BACKEND_string(const struct director *d); -const char *VRT_CollectString(struct ws *, const char *p, ...); +const char *VRT_CollectString(const struct vrt_ctx *, const char *p, ...); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 140635b..6ef580b 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -774,8 +774,7 @@ struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *, - struct ws *); +typedef int vcl_func_f(const struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *); """) diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index d6dd786..4520b00 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -693,8 +693,9 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) for (i = 0; i < VCL_MET_MAX; i++) { Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); Fc(tl, 1, - "VGC_function_%s(struct vrt_ctx *ctx, struct worker *wrk," - " struct req *req, struct busyobj *bo, struct ws *ws)\n", + "VGC_function_%s(const struct vrt_ctx *ctx," + " struct worker *wrk," + " struct req *req, struct busyobj *bo)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index ab3175e..c318920 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -404,20 +404,20 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt) switch((*e)->fmt) { case BACKEND: p = "VRT_BACKEND_string(\v1)"; break; case BOOL: p = "VRT_BOOL_string(\v1)"; break; - case DURATION: p = "VRT_REAL_string(ws, \v1)"; break; + case DURATION: p = "VRT_REAL_string(ctx, \v1)"; break; /* XXX: should DURATION insist on "s" suffix ? */ case INT: if (vcc_isconst(*e)) { p = "\"\v1\""; constant = EXPR_CONST; } else { - p = "VRT_INT_string(ws, \v1)"; + p = "VRT_INT_string(ctx, \v1)"; } break; - case IP: p = "VRT_IP_string(ws, \v1)"; break; - case BYTES: p = "VRT_REAL_string(ws, \v1)"; break; /* XXX */ - case REAL: p = "VRT_REAL_string(ws, \v1)"; break; - case TIME: p = "VRT_TIME_string(ws, \v1)"; break; + case IP: p = "VRT_IP_string(ctx, \v1)"; break; + case BYTES: p = "VRT_REAL_string(ctx, \v1)"; break; /* XXX */ + case REAL: p = "VRT_REAL_string(ctx, \v1)"; break; + case TIME: p = "VRT_TIME_string(ctx, \v1)"; break; case HEADER: p = "VRT_GetHdr(ctx, \v1)"; break; case ENUM: case STRING: @@ -914,7 +914,7 @@ vcc_expr_strfold(struct vcc *tl, struct expr **e, enum var_type fmt) if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST) *e = vcc_expr_edit(STRING, - "\v+VRT_CollectString(ws,\n\v1,\nvrt_magic_string_end)\v-", + "\v+VRT_CollectString(ctx,\n\v1,\nvrt_magic_string_end)\v-", *e, NULL); if (fmt == STRING_LIST && (*e)->fmt == STRING) (*e)->fmt = STRING_LIST; From phk at varnish-cache.org Tue Apr 30 11:12:31 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 13:12:31 +0200 Subject: [master] af675ec Replace the newly added busyobj argument with vrt_ctx. Message-ID: commit af675ec65a47aa31da8abda5cf5e0cdaf32dafaa Author: Poul-Henning Kamp Date: Tue Apr 30 11:11:50 2013 +0000 Replace the newly added busyobj argument with vrt_ctx. This actually makes some of the macro-expansions in cache_vrt_var.c simpler and saner... diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index cb7f095..aa2aec7 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -220,7 +220,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) REPLACE(vcl->name, name); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL); + (void)vcl->conf->init_func(&ctx, NULL, NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; @@ -247,7 +247,7 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL); + (void)vcl->conf->fini_func(&ctx, NULL, NULL); vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); @@ -391,6 +391,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.vcl = req->vcl; ctx.http_req = req->http; ctx.http_resp = req->resp; + ctx.req = req; if (req->obj) ctx.http_obj = req->obj->http; } @@ -412,6 +413,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.vcl = bo->vcl; ctx.http_bereq = bo->bereq; ctx.http_beresp = bo->beresp; + ctx.bo = bo; } ctx.ws = ws; aws = WS_Snapshot(wrk->aws); @@ -419,7 +421,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, wrk->cur_method = method; AN(vsl); VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); - (void)func(&ctx, wrk, req, bo); + (void)func(&ctx, wrk, req); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method = 0; WS_Reset(wrk->aws, aws); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 58b7df1..b221f22 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -393,11 +393,12 @@ VRT_BOOL_string(unsigned val) */ void -VRT_l_beresp_saintmode(const struct busyobj *bo, double a) +VRT_l_beresp_saintmode(const struct vrt_ctx *ctx, double a) { + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (a > 0.) - VBE_AddTrouble(bo, a + VTIM_real()); + VBE_AddTrouble(ctx->bo, a + VTIM_real()); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 605f44f..6fe06e6 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -37,6 +37,7 @@ #include "common/heritage.h" #include "cache_backend.h" +#include "vrt.h" #include "vrt_obj.h" #include "vtcp.h" #include "vtim.h" @@ -61,86 +62,82 @@ vrt_do_string(const struct http *hp, int fld, va_end(ap); } -#define VRT_DO_HDR(obj, hdr, http, fld) \ -void \ -VRT_l_##obj##_##hdr(const struct CPAR *px, const char *p, ...) \ -{ \ - va_list ap; \ - \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ - va_start(ap, p); \ - vrt_do_string(http, fld, #obj "." #hdr, p, ap); \ - va_end(ap); \ -} \ - \ -const char * \ -VRT_r_##obj##_##hdr(const struct CPAR *px) \ -{ \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ - CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); \ - return (http->hd[fld].b); \ +#define VRT_DO_HDR(obj, hdr, fld) \ +void \ +VRT_l_##obj##_##hdr(const struct vrt_ctx *ctx, const char *p, ...) \ +{ \ + va_list ap; \ + \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + va_start(ap, p); \ + vrt_do_string(ctx->http_##obj, fld, #obj "." #hdr, p, ap); \ + va_end(ap); \ +} \ + \ +const char * \ +VRT_r_##obj##_##hdr(const struct vrt_ctx *ctx) \ +{ \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \ + return (ctx->http_##obj->hd[fld].b); \ } -#define VRT_DO_STATUS(obj, http) \ -void \ -VRT_l_##obj##_status(const struct CPAR *px, long num) \ -{ \ - \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ - assert(num >= 100 && num <= 999); \ - http->status = (uint16_t)num; \ -} \ - \ -long \ -VRT_r_##obj##_status(const struct CPAR *px) \ -{ \ - \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ - return(http->status); \ -} - -#define CPAR req -#define CMAGIC REQ_MAGIC -VRT_DO_HDR(req, method, px->http, HTTP_HDR_METHOD) -VRT_DO_HDR(req, request, px->http, HTTP_HDR_METHOD) -VRT_DO_HDR(req, url, px->http, HTTP_HDR_URL) -VRT_DO_HDR(req, proto, px->http, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, proto, px->obj->http, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, response, px->obj->http, HTTP_HDR_RESPONSE) -VRT_DO_STATUS(obj, px->obj->http) -VRT_DO_HDR(resp, proto, px->resp, HTTP_HDR_PROTO) -VRT_DO_HDR(resp, response, px->resp, HTTP_HDR_RESPONSE) -VRT_DO_STATUS(resp, px->resp) -#undef CPAR -#undef CMAGIC - -#define CPAR busyobj -#define CMAGIC BUSYOBJ_MAGIC -VRT_DO_HDR(bereq, method, px->bereq, HTTP_HDR_METHOD) -VRT_DO_HDR(bereq, request, px->bereq, HTTP_HDR_METHOD) -VRT_DO_HDR(bereq, url, px->bereq, HTTP_HDR_URL) -VRT_DO_HDR(bereq, proto, px->bereq, HTTP_HDR_PROTO) -VRT_DO_HDR(beresp, proto, px->beresp, HTTP_HDR_PROTO) -VRT_DO_HDR(beresp, response, px->beresp, HTTP_HDR_RESPONSE) -VRT_DO_STATUS(beresp, px->beresp) -#undef CPAR -#undef CMAGIC +#define VRT_DO_STATUS(obj) \ +void \ +VRT_l_##obj##_status(const struct vrt_ctx *ctx, long num) \ +{ \ + \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \ + assert(num >= 100 && num <= 999); \ + ctx->http_##obj->status = (uint16_t)num; \ +} \ + \ +long \ +VRT_r_##obj##_status(const struct vrt_ctx *ctx) \ +{ \ + \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \ + return(ctx->http_##obj->status); \ +} + +VRT_DO_HDR(req, method, HTTP_HDR_METHOD) +VRT_DO_HDR(req, request, HTTP_HDR_METHOD) +VRT_DO_HDR(req, url, HTTP_HDR_URL) +VRT_DO_HDR(req, proto, HTTP_HDR_PROTO) +VRT_DO_HDR(obj, proto, HTTP_HDR_PROTO) +VRT_DO_HDR(obj, response, HTTP_HDR_RESPONSE) +VRT_DO_STATUS(obj) +VRT_DO_HDR(resp, proto, HTTP_HDR_PROTO) +VRT_DO_HDR(resp, response, HTTP_HDR_RESPONSE) +VRT_DO_STATUS(resp) + +VRT_DO_HDR(bereq, method, HTTP_HDR_METHOD) +VRT_DO_HDR(bereq, request, HTTP_HDR_METHOD) +VRT_DO_HDR(bereq, url, HTTP_HDR_URL) +VRT_DO_HDR(bereq, proto, HTTP_HDR_PROTO) +VRT_DO_HDR(beresp, proto, HTTP_HDR_PROTO) +VRT_DO_HDR(beresp, response, HTTP_HDR_RESPONSE) +VRT_DO_STATUS(beresp) /*--------------------------------------------------------------------*/ #define VBERESP(dir, type, onm, field) \ void \ -VRT_l_##dir##_##onm(struct busyobj *bo, type a) \ +VRT_l_##dir##_##onm(const struct vrt_ctx *ctx, type a) \ { \ - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ - bo->field = a; \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + ctx->bo->field = a; \ } \ \ type \ -VRT_r_##dir##_##onm(const struct busyobj *bo) \ +VRT_r_##dir##_##onm(const struct vrt_ctx *ctx) \ { \ - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ - return (bo->field); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + return (ctx->bo->field); \ } VBERESP(beresp, unsigned, do_esi, do_esi) @@ -179,19 +176,21 @@ VRT_l_client_identity(struct req *req, const char *str, ...) #define BEREQ_TIMEOUT(which) \ void \ -VRT_l_bereq_##which(struct busyobj *bo, double num) \ +VRT_l_bereq_##which(const struct vrt_ctx *ctx, double num) \ { \ \ - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ - bo->which = (num > 0.0 ? num : 0.0); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + ctx->bo->which = (num > 0.0 ? num : 0.0); \ } \ \ double \ -VRT_r_bereq_##which(const struct busyobj *bo) \ +VRT_r_bereq_##which(const struct vrt_ctx *ctx) \ { \ \ - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); \ - return (bo->which); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + return (ctx->bo->which); \ } BEREQ_TIMEOUT(connect_timeout) @@ -201,53 +200,58 @@ BEREQ_TIMEOUT(between_bytes_timeout) /*--------------------------------------------------------------------*/ const char * -VRT_r_beresp_backend_name(const struct busyobj *bo) +VRT_r_beresp_backend_name(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); - return(bo->vbc->backend->vcl_name); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC); + return(ctx->bo->vbc->backend->vcl_name); } struct sockaddr_storage * -VRT_r_beresp_backend_ip(const struct busyobj *bo) +VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); - return(bo->vbc->addr); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC); + return(ctx->bo->vbc->addr); } long -VRT_r_beresp_backend_port(const struct busyobj *bo) +VRT_r_beresp_backend_port(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); - return (VTCP_port(bo->vbc->addr)); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC); + return (VTCP_port(ctx->bo->vbc->addr)); } const char * -VRT_r_beresp_storage(const struct busyobj *bo) +VRT_r_beresp_storage(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - if (bo->storage_hint != NULL) - return (bo->storage_hint); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + if (ctx->bo->storage_hint != NULL) + return (ctx->bo->storage_hint); else return (NULL); } void -VRT_l_beresp_storage(struct busyobj *bo, const char *str, ...) +VRT_l_beresp_storage(const struct vrt_ctx *ctx, const char *str, ...) { va_list ap; char *b; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); va_start(ap, str); - b = VRT_String(bo->ws, NULL, str, ap); + b = VRT_String(ctx->bo->ws, NULL, str, ap); // XXX: ctx->ws ? va_end(ap); - bo->storage_hint = b; + ctx->bo->storage_hint = b; } /*--------------------------------------------------------------------*/ @@ -285,30 +289,33 @@ VRT_r_req_backend_healthy(const struct req *req) /*--------------------------------------------------------------------*/ void -VRT_l_bereq_backend(struct busyobj *bo, struct director *be) +VRT_l_bereq_backend(const struct vrt_ctx *ctx, struct director *be) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(bo->director); - bo->director = be; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + AN(ctx->bo->director); + ctx->bo->director = be; } struct director * -VRT_r_bereq_backend(const struct busyobj *bo) +VRT_r_bereq_backend(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(bo->director); - return (bo->director); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + AN(ctx->bo->director); + return (ctx->bo->director); } unsigned -VRT_r_bereq_backend_healthy(const struct busyobj *bo) +VRT_r_bereq_backend_healthy(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->director, DIRECTOR_MAGIC); - return (VDI_Healthy(bo->director, bo->digest)); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->director, DIRECTOR_MAGIC); + return (VDI_Healthy(ctx->bo->director, ctx->bo->digest)); } /*--------------------------------------------------------------------*/ @@ -369,10 +376,10 @@ VRT_r_req_restarts(const struct req *req) #define VRT_DO_EXP(which, exp, fld, offset, extra) \ \ void \ -VRT_l_##which##_##fld(struct CPAR *px, double a) \ +VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \ { \ \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ if (a > 0.) \ a += offset; \ EXP_Set_##fld(&exp, a); \ @@ -380,10 +387,10 @@ VRT_l_##which##_##fld(struct CPAR *px, double a) \ } \ \ double \ -VRT_r_##which##_##fld(const struct CPAR *px) \ +VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \ { \ \ - CHECK_OBJ_NOTNULL(px, CMAGIC); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ return(EXP_Get_##fld(&exp) - offset); \ } @@ -397,38 +404,33 @@ vrt_wsp_exp(struct vsl_log *vsl, unsigned xid, double now, const struct exp *e) xid, e->ttl - dt, e->grace, e->keep, now, e->age + dt); } -#define CPAR req -#define CMAGIC REQ_MAGIC -VRT_DO_EXP(req, px->exp, ttl, 0, ) -VRT_DO_EXP(req, px->exp, grace, 0, ) -VRT_DO_EXP(req, px->exp, keep, 0, ) - -VRT_DO_EXP(obj, px->obj->exp, grace, 0, - EXP_Rearm(px->obj); - vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) -VRT_DO_EXP(obj, px->obj->exp, ttl, - (px->t_req - px->obj->exp.entered), - EXP_Rearm(px->obj); - vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) -VRT_DO_EXP(obj, px->obj->exp, keep, 0, - EXP_Rearm(px->obj); - vrt_wsp_exp(px->vsl, px->obj->vxid, px->t_req, &px->obj->exp);) -#undef CPAR -#undef CMAGIC - -#define CPAR busyobj -#define CMAGIC BUSYOBJ_MAGIC -VRT_DO_EXP(beresp, px->exp, grace, 0, - vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, - px->exp.entered, &px->exp);) -VRT_DO_EXP(beresp, px->exp, ttl, 0, - vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, - px->exp.entered, &px->exp);) -VRT_DO_EXP(beresp, px->exp, keep, 0, - vrt_wsp_exp(px->vsl, px->vsl->wid & VSL_IDENTMASK, - px->exp.entered, &px->exp);) -#undef CPAR -#undef CMAGIC +VRT_DO_EXP(req, ctx->req->exp, ttl, 0, ) +VRT_DO_EXP(req, ctx->req->exp, grace, 0, ) +VRT_DO_EXP(req, ctx->req->exp, keep, 0, ) + +VRT_DO_EXP(obj, ctx->req->obj->exp, grace, 0, + EXP_Rearm(ctx->req->obj); + vrt_wsp_exp(ctx->vsl, ctx->req->obj->vxid, + ctx->req->t_req, &ctx->req->obj->exp);) +VRT_DO_EXP(obj, ctx->req->obj->exp, ttl, + (ctx->req->t_req - ctx->req->obj->exp.entered), + EXP_Rearm(ctx->req->obj); + vrt_wsp_exp(ctx->vsl, ctx->req->obj->vxid, + ctx->req->t_req, &ctx->req->obj->exp);) +VRT_DO_EXP(obj, ctx->req->obj->exp, keep, 0, + EXP_Rearm(ctx->req->obj); + vrt_wsp_exp(ctx->vsl, ctx->req->obj->vxid, + ctx->req->t_req, &ctx->req->obj->exp);) + +VRT_DO_EXP(beresp, ctx->bo->exp, grace, 0, + vrt_wsp_exp(ctx->vsl, ctx->vsl->wid & VSL_IDENTMASK, + ctx->bo->exp.entered, &ctx->bo->exp);) +VRT_DO_EXP(beresp, ctx->bo->exp, ttl, 0, + vrt_wsp_exp(ctx->vsl, ctx->vsl->wid & VSL_IDENTMASK, + ctx->bo->exp.entered, &ctx->bo->exp);) +VRT_DO_EXP(beresp, ctx->bo->exp, keep, 0, + vrt_wsp_exp(ctx->vsl, ctx->vsl->wid & VSL_IDENTMASK, + ctx->bo->exp.entered, &ctx->bo->exp);) /*-------------------------------------------------------------------- * req.xid diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 6ef580b..d4b53fd 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -141,25 +141,25 @@ sp_variables = ( 'STRING', ( 'client',), ( 'client',), - 'cR' + 'C' ), ('req.request', 'STRING', ( 'client',), ( 'client',), - 'cR' + 'C' ), ('req.url', 'STRING', ( 'client',), ( 'client',), - 'cR' + 'C' ), ('req.proto', 'STRING', ( 'client',), ( 'client',), - 'cR' + 'C' ), ('req.http.', 'HEADER', @@ -183,19 +183,19 @@ sp_variables = ( 'DURATION', ( 'client',), ( 'client',), - 'R' + 'C' ), ('req.grace', 'DURATION', ( 'client',), ( 'client',), - 'R' + 'C' ), ('req.keep', 'DURATION', ( 'client',), ( 'client',), - 'R' + 'C' ), ('req.xid', 'STRING', @@ -243,37 +243,37 @@ sp_variables = ( 'BACKEND', ( 'backend', ), ( 'backend', ), - 'B' + 'C' ), ('bereq.backend.healthy', 'BOOL', ( 'backend', ), ( ), - 'B' + 'C' ), ('bereq.method', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cB' + 'C' ), ('bereq.request', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cB' + 'C' ), ('bereq.url', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cB' + 'C' ), ('bereq.proto', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'cB' + 'C' ), ('bereq.http.', 'HEADER', @@ -285,43 +285,43 @@ sp_variables = ( 'DURATION', ( 'pipe', 'backend_fetch', 'pass', 'miss',), ( 'pipe', 'backend_fetch', 'pass', 'miss',), - 'B' + 'C' ), ('bereq.first_byte_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'B' + 'C' ), ('bereq.between_bytes_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'B' + 'C' ), ('beresp.proto', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'cB' + 'C' ), ('beresp.saintmode', 'DURATION', ( ), ( 'backend_response',), - 'cB' + 'C' ), ('beresp.status', 'INT', ( 'backend_response',), ( 'backend_response',), - 'cB' + 'C' ), ('beresp.response', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'cB' + 'C' ), ('beresp.http.', 'HEADER', @@ -333,97 +333,97 @@ sp_variables = ( 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.do_stream', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.do_gzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.do_gunzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.do_pass', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.uncacheable', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.ttl', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.grace', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.keep', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('beresp.backend.name', 'STRING', ( 'backend_response',), ( ), - 'cB' + 'C' ), ('beresp.backend.ip', 'IP', ( 'backend_response',), ( ), - 'cB' + 'C' ), ('beresp.backend.port', 'INT', ( 'backend_response',), ( ), - 'cB' + 'C' ), ('beresp.storage', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'B' + 'C' ), ('obj.proto', 'STRING', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'cR' + 'C' ), ('obj.status', 'INT', ( 'error',), ( 'error',), - 'cR' + 'C' ), ('obj.response', 'STRING', ( 'error',), ( 'error',), - 'cR' + 'C' ), ('obj.hits', 'INT', @@ -441,19 +441,19 @@ sp_variables = ( 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'R' + 'C' ), ('obj.grace', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'R' + 'C' ), ('obj.keep', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'R' + 'C' ), ('obj.lastuse', 'DURATION', @@ -471,19 +471,19 @@ sp_variables = ( 'STRING', ( 'deliver',), ( 'deliver',), - 'cR' + 'C' ), ('resp.status', 'INT', ( 'deliver',), ( 'deliver',), - 'cR' + 'C' ), ('resp.response', 'STRING', ( 'deliver',), ( 'deliver',), - 'cR' + 'C' ), ('resp.http.', 'HEADER', @@ -774,7 +774,7 @@ struct worker; typedef int vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); -typedef int vcl_func_f(const struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *); +typedef int vcl_func_f(const struct vrt_ctx *ctx, struct worker *, struct req *); """) @@ -885,15 +885,11 @@ def mk_proto(c, r=False): elif i == "c": pass elif i == "C": - s += "const struct vrt_ctx *" + s += " const struct vrt_ctx *" elif i == "R": if r: s += " const" s += " struct req *" - elif i == "B": - if r: - s += " const" - s += " struct busyobj *" else: print("Unknown args-spec char '%s'" % i) exit(1) @@ -909,8 +905,8 @@ def mk_args(c, r=False): continue; elif i == "R": s += "req" - elif i == "B": - s += "bo" + elif i == "C": + s += "ctx" else: print("Unknown args-spec char '%s'" % i) exit(1) From phk at varnish-cache.org Tue Apr 30 11:46:21 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 30 Apr 2013 13:46:21 +0200 Subject: [master] 4478944 Make all the VCL variables controlled by generate.py use vrt_ctx. Message-ID: commit 4478944be97c7374707b475346b76584623ebcba Author: Poul-Henning Kamp Date: Tue Apr 30 11:46:02 2013 +0000 Make all the VCL variables controlled by generate.py use vrt_ctx. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index b221f22..0d9af43 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -295,9 +295,10 @@ VRT_hashdata(struct req *req, const char *str, ...) /*--------------------------------------------------------------------*/ double -VRT_r_now() +VRT_r_now(const struct vrt_ctx *ctx) { + (void)ctx; return (VTIM_real()); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 6fe06e6..6b79f9c 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -150,26 +150,30 @@ VBERESP(beresp, unsigned, uncacheable, do_pass) /*--------------------------------------------------------------------*/ const char * -VRT_r_client_identity(const struct req *req) +VRT_r_client_identity(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->client_identity != NULL) - return (req->client_identity); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + if (ctx->req->client_identity != NULL) + return (ctx->req->client_identity); else - return (req->sp->addr); + return (ctx->req->sp->addr); } void -VRT_l_client_identity(struct req *req, const char *str, ...) +VRT_l_client_identity(const struct vrt_ctx *ctx, const char *str, ...) { va_list ap; char *b; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); va_start(ap, str); - b = VRT_String(req->http->ws, NULL, str, ap); + // XXX ? + b = VRT_String(ctx->req->http->ws, NULL, str, ap); va_end(ap); - req->client_identity = b; + ctx->req->client_identity = b; } /*--------------------------------------------------------------------*/ @@ -257,33 +261,37 @@ VRT_l_beresp_storage(const struct vrt_ctx *ctx, const char *str, ...) /*--------------------------------------------------------------------*/ void -VRT_l_req_backend(struct req *req, struct director *be) +VRT_l_req_backend(const struct vrt_ctx *ctx, struct director *be) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - req->director = be; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + ctx->req->director = be; } struct director * -VRT_r_req_backend(const struct req *req) +VRT_r_req_backend(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return (req->director); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return (ctx->req->director); } unsigned -VRT_r_req_backend_healthy(const struct req *req) +VRT_r_req_backend_healthy(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); /* * XXX: Not optimal, but we do not have a backend in vcl_deliver * XXX: and we have to return something. */ - if (req->director == NULL) + if (ctx->req->director == NULL) return (0); - CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC); - return (VDI_Healthy(req->director, req->digest)); + CHECK_OBJ_NOTNULL(ctx->req->director, DIRECTOR_MAGIC); + return (VDI_Healthy(ctx->req->director, ctx->req->digest)); } /*--------------------------------------------------------------------*/ @@ -321,51 +329,58 @@ VRT_r_bereq_backend_healthy(const struct vrt_ctx *ctx) /*--------------------------------------------------------------------*/ void -VRT_l_req_esi(struct req *req, unsigned process_esi) +VRT_l_req_esi(const struct vrt_ctx *ctx, unsigned process_esi) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); /* * Only allow you to turn of esi in the main request * else everything gets confused */ - if(req->esi_level == 0) - req->disable_esi = !process_esi; + if(ctx->req->esi_level == 0) + ctx->req->disable_esi = !process_esi; } unsigned -VRT_r_req_esi(const struct req *req) +VRT_r_req_esi(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return (!req->disable_esi); + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return (!ctx->req->disable_esi); } long -VRT_r_req_esi_level(const struct req *req) +VRT_r_req_esi_level(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return(req->esi_level); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return(ctx->req->esi_level); } /*--------------------------------------------------------------------*/ unsigned -VRT_r_req_can_gzip(const struct req *req) +VRT_r_req_can_gzip(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return (RFC2616_Req_Gzip(req->http)); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return (RFC2616_Req_Gzip(ctx->req->http)); // XXX ? } /*--------------------------------------------------------------------*/ long -VRT_r_req_restarts(const struct req *req) +VRT_r_req_restarts(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return (req->restarts); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return (ctx->req->restarts); } /*-------------------------------------------------------------------- @@ -437,15 +452,17 @@ VRT_DO_EXP(beresp, ctx->bo->exp, keep, 0, */ const char * -VRT_r_req_xid(const struct req *req) +VRT_r_req_xid(const struct vrt_ctx *ctx) { char *p; int size; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - size = snprintf(NULL, 0, "%u", req->vsl->wid & VSL_IDENTMASK) + 1; - AN(p = WS_Alloc(req->http->ws, size)); - assert(snprintf(p, size, "%u", req->vsl->wid & VSL_IDENTMASK) < size); + // XXX ? + size = snprintf(NULL, 0, "%u", ctx->req->vsl->wid & VSL_IDENTMASK) + 1; + AN(p = WS_Alloc(ctx->req->http->ws, size)); + assert(snprintf(p, size, "%u", ctx->req->vsl->wid & VSL_IDENTMASK) < size); return (p); } @@ -453,19 +470,21 @@ VRT_r_req_xid(const struct req *req) #define REQ_BOOL(hash_var) \ void \ -VRT_l_req_##hash_var(struct req *req, unsigned val) \ +VRT_l_req_##hash_var(const struct vrt_ctx *ctx, unsigned val) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - req->hash_var = val ? 1 : 0; \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ + ctx->req->hash_var = val ? 1 : 0; \ } \ \ unsigned \ -VRT_r_req_##hash_var(const struct req *req) \ +VRT_r_req_##hash_var(const struct vrt_ctx *ctx) \ { \ \ - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); \ - return(req->hash_var); \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \ + return(ctx->req->hash_var); \ } REQ_BOOL(hash_ignore_busy) @@ -474,33 +493,36 @@ REQ_BOOL(hash_always_miss) /*--------------------------------------------------------------------*/ struct sockaddr_storage * -VRT_r_client_ip(const struct req *req) +VRT_r_client_ip(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - return (&req->sp->sockaddr); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + return (&ctx->req->sp->sockaddr); } struct sockaddr_storage * -VRT_r_server_ip(const struct req *req) +VRT_r_server_ip(const struct vrt_ctx *ctx) { int i; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->sp->mysockaddr.ss_family == AF_UNSPEC) { - i = getsockname(req->sp->fd, - (void*)&req->sp->mysockaddr, &req->sp->mysockaddrlen); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + if (ctx->req->sp->mysockaddr.ss_family == AF_UNSPEC) { + i = getsockname(ctx->req->sp->fd, + (void*)&ctx->req->sp->mysockaddr, + &ctx->req->sp->mysockaddrlen); assert(VTCP_Check(i)); } - return (&req->sp->mysockaddr); + return (&ctx->req->sp->mysockaddr); } const char* -VRT_r_server_identity(const struct req *req) +VRT_r_server_identity(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (heritage.identity[0] != '\0') return (heritage.identity); else @@ -508,10 +530,10 @@ VRT_r_server_identity(const struct req *req) } const char* -VRT_r_server_hostname(const struct req *req) +VRT_r_server_hostname(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (vrt_hostname[0] == '\0') AZ(gethostname(vrt_hostname, sizeof(vrt_hostname))); return (vrt_hostname); @@ -522,43 +544,49 @@ VRT_r_server_hostname(const struct req *req) */ long -VRT_r_server_port(const struct req *req) +VRT_r_server_port(const struct vrt_ctx *ctx) { int i; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->sp->mysockaddr.ss_family == AF_UNSPEC) { - i = getsockname(req->sp->fd, - (void*)&req->sp->mysockaddr, &req->sp->mysockaddrlen); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + if (ctx->req->sp->mysockaddr.ss_family == AF_UNSPEC) { + i = getsockname(ctx->req->sp->fd, + (void*)&ctx->req->sp->mysockaddr, + &ctx->req->sp->mysockaddrlen); assert(VTCP_Check(i)); } - return (VTCP_port(&req->sp->mysockaddr)); + return (VTCP_port(&ctx->req->sp->mysockaddr)); } /*--------------------------------------------------------------------*/ long -VRT_r_obj_hits(const struct req *req) +VRT_r_obj_hits(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); /* XXX */ - return (req->obj->hits); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); /* XXX */ + return (ctx->req->obj->hits); } double -VRT_r_obj_lastuse(const struct req *req) +VRT_r_obj_lastuse(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); /* XXX */ - return (VTIM_real() - req->obj->last_use); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); /* XXX */ + return (VTIM_real() - ctx->req->obj->last_use); } unsigned -VRT_r_obj_uncacheable(const struct req *req) +VRT_r_obj_uncacheable(const struct vrt_ctx *ctx) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - return (req->obj->objcore->flags & OC_F_PASS ? 1 : 0); + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); + return (ctx->req->obj->objcore->flags & OC_F_PASS ? 1 : 0); } diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index d4b53fd..254a3cc 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -105,397 +105,331 @@ sp_variables = ( 'IP', ( 'both',), ( ), - 'R' ), ('client.identity', 'STRING', ( 'both',), ( 'both',), - 'R' ), ('server.ip', 'IP', ( 'client',), ( ), - 'R' ), ('server.hostname', 'STRING', ( 'client',), ( ), - 'R' ), ('server.identity', 'STRING', ( 'client',), ( ), - 'R' ), ('server.port', 'INT', ( 'client',), ( ), - 'R' ), ('req.method', 'STRING', ( 'client',), ( 'client',), - 'C' ), ('req.request', 'STRING', ( 'client',), ( 'client',), - 'C' ), ('req.url', 'STRING', ( 'client',), ( 'client',), - 'C' ), ('req.proto', 'STRING', ( 'client',), ( 'client',), - 'C' ), ('req.http.', 'HEADER', ( 'client',), ( 'client',), - 'C' ), ('req.restarts', 'INT', ( 'client',), ( ), - 'cR' ), ('req.esi_level', 'INT', ( 'client',), ( ), - 'cR' ), ('req.ttl', 'DURATION', ( 'client',), ( 'client',), - 'C' ), ('req.grace', 'DURATION', ( 'client',), ( 'client',), - 'C' ), ('req.keep', 'DURATION', ( 'client',), ( 'client',), - 'C' ), ('req.xid', 'STRING', ( 'client',), ( ), - 'R' ), ('req.esi', 'BOOL', ( 'recv', 'backend_response', 'deliver', 'error',), ( 'recv', 'backend_response', 'deliver', 'error',), - 'R' ), ('req.can_gzip', 'BOOL', ( 'client',), ( ), - 'R' ), ('req.backend', 'BACKEND', ( 'client',), ( 'client',), - 'R' ), ('req.backend.healthy', 'BOOL', ( 'client',), ( ), - 'R' ), ('req.hash_ignore_busy', 'BOOL', ( 'recv',), ( 'recv',), - 'R' ), ('req.hash_always_miss', 'BOOL', ( 'recv',), ( 'recv',), - 'R' ), ('bereq.backend', 'BACKEND', ( 'backend', ), ( 'backend', ), - 'C' ), ('bereq.backend.healthy', 'BOOL', ( 'backend', ), ( ), - 'C' ), ('bereq.method', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'C' ), ('bereq.request', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'C' ), ('bereq.url', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'C' ), ('bereq.proto', 'STRING', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'C' ), ('bereq.http.', 'HEADER', ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), - 'C' ), ('bereq.connect_timeout', 'DURATION', ( 'pipe', 'backend_fetch', 'pass', 'miss',), ( 'pipe', 'backend_fetch', 'pass', 'miss',), - 'C' ), ('bereq.first_byte_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'C' ), ('bereq.between_bytes_timeout', 'DURATION', ( 'backend_fetch', 'pass', 'miss',), ( 'backend_fetch', 'pass', 'miss',), - 'C' ), ('beresp.proto', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.saintmode', 'DURATION', ( ), ( 'backend_response',), - 'C' ), ('beresp.status', 'INT', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.response', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.http.', 'HEADER', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.do_esi', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.do_stream', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.do_gzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.do_gunzip', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.do_pass', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.uncacheable', 'BOOL', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.ttl', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.grace', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.keep', 'DURATION', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('beresp.backend.name', 'STRING', ( 'backend_response',), ( ), - 'C' ), ('beresp.backend.ip', 'IP', ( 'backend_response',), ( ), - 'C' ), ('beresp.backend.port', 'INT', ( 'backend_response',), ( ), - 'C' ), ('beresp.storage', 'STRING', ( 'backend_response',), ( 'backend_response',), - 'C' ), ('obj.proto', 'STRING', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'C' ), ('obj.status', 'INT', ( 'error',), ( 'error',), - 'C' ), ('obj.response', 'STRING', ( 'error',), ( 'error',), - 'C' ), ('obj.hits', 'INT', ( 'lookup', 'deliver',), ( ), - 'cR' ), ('obj.http.', 'HEADER', ( 'lookup', 'error',), ( 'error',), # XXX ? - 'C' ), ('obj.ttl', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'C' ), ('obj.grace', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'C' ), ('obj.keep', 'DURATION', ( 'lookup', 'error',), ( 'lookup', 'error',), - 'C' ), ('obj.lastuse', 'DURATION', ( 'lookup', 'deliver', 'error',), ( ), - 'cR' ), ('obj.uncacheable', 'BOOL', ( 'lookup', 'deliver', 'error',), ( ), - 'cR' ), ('resp.proto', 'STRING', ( 'deliver',), ( 'deliver',), - 'C' ), ('resp.status', 'INT', ( 'deliver',), ( 'deliver',), - 'C' ), ('resp.response', 'STRING', ( 'deliver',), ( 'deliver',), - 'C' ), ('resp.http.', 'HEADER', ( 'deliver',), ( 'deliver',), - 'C' ), ('now', 'TIME', ( 'all',), ( ), - '' ), ) @@ -875,45 +809,6 @@ fo.write(""" const struct var vcc_vars[] = { """) -def mk_proto(c, r=False): - if c == "": - return "void" - s = "" - for i in c: - if i == "c" and not r: - s += " const" - elif i == "c": - pass - elif i == "C": - s += " const struct vrt_ctx *" - elif i == "R": - if r: - s += " const" - s += " struct req *" - else: - print("Unknown args-spec char '%s'" % i) - exit(1) - return s[1:] - - -def mk_args(c, r=False): - if c == "": - return "" - s = "" - for i in c: - if i == "c": - continue; - elif i == "R": - s += "req" - elif i == "C": - s += "ctx" - else: - print("Unknown args-spec char '%s'" % i) - exit(1) - if s != "" and not r: - s += "," - return s - for i in sp_variables: typ = i[1] cnam = i[0].replace(".", "_") @@ -928,10 +823,8 @@ for i in sp_variables: fo.write(i[0].split(".")[0].upper()) fo.write('",\n') else: - fo.write('\t "VRT_r_%s(%s)",\n' % - (cnam, mk_args(i[4], True))) - fh.write(ctyp + " VRT_r_%s(%s);\n" % - (cnam, mk_proto(i[4], True))) + fo.write('\t "VRT_r_%s(ctx)",\n' % cnam) + fh.write(ctyp + " VRT_r_%s(const struct vrt_ctx *);\n" % cnam ) restrict(fo, i[2]) if len(i[3]) == 0: @@ -941,9 +834,8 @@ for i in sp_variables: fo.write(i[0].split(".")[0].upper()) fo.write('",\n') else: - fo.write('\t "VRT_l_%s(%s",\n' % - (cnam, mk_args(i[4], False))) - fh.write("void VRT_l_%s(%s, " % (cnam, mk_proto(i[4], False))) + fo.write('\t "VRT_l_%s(ctx, ",\n' % cnam) + fh.write("void VRT_l_%s(const struct vrt_ctx *, " % cnam) if typ != "STRING": fh.write(ctyp + ");\n") else: diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 4520b00..bf992e2 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -695,7 +695,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) Fc(tl, 1, "VGC_function_%s(const struct vrt_ctx *ctx," " struct worker *wrk," - " struct req *req, struct busyobj *bo)\n", + " struct req *req)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n");