Mailing List Archive

[master] 7eb20abe6 v1p: Refine stream_close_t outcome
commit 7eb20abe671046fc253f4bf5731dd94f3b8ba86f
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Fri Jan 19 16:37:49 2024 +0100

v1p: Refine stream_close_t outcome

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 2a9e31edc..6b378aede 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -391,11 +391,10 @@ vbe_dir_http1pipe(VRT_CTX, VCL_BACKEND d)
&v1a.bereq, &v1a.out);
VSLb_ts_req(ctx->req, "Pipe", W_TIM_real(ctx->req->wrk));
if (i == 0)
- V1P_Process(ctx->req, *PFD_Fd(pfd), &v1a);
+ retval = V1P_Process(ctx->req, *PFD_Fd(pfd), &v1a);
VSLb_ts_req(ctx->req, "PipeSess", W_TIM_real(ctx->req->wrk));
- ctx->bo->htc->doclose = SC_TX_PIPE;
+ ctx->bo->htc->doclose = retval;
vbe_dir_finish(ctx, d);
- retval = SC_TX_PIPE;
}
V1P_Charge(ctx->req, &v1a, bp->vsc);
CHECK_OBJ_NOTNULL(retval, STREAM_CLOSE_MAGIC);
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index dc454bcab..b5ab02446 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -54,7 +54,7 @@ struct v1p_acct {

int V1P_Enter(void);
void V1P_Leave(void);
-void V1P_Process(const struct req *, int fd, struct v1p_acct *);
+stream_close_t V1P_Process(const struct req *, int fd, struct v1p_acct *);
void V1P_Charge(struct req *, const struct v1p_acct *, struct VSC_vbe *);

/* cache_http1_line.c */
diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c
index 0c4a69a03..c55f68803 100644
--- a/bin/varnishd/http1/cache_http1_pipe.c
+++ b/bin/varnishd/http1/cache_http1_pipe.c
@@ -113,11 +113,12 @@ V1P_Charge(struct req *req, const struct v1p_acct *a, struct VSC_vbe *b)
Lck_Unlock(&pipestat_mtx);
}

-void
+stream_close_t
V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
{
struct pollfd fds[2];
vtim_dur tmo;
+ stream_close_t sc;
int i, j;

CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -129,7 +130,7 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
req->htc->pipeline_e - req->htc->pipeline_b);
VTCP_Assert(j);
if (j < 0)
- return;
+ return (SC_OVERLOAD);
req->htc->pipeline_b = NULL;
req->htc->pipeline_e = NULL;
v1a->in += j;
@@ -140,6 +141,7 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
fds[1].fd = req->sp->fd;
fds[1].events = POLLIN;

+ sc = SC_TX_PIPE;
while (fds[0].fd > -1 || fds[1].fd > -1) {
fds[0].revents = 0;
fds[1].revents = 0;
@@ -147,6 +149,8 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
if (tmo == 0.)
tmo = -1.;
i = poll(fds, 2, (int)(tmo * 1e3));
+ if (i == 0)
+ sc = SC_RX_TIMEOUT;
if (i < 1)
break;
if (fds[0].revents &&
@@ -168,6 +172,8 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
fds[1].fd = -1;
}
}
+
+ return (sc);
}

/*--------------------------------------------------------------------*/
diff --git a/bin/varnishtest/tests/s00013.vtc b/bin/varnishtest/tests/s00013.vtc
index ac7168bb1..06e89871b 100644
--- a/bin/varnishtest/tests/s00013.vtc
+++ b/bin/varnishtest/tests/s00013.vtc
@@ -4,6 +4,12 @@ server s1 {
rxreq
txresp -hdr "transfer-encoding: chunked"
delay 1.1
+ close
+
+ accept
+ rxreq
+ txresp -hdr "transfer-encoding: chunked"
+ expect_close
} -start

varnish v1 -cliok "param.set pipe_timeout 0s"
@@ -20,3 +26,10 @@ client c1 {
} -run

logexpect l1 -wait
+
+varnish v1 -cliok "param.set pipe_timeout 500ms"
+client c1 -run
+
+varnish v1 -expect MAIN.s_pipe == 2
+varnish v1 -expect MAIN.sc_tx_pipe == 1
+varnish v1 -expect MAIN.sc_rx_timeout == 1
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit