[master] 27017722d vtc_http: Turn http::timeout into a duration
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Jan 30 16:55:06 UTC 2023
commit 27017722d56c6c3152d92648f6d5470bccc3a695
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Jul 29 17:47:13 2022 +0200
vtc_http: Turn http::timeout into a duration
This aligns with varnishd where durations are always computed in seconds
instead of introducing corner cases where sometimes it's milliseconds.
It also aligns with vtc_syslog that was introduced after the change to
"seconds everywhere" in varnishd.
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 44c0138cd..4b79ebc1b 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -496,12 +496,12 @@ http_rxchar(struct http *hp, int n, int eof)
pfd[0].fd = hp->sess->fd;
pfd[0].events = POLLIN;
pfd[0].revents = 0;
- i = poll(pfd, 1, hp->timeout);
+ i = poll(pfd, 1, hp->timeout * 1000);
if (i < 0 && errno == EINTR)
continue;
if (i == 0) {
vtc_log(hp->vl, hp->fatal,
- "HTTP rx timeout (fd:%d %u ms)",
+ "HTTP rx timeout (fd:%d %.3fs)",
hp->sess->fd, hp->timeout);
continue;
}
@@ -1473,7 +1473,7 @@ cmd_http_timeout(CMD_ARGS)
d = VNUM(av[1]);
if (isnan(d))
vtc_fatal(vl, "timeout is not a number (%s)", av[1]);
- hp->timeout = (int)(d * 1000.0);
+ hp->timeout = d;
}
/* SECTION: client-server.spec.expect_close
@@ -1500,7 +1500,7 @@ cmd_http_expect_close(CMD_ARGS)
fds[0].fd = hp->sess->fd;
fds[0].events = POLLIN;
fds[0].revents = 0;
- i = poll(fds, 1, hp->timeout);
+ i = poll(fds, 1, hp->timeout * 1000);
if (i < 0 && errno == EINTR)
continue;
if (i == 0)
@@ -1821,7 +1821,7 @@ http_process(struct vtclog *vl, struct vtc_sess *vsp, const char *spec,
AN(hp);
hp->sess = vsp;
hp->sess->fd = sock;
- hp->timeout = vtc_maxdur * 1000 / 2;
+ hp->timeout = vtc_maxdur * .5;
if (rcvbuf) {
// XXX setsockopt() too late on SunOS
diff --git a/bin/varnishtest/vtc_http.h b/bin/varnishtest/vtc_http.h
index e45b40469..c029cb80d 100644
--- a/bin/varnishtest/vtc_http.h
+++ b/bin/varnishtest/vtc_http.h
@@ -47,7 +47,7 @@ struct http {
#define HTTP_MAGIC 0x2f02169c
int *sfd;
struct vtc_sess *sess;
- int timeout;
+ vtim_dur timeout;
struct vtclog *vl;
struct vsb *vsb;
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index 7a437eb84..7a848bb0d 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -176,12 +176,12 @@ get_bytes(const struct http *hp, char *buf, int n)
pfd[0].fd = hp->sess->fd;
pfd[0].events = POLLIN;
pfd[0].revents = 0;
- i = poll(pfd, 1, hp->timeout);
+ i = poll(pfd, 1, hp->timeout * 1000);
if (i < 0 && errno == EINTR)
continue;
if (i == 0)
vtc_log(hp->vl, 3,
- "HTTP2 rx timeout (fd:%d %u ms)",
+ "HTTP2 rx timeout (fd:%d %.3fs)",
hp->sess->fd, hp->timeout);
if (i < 0)
vtc_log(hp->vl, 3,
More information about the varnish-commit
mailing list