Commit f75b694d authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

New MAIN.n_pipe gauge

This allows users to keep track of the number of ongoing pipe
transactions at any time.
parent 8e138d60
......@@ -394,6 +394,11 @@
:oneliner: Total sessions seen
.. varnish_vsc:: n_pipe
:type: gauge
:oneliner: Number of ongoing pipe sessions
.. varnish_vsc:: s_pipe
:group: wrk
:oneliner: Total pipe sessions seen
......
......@@ -44,6 +44,7 @@
#include "cache_transport.h"
#include "hash/hash_slinger.h"
#include "http1/cache_http1.h"
#include "storage/storage.h"
#include "common/heritage.h"
#include "vcl.h"
......@@ -704,11 +705,13 @@ cnt_pipe(struct worker *wrk, struct req *req)
nxt = REQ_FSM_MORE;
break;
case VCL_RET_PIPE:
XXXAZ(V1P_Enter());
AZ(bo->req);
bo->req = req;
bo->wrk = wrk;
SES_Close(req->sp, VDI_Http1Pipe(req, bo));
nxt = REQ_FSM_DONE;
V1P_Leave();
break;
default:
WRONG("Illegal return from vcl_pipe{}");
......
......@@ -50,6 +50,8 @@ struct v1p_acct {
uint64_t out;
};
int V1P_Enter(void);
void V1P_Leave(void);
void V1P_Process(const struct req *, int fd, struct v1p_acct *);
void V1P_Charge(struct req *, const struct v1p_acct *, struct VSC_vbe *);
......
......@@ -62,6 +62,26 @@ rdf(int fd0, int fd1, uint64_t *pcnt)
return (0);
}
int
V1P_Enter(void)
{
Lck_Lock(&pipestat_mtx);
VSC_C_main->n_pipe++;
Lck_Unlock(&pipestat_mtx);
return (0);
}
void
V1P_Leave(void)
{
Lck_Lock(&pipestat_mtx);
assert(VSC_C_main->n_pipe > 0);
VSC_C_main->n_pipe--;
Lck_Unlock(&pipestat_mtx);
}
void
V1P_Charge(struct req *req, const struct v1p_acct *a, struct VSC_vbe *b)
{
......
varnishtest "n_pipe gauge"
barrier b1 cond 2
barrier b2 cond 2
barrier b3 cond 2
barrier b4 cond 2
server s1 {
rxreq
barrier b1 sync
barrier b2 sync
txresp
} -start
server s2 {
rxreq
barrier b3 sync
barrier b4 sync
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.url == "/c1") {
set req.backend_hint = s1;
}
elsif (req.url == "/c2") {
set req.backend_hint = s2;
}
return (pipe);
}
} -start
varnish v1 -expect MAIN.n_pipe == 0
client c1 {
txreq -url "/c1"
rxresp
} -start
barrier b1 sync
varnish v1 -expect MAIN.n_pipe == 1
client c2 {
txreq -url "/c2"
rxresp
} -start
barrier b3 sync
varnish v1 -expect MAIN.n_pipe == 2
barrier b2 sync
varnish v1 -expect MAIN.n_pipe == 1
barrier b4 sync
varnish v1 -expect MAIN.n_pipe == 0
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