Mailing List Archive

[master] bb6441474 v1p: Honor pipe_task_deadline parameter
commit bb6441474971c975bee50e1aa919b2387a934562
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Fri Jan 19 18:04:32 2024 +0100

v1p: Honor pipe_task_deadline parameter

diff --git a/bin/varnishd/http1/cache_http1_pipe.c b/bin/varnishd/http1/cache_http1_pipe.c
index c55f68803..d0b513c7c 100644
--- a/bin/varnishd/http1/cache_http1_pipe.c
+++ b/bin/varnishd/http1/cache_http1_pipe.c
@@ -40,6 +40,7 @@

#include "cache_http1.h"
#include "vtcp.h"
+#include "vtim.h"

#include "VSC_vbe.h"

@@ -117,7 +118,8 @@ stream_close_t
V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
{
struct pollfd fds[2];
- vtim_dur tmo;
+ vtim_dur tmo, tmo_task;
+ vtim_real deadline;
stream_close_t sc;
int i, j;

@@ -141,6 +143,10 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
fds[1].fd = req->sp->fd;
fds[1].events = POLLIN;

+ deadline = cache_param->pipe_task_deadline;
+ if (deadline > 0.)
+ deadline += req->sp->t_idle;
+
sc = SC_TX_PIPE;
while (fds[0].fd > -1 || fds[1].fd > -1) {
fds[0].revents = 0;
@@ -148,6 +154,11 @@ V1P_Process(const struct req *req, int fd, struct v1p_acct *v1a)
tmo = cache_param->pipe_timeout;
if (tmo == 0.)
tmo = -1.;
+ if (deadline > 0.) {
+ tmo_task = deadline - VTIM_real();
+ tmo = (tmo > 0.) ? vmin(tmo, tmo_task) : tmo_task;
+ tmo = vmax(tmo, 0.);
+ }
i = poll(fds, 2, (int)(tmo * 1e3));
if (i == 0)
sc = SC_RX_TIMEOUT;
diff --git a/bin/varnishtest/tests/s00013.vtc b/bin/varnishtest/tests/s00013.vtc
index 06e89871b..e27838df5 100644
--- a/bin/varnishtest/tests/s00013.vtc
+++ b/bin/varnishtest/tests/s00013.vtc
@@ -10,13 +10,31 @@ server s1 {
rxreq
txresp -hdr "transfer-encoding: chunked"
expect_close
+
+ accept
+ rxreq
+ txresp -hdr "transfer-encoding: chunked"
+ expect_close
+
+ accept
+ non_fatal
+ rxreq
+ txresp -hdr "transfer-encoding: chunked"
+ loop 20 {
+ chunkedlen 1
+ delay 0.1
+ }
} -start

varnish v1 -cliok "param.set pipe_timeout 0s"
+varnish v1 -cliok "param.set pipe_task_deadline 0s"
varnish v1 -vcl+backend "" -start

-logexpect l1 -v v1 -q "Timestamp:PipeSess[2] > 1.0" {
- expect 1001 * ReqMethod PIPE
+logexpect l1 -v v1 -g raw -q SessClose {
+ expect 1000 * SessClose {^TX_PIPE 1\.}
+ expect 1003 * SessClose {^RX_TIMEOUT 0\.}
+ expect 1006 * SessClose {^RX_TIMEOUT 1\.}
+ expect 1009 * SessClose {^RX_TIMEOUT 1\.}
} -start

client c1 {
@@ -25,11 +43,20 @@ client c1 {
rxresp
} -run

-logexpect l1 -wait
+varnish v1 -cliok "param.set pipe_timeout 500ms"
+varnish v1 -cliok "param.set pipe_task_deadline 0s"
+client c1 -run
+
+varnish v1 -cliok "param.set pipe_timeout 0s"
+varnish v1 -cliok "param.set pipe_task_deadline 1.1s"
+client c1 -run

varnish v1 -cliok "param.set pipe_timeout 500ms"
+varnish v1 -cliok "param.set pipe_task_deadline 1.1s"
client c1 -run

-varnish v1 -expect MAIN.s_pipe == 2
+logexpect l1 -wait
+
+varnish v1 -expect MAIN.s_pipe == 4
varnish v1 -expect MAIN.sc_tx_pipe == 1
-varnish v1 -expect MAIN.sc_rx_timeout == 1
+varnish v1 -expect MAIN.sc_rx_timeout == 3
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit