Skip to content

Commit

Permalink
v1p: Honor deadline_pipe parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dridi committed Jan 19, 2024
1 parent f379654 commit 068251a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
13 changes: 12 additions & 1 deletion bin/varnishd/http1/cache_http1_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

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

#include "VSC_vbe.h"

Expand Down Expand Up @@ -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;

Expand All @@ -141,13 +143,22 @@ 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->deadline_pipe;
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;
fds[1].revents = 0;
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;
Expand Down
37 changes: 32 additions & 5 deletions bin/varnishtest/tests/s00013.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -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 deadline_pipe 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 {
Expand All @@ -25,11 +43,20 @@ client c1 {
rxresp
} -run

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

varnish v1 -cliok "param.set pipe_timeout 0s"
varnish v1 -cliok "param.set deadline_pipe 1.1s"
client c1 -run

varnish v1 -cliok "param.set pipe_timeout 500ms"
varnish v1 -cliok "param.set deadline_pipe 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

0 comments on commit 068251a

Please sign in to comment.