Commit b58eb24f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

New pipe_sess_max runtime parameter

Optionally, it can limit the number of concurrent pipe transactions as
they each monopolize one worker thread.
parent f75b694d
...@@ -696,22 +696,24 @@ cnt_pipe(struct worker *wrk, struct req *req) ...@@ -696,22 +696,24 @@ cnt_pipe(struct worker *wrk, struct req *req)
VCL_pipe_method(req->vcl, wrk, req, bo, NULL); VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
switch (wrk->handling) { switch (wrk->handling) {
case VCL_RET_FAIL:
req->req_step = R_STP_VCLFAIL;
nxt = REQ_FSM_MORE;
break;
case VCL_RET_SYNTH: case VCL_RET_SYNTH:
req->req_step = R_STP_SYNTH; req->req_step = R_STP_SYNTH;
nxt = REQ_FSM_MORE; nxt = REQ_FSM_MORE;
break; break;
case VCL_RET_PIPE: case VCL_RET_PIPE:
XXXAZ(V1P_Enter()); if (V1P_Enter() == 0) {
AZ(bo->req); AZ(bo->req);
bo->req = req; bo->req = req;
bo->wrk = wrk; bo->wrk = wrk;
SES_Close(req->sp, VDI_Http1Pipe(req, bo)); SES_Close(req->sp, VDI_Http1Pipe(req, bo));
nxt = REQ_FSM_DONE; nxt = REQ_FSM_DONE;
V1P_Leave(); V1P_Leave();
break;
}
/* fall through */
case VCL_RET_FAIL:
req->req_step = R_STP_VCLFAIL;
nxt = REQ_FSM_MORE;
break; break;
default: default:
WRONG("Illegal return from vcl_pipe{}"); WRONG("Illegal return from vcl_pipe{}");
......
...@@ -65,11 +65,16 @@ rdf(int fd0, int fd1, uint64_t *pcnt) ...@@ -65,11 +65,16 @@ rdf(int fd0, int fd1, uint64_t *pcnt)
int int
V1P_Enter(void) V1P_Enter(void)
{ {
int retval = 0;
Lck_Lock(&pipestat_mtx); Lck_Lock(&pipestat_mtx);
VSC_C_main->n_pipe++; if (cache_param->pipe_sess_max == 0 ||
VSC_C_main->n_pipe < cache_param->pipe_sess_max)
VSC_C_main->n_pipe++;
else
retval = -1;
Lck_Unlock(&pipestat_mtx); Lck_Unlock(&pipestat_mtx);
return (0); return (retval);
} }
void void
......
varnishtest "n_pipe gauge" varnishtest "concurrent pipe limit"
barrier b1 cond 2 barrier b1 cond 2
barrier b2 cond 2 barrier b2 cond 2
...@@ -36,6 +36,7 @@ varnish v1 -expect MAIN.n_pipe == 0 ...@@ -36,6 +36,7 @@ varnish v1 -expect MAIN.n_pipe == 0
client c1 { client c1 {
txreq -url "/c1" txreq -url "/c1"
rxresp rxresp
expect resp.status == 200
} -start } -start
barrier b1 sync barrier b1 sync
...@@ -45,10 +46,20 @@ varnish v1 -expect MAIN.n_pipe == 1 ...@@ -45,10 +46,20 @@ varnish v1 -expect MAIN.n_pipe == 1
client c2 { client c2 {
txreq -url "/c2" txreq -url "/c2"
rxresp rxresp
expect resp.status == 200
} -start } -start
barrier b3 sync barrier b3 sync
varnish v1 -expect MAIN.n_pipe == 2 varnish v1 -expect MAIN.n_pipe == 2
varnish v1 -cliok "param.set pipe_sess_max 2"
client c3 {
txreq
rxresp
expect resp.status == 503
} -run
barrier b2 sync barrier b2 sync
varnish v1 -expect MAIN.n_pipe == 1 varnish v1 -expect MAIN.n_pipe == 1
barrier b4 sync barrier b4 sync
......
...@@ -914,6 +914,20 @@ PARAM( ...@@ -914,6 +914,20 @@ PARAM(
/* func */ NULL /* func */ NULL
) )
PARAM(
/* name */ pipe_sess_max,
/* typ */ uint,
/* min */ "0",
/* max */ NULL,
/* default */ "0",
/* units */ "connections",
/* flags */ 0,
/* s-text */
"Maximum number of sessions dedicated to pipe transactions.",
/* l-text */ "",
/* func */ NULL
)
PARAM( PARAM(
/* name */ pipe_timeout, /* name */ pipe_timeout,
/* typ */ timeout, /* typ */ timeout,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment