[master] fbc143344 Move the embark step outside of CNT_Request
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Dec 27 07:33:05 UTC 2018
commit fbc143344f3de364231b298281c7c5fbb0a2f291
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu Dec 27 08:31:11 2018 +0100
Move the embark step outside of CNT_Request
And make the caller responsible for formally entering the task.
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index a4aeb584b..5642f31e1 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -178,10 +178,12 @@ ved_include(struct req *preq, const char *src, const char *host,
req->transport = &VED_transport;
req->transport_priv = ecx;
+ CNT_Embark(wrk, req);
+ VCL_TaskEnter(req->vcl, req->privs);
+
while (1) {
- req->wrk = wrk;
ecx->woken = 0;
- s = CNT_Request(wrk, req);
+ s = CNT_Request(req);
if (s == REQ_FSM_DONE)
break;
DSL(DBG_WAITINGLIST, req->vsl->wid,
@@ -193,6 +195,7 @@ ved_include(struct req *preq, const char *src, const char *host,
&ecx->preq->wrk->cond, &sp->mtx, 0);
Lck_Unlock(&sp->mtx);
AZ(req->wrk);
+ CNT_Embark(wrk, req);
}
VCL_Rel(&req->vcl);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 05d5339f4..f5e6b16f7 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -1015,13 +1015,34 @@ cnt_diag(struct req *req, const char *state)
VSL_Flush(req->vsl, 0);
}
+void
+CNT_Embark(struct worker *wrk, struct req *req)
+{
+
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+
+ /* wrk can have changed for restarts */
+ req->vfc->wrk = req->wrk = wrk;
+ wrk->vsl = req->vsl;
+ if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) {
+ VCL_Refresh(&wrk->vcl);
+ req->vcl = wrk->vcl;
+ wrk->vcl = NULL;
+ }
+
+ AN(req->vcl);
+}
+
enum req_fsm_nxt
-CNT_Request(struct worker *wrk, struct req *req)
+CNT_Request(struct req *req)
{
+ struct worker *wrk;
enum req_fsm_nxt nxt;
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ wrk = req->wrk;
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC);
AN(req->transport->deliver);
@@ -1035,19 +1056,9 @@ CNT_Request(struct worker *wrk, struct req *req)
req->req_step == R_STP_TRANSPORT);
AN(req->vsl->wid & VSL_CLIENTMARKER);
-
- /* wrk can have changed for restarts */
- req->vfc->wrk = req->wrk = wrk;
- wrk->vsl = req->vsl;
- if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) {
- AZ(req->vcl);
- VCL_Refresh(&wrk->vcl);
- req->vcl = wrk->vcl;
- wrk->vcl = NULL;
- }
AN(req->vcl);
- if (req->req_step != R_STP_LOOKUP)
- VCL_TaskEnter(req->vcl, req->privs);
+ CHECK_OBJ(req->privs, VRT_PRIVS_MAGIC);
+
for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) {
/*
* This is a good place to be paranoid about the various
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 0c29891e6..b8c53a6df 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -330,7 +330,8 @@ enum req_fsm_nxt {
REQ_FSM_DISEMBARK,
};
-enum req_fsm_nxt CNT_Request(struct worker *, struct req *);
+void CNT_Embark(struct worker *, struct req *);
+enum req_fsm_nxt CNT_Request(struct req *);
/* cache_session.c */
void SES_NewPool(struct pool *, unsigned pool_no);
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 3ef60429d..deee26649 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -442,7 +442,10 @@ HTTP1_Session(struct worker *wrk, struct req *req)
req->task.func = http1_req;
req->task.priv = req;
wrk->stats->client_req++;
- if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK)
+ CNT_Embark(wrk, req);
+ if (req->req_step == R_STP_TRANSPORT)
+ VCL_TaskEnter(req->vcl, req->privs);
+ if (CNT_Request(req) == REQ_FSM_DISEMBARK)
return;
req->task.func = NULL;
req->task.priv = NULL;
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 8915e1498..d71b6949a 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -534,9 +534,12 @@ h2_do_req(struct worker *wrk, void *priv)
CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
THR_SetRequest(req);
+ CNT_Embark(wrk, req);
+ if (req->req_step == R_STP_TRANSPORT)
+ VCL_TaskEnter(req->vcl, req->privs);
wrk->stats->client_req++;
- if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) {
+ if (CNT_Request(req) != REQ_FSM_DISEMBARK) {
AZ(req->ws->r);
h2 = r2->h2sess;
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
More information about the varnish-commit
mailing list