Skip to content

Commit eb9160c

Browse files
committed
merge vcl_trace
2 parents 8b2cc70 + 3a91164 commit eb9160c

25 files changed

+367
-99
lines changed

bin/varnishd/cache/cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ struct worker {
244244

245245
unsigned cur_method;
246246
unsigned seen_methods;
247-
unsigned handling;
247+
248+
struct wrk_vpi *vpi;
248249
};
249250

250251
/* Stored object -----------------------------------------------------

bin/varnishd/cache/cache_fetch.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "storage/storage.h"
3939
#include "vcl.h"
4040
#include "vtim.h"
41+
#include "vcc_interface.h"
4142

4243
#define FETCH_STEPS \
4344
FETCH_STEP(mkbereq, MKBEREQ) \
@@ -407,10 +408,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
407408

408409
VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, NULL);
409410

410-
if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL)
411+
if (wrk->vpi->handling == VCL_RET_ABANDON ||
412+
wrk->vpi->handling == VCL_RET_FAIL)
411413
return (F_STP_FAIL);
412414

413-
assert (wrk->handling == VCL_RET_FETCH || wrk->handling == VCL_RET_ERROR);
415+
assert (wrk->vpi->handling == VCL_RET_FETCH ||
416+
wrk->vpi->handling == VCL_RET_ERROR);
414417

415418
HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod);
416419

@@ -423,7 +426,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
423426
bo->vfc->resp = bo->beresp;
424427
bo->vfc->req = bo->bereq;
425428

426-
if (wrk->handling == VCL_RET_ERROR)
429+
if (wrk->vpi->handling == VCL_RET_ERROR)
427430
return (F_STP_ERROR);
428431

429432
VSLb_ts_busyobj(bo, "Fetch", W_TIM_real(wrk));
@@ -500,24 +503,25 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
500503
return (F_STP_ERROR);
501504
}
502505

503-
if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL ||
504-
wrk->handling == VCL_RET_ERROR) {
506+
if (wrk->vpi->handling == VCL_RET_ABANDON ||
507+
wrk->vpi->handling == VCL_RET_FAIL ||
508+
wrk->vpi->handling == VCL_RET_ERROR) {
505509
/* do not count deliberately ending the backend connection as
506510
* fetch failure
507511
*/
508-
handling = wrk->handling;
512+
handling = wrk->vpi->handling;
509513
if (bo->htc)
510514
bo->htc->doclose = SC_RESP_CLOSE;
511515
vbf_cleanup(bo);
512-
wrk->handling = handling;
516+
wrk->vpi->handling = handling;
513517

514-
if (wrk->handling == VCL_RET_ERROR)
518+
if (wrk->vpi->handling == VCL_RET_ERROR)
515519
return (F_STP_ERROR);
516520
else
517521
return (F_STP_FAIL);
518522
}
519523

520-
if (wrk->handling == VCL_RET_RETRY) {
524+
if (wrk->vpi->handling == VCL_RET_RETRY) {
521525
if (bo->htc && bo->htc->body_status != BS_NONE)
522526
bo->htc->doclose = SC_RESP_CLOSE;
523527
vbf_cleanup(bo);
@@ -540,15 +544,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
540544

541545
if (bo->do_esi)
542546
bo->do_stream = 0;
543-
if (wrk->handling == VCL_RET_PASS) {
547+
if (wrk->vpi->handling == VCL_RET_PASS) {
544548
oc->flags |= OC_F_HFP;
545549
bo->uncacheable = 1;
546-
wrk->handling = VCL_RET_DELIVER;
550+
wrk->vpi->handling = VCL_RET_DELIVER;
547551
}
548552
if (bo->uncacheable)
549553
oc->flags |= OC_F_HFM;
550554

551-
assert(wrk->handling == VCL_RET_DELIVER);
555+
assert(wrk->vpi->handling == VCL_RET_DELIVER);
552556

553557
return (bo->was_304 ? F_STP_CONDFETCH : F_STP_FETCH);
554558
}
@@ -638,7 +642,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
638642
oc = bo->fetch_objcore;
639643
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
640644

641-
assert(wrk->handling == VCL_RET_DELIVER);
645+
assert(wrk->vpi->handling == VCL_RET_DELIVER);
642646

643647
if (bo->htc == NULL) {
644648
(void)VFP_Error(bo->vfc, "No backend connection (rollback?)");
@@ -887,7 +891,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
887891
AN(oc->flags & OC_F_BUSY);
888892
assert(bo->director_state == DIR_S_NULL);
889893

890-
if (wrk->handling != VCL_RET_ERROR)
894+
if (wrk->vpi->handling != VCL_RET_ERROR)
891895
wrk->stats->fetch_failed++;
892896

893897
now = W_TIM_real(wrk);
@@ -941,20 +945,20 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
941945

942946
AZ(VSB_finish(synth_body));
943947

944-
if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) {
948+
if (wrk->vpi->handling == VCL_RET_ABANDON || wrk->vpi->handling == VCL_RET_FAIL) {
945949
VSB_destroy(&synth_body);
946950
return (F_STP_FAIL);
947951
}
948952

949-
if (wrk->handling == VCL_RET_RETRY) {
953+
if (wrk->vpi->handling == VCL_RET_RETRY) {
950954
VSB_destroy(&synth_body);
951955
if (bo->retries++ < cache_param->max_retries)
952956
return (F_STP_RETRY);
953957
VSLb(bo->vsl, SLT_VCL_Error, "Too many retries, failing");
954958
return (F_STP_FAIL);
955959
}
956960

957-
assert(wrk->handling == VCL_RET_DELIVER);
961+
assert(wrk->vpi->handling == VCL_RET_DELIVER);
958962

959963
assert(bo->vfc->wrk == bo->wrk);
960964
assert(bo->vfc->oc == oc);

bin/varnishd/cache/cache_panic.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#include "cache_varnishd.h"
4545
#include "cache_transport.h"
46+
#include "vcc_interface.h"
4647

4748
#include "cache_filter.h"
4849
#include "common/heritage.h"
@@ -296,11 +297,6 @@ pan_wrk(struct vsb *vsb, const struct worker *wrk)
296297
else
297298
VSB_printf(vsb, "0x%x,\n", m);
298299

299-
hand = VCL_Return_Name(wrk->handling);
300-
if (hand != NULL)
301-
VSB_printf(vsb, "VCL::return = %s,\n", hand);
302-
else
303-
VSB_printf(vsb, "VCL::return = 0x%x,\n", wrk->handling);
304300
VSB_cat(vsb, "VCL::methods = {");
305301
m = wrk->seen_methods;
306302
p = "";
@@ -354,6 +350,7 @@ static void
354350
pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
355351
{
356352
const char *p;
353+
const struct worker *wrk;
357354

358355
if (PAN_dump_struct(vsb, bo, BUSYOBJ_MAGIC, "busyobj"))
359356
return;
@@ -364,8 +361,9 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
364361
pan_req(vsb, bo->req);
365362
if (bo->sp != NULL)
366363
pan_sess(vsb, bo->sp);
367-
if (bo->wrk != NULL)
368-
pan_wrk(vsb, bo->wrk);
364+
wrk = bo->wrk;
365+
if (wrk != NULL)
366+
pan_wrk(vsb, wrk);
369367

370368
if (bo->vfc != NULL)
371369
pan_vfp(vsb, bo->vfc);
@@ -407,6 +405,9 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
407405
else
408406
VDI_Panic(bo->director_resp, vsb, "director_resp");
409407
VCL_Panic(vsb, "vcl", bo->vcl);
408+
if (wrk != NULL)
409+
VPI_Panic(vsb, wrk->vpi, bo->vcl);
410+
410411
VSB_indent(vsb, -2);
411412
VSB_cat(vsb, "},\n");
412413
}
@@ -431,6 +432,7 @@ static void
431432
pan_req(struct vsb *vsb, const struct req *req)
432433
{
433434
const struct transport *xp;
435+
const struct worker *wrk;
434436

435437
if (PAN_dump_struct(vsb, req, REQ_MAGIC, "req"))
436438
return;
@@ -465,8 +467,9 @@ pan_req(struct vsb *vsb, const struct req *req)
465467
if (req->sp != NULL)
466468
pan_sess(vsb, req->sp);
467469

468-
if (req->wrk != NULL)
469-
pan_wrk(vsb, req->wrk);
470+
wrk = req->wrk;
471+
if (wrk != NULL)
472+
pan_wrk(vsb, wrk);
470473

471474
WS_Panic(vsb, req->ws);
472475
if (VALID_OBJ(req->htc, HTTP_CONN_MAGIC))
@@ -478,6 +481,8 @@ pan_req(struct vsb *vsb, const struct req *req)
478481
VDP_Panic(vsb, req->vdc);
479482

480483
VCL_Panic(vsb, "vcl", req->vcl);
484+
if (wrk != NULL)
485+
VPI_Panic(vsb, wrk->vpi, req->vcl);
481486

482487
if (req->body_oc != NULL)
483488
pan_objcore(vsb, "BODY", req->body_oc);

bin/varnishd/cache/cache_req_fsm.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "cache_filter.h"
4545
#include "cache_objhead.h"
4646
#include "cache_transport.h"
47+
#include "vcc_interface.h"
4748

4849
#include "hash/hash_slinger.h"
4950
#include "http1/cache_http1.h"
@@ -238,12 +239,12 @@ cnt_deliver(struct worker *wrk, struct req *req)
238239

239240
assert(req->restarts <= cache_param->max_restarts);
240241

241-
if (wrk->handling != VCL_RET_DELIVER) {
242+
if (wrk->vpi->handling != VCL_RET_DELIVER) {
242243
HSH_Cancel(wrk, req->objcore, NULL);
243244
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
244245
http_Teardown(req->resp);
245246

246-
switch (wrk->handling) {
247+
switch (wrk->vpi->handling) {
247248
case VCL_RET_RESTART:
248249
req->req_step = R_STP_RESTART;
249250
break;
@@ -260,7 +261,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
260261
return (REQ_FSM_MORE);
261262
}
262263

263-
assert(wrk->handling == VCL_RET_DELIVER);
264+
assert(wrk->vpi->handling == VCL_RET_DELIVER);
264265

265266
if (IS_TOPREQ(req) && RFC2616_Do_Cond(req))
266267
http_PutResponse(req->resp, "HTTP/1.1", 304, NULL);
@@ -333,7 +334,7 @@ cnt_synth(struct worker *wrk, struct req *req)
333334

334335
VSLb_ts_req(req, "Process", W_TIM_real(wrk));
335336

336-
if (wrk->handling == VCL_RET_FAIL) {
337+
if (wrk->vpi->handling == VCL_RET_FAIL) {
337338
VSB_destroy(&synth_body);
338339
(void)VRB_Ignore(req);
339340
(void)req->transport->minimal_response(req, 500);
@@ -343,11 +344,11 @@ cnt_synth(struct worker *wrk, struct req *req)
343344
return (REQ_FSM_DONE);
344345
}
345346

346-
if (wrk->handling == VCL_RET_RESTART &&
347+
if (wrk->vpi->handling == VCL_RET_RESTART &&
347348
req->restarts > cache_param->max_restarts)
348-
wrk->handling = VCL_RET_DELIVER;
349+
wrk->vpi->handling = VCL_RET_DELIVER;
349350

350-
if (wrk->handling == VCL_RET_RESTART) {
351+
if (wrk->vpi->handling == VCL_RET_RESTART) {
351352
/*
352353
* XXX: Should we reset req->doclose = SC_VCL_FAILURE
353354
* XXX: If so, to what ?
@@ -357,7 +358,7 @@ cnt_synth(struct worker *wrk, struct req *req)
357358
req->req_step = R_STP_RESTART;
358359
return (REQ_FSM_MORE);
359360
}
360-
assert(wrk->handling == VCL_RET_DELIVER);
361+
assert(wrk->vpi->handling == VCL_RET_DELIVER);
361362

362363
http_Unset(req->resp, H_Content_Length);
363364
http_PrintfHeader(req->resp, "Content-Length: %zd",
@@ -617,7 +618,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
617618

618619
VCL_hit_method(req->vcl, wrk, req, NULL, NULL);
619620

620-
switch (wrk->handling) {
621+
switch (wrk->vpi->handling) {
621622
case VCL_RET_DELIVER:
622623
if (busy != NULL) {
623624
AZ(oc->flags & OC_F_HFM);
@@ -679,7 +680,7 @@ cnt_miss(struct worker *wrk, struct req *req)
679680
CHECK_OBJ_ORNULL(req->stale_oc, OBJCORE_MAGIC);
680681

681682
VCL_miss_method(req->vcl, wrk, req, NULL, NULL);
682-
switch (wrk->handling) {
683+
switch (wrk->vpi->handling) {
683684
case VCL_RET_FETCH:
684685
wrk->stats->cache_miss++;
685686
VBF_Fetch(wrk, req, req->objcore, req->stale_oc, VBF_NORMAL);
@@ -724,7 +725,7 @@ cnt_pass(struct worker *wrk, struct req *req)
724725
AZ(req->stale_oc);
725726

726727
VCL_pass_method(req->vcl, wrk, req, NULL, NULL);
727-
switch (wrk->handling) {
728+
switch (wrk->vpi->handling) {
728729
case VCL_RET_FAIL:
729730
req->req_step = R_STP_VCLFAIL;
730731
break;
@@ -785,11 +786,11 @@ cnt_pipe(struct worker *wrk, struct req *req)
785786

786787
bo->wrk = wrk;
787788
if (WS_Overflowed(req->ws))
788-
wrk->handling = VCL_RET_FAIL;
789+
wrk->vpi->handling = VCL_RET_FAIL;
789790
else
790791
VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
791792

792-
switch (wrk->handling) {
793+
switch (wrk->vpi->handling) {
793794
case VCL_RET_SYNTH:
794795
req->req_step = R_STP_SYNTH;
795796
nxt = REQ_FSM_MORE;
@@ -960,12 +961,12 @@ cnt_recv(struct worker *wrk, struct req *req)
960961

961962
VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
962963

963-
if (wrk->handling == VCL_RET_FAIL) {
964+
if (wrk->vpi->handling == VCL_RET_FAIL) {
964965
req->req_step = R_STP_VCLFAIL;
965966
return (REQ_FSM_MORE);
966967
}
967968

968-
if (wrk->handling == VCL_RET_VCL && req->restarts == 0) {
969+
if (wrk->vpi->handling == VCL_RET_VCL && req->restarts == 0) {
969970
// Req_Rollback has happened in VPI_vcl_select
970971
assert(WS_Snapshot(req->ws) == req->ws_req);
971972
cnt_recv_prep(req, ci);
@@ -986,7 +987,7 @@ cnt_recv(struct worker *wrk, struct req *req)
986987
return (REQ_FSM_DONE);
987988
}
988989

989-
recv_handling = wrk->handling;
990+
recv_handling = wrk->vpi->handling;
990991

991992
/* We wash the A-E header here for the sake of VRY */
992993
if (cache_param->http_gzip_support &&
@@ -1001,10 +1002,10 @@ cnt_recv(struct worker *wrk, struct req *req)
10011002

10021003
VSHA256_Init(&sha256ctx);
10031004
VCL_hash_method(req->vcl, wrk, req, NULL, &sha256ctx);
1004-
if (wrk->handling == VCL_RET_FAIL)
1005-
recv_handling = wrk->handling;
1005+
if (wrk->vpi->handling == VCL_RET_FAIL)
1006+
recv_handling = wrk->vpi->handling;
10061007
else
1007-
assert(wrk->handling == VCL_RET_LOOKUP);
1008+
assert(wrk->vpi->handling == VCL_RET_LOOKUP);
10081009
VSHA256_Final(req->digest, &sha256ctx);
10091010

10101011
switch (recv_handling) {
@@ -1089,7 +1090,7 @@ cnt_purge(struct worker *wrk, struct req *req)
10891090
AZ(HSH_DerefObjCore(wrk, &boc, 1));
10901091

10911092
VCL_purge_method(req->vcl, wrk, req, NULL, NULL);
1092-
switch (wrk->handling) {
1093+
switch (wrk->vpi->handling) {
10931094
case VCL_RET_RESTART:
10941095
req->req_step = R_STP_RESTART;
10951096
break;

bin/varnishd/cache/cache_varnishd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,13 @@ void WRK_Init(void);
526526
void WRK_AddStat(const struct worker *);
527527
void WRK_Log(enum VSL_tag_e, const char *, ...);
528528

529+
/* cache_vpi.c */
530+
extern const size_t vpi_wrk_len;
531+
void VPI_wrk_init(struct worker *, void *, size_t);
532+
void VPI_Panic(struct vsb *, const struct wrk_vpi *, const struct vcl *);
533+
void VPI_l_vcl_trace(struct wrk_vpi *, VCL_BOOL);
534+
VCL_BOOL VPI_r_vcl_trace(struct wrk_vpi *);
535+
529536
/* cache_ws.c */
530537
void WS_Panic(struct vsb *, const struct ws *);
531538
static inline int

0 commit comments

Comments
 (0)