[master] 43bbe97b3 Pull the deadline calculation out of V1L
Nils Goroll
nils.goroll at uplex.de
Wed Apr 24 09:32:09 UTC 2019
commit 43bbe97b38a86d706c0d9f4838bbfbd305342775
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Apr 24 09:31:01 2019 +0200
Pull the deadline calculation out of V1L
and change the t0 argument into a vtim_real deadline, allowing for
adjustments per call.
This causes changes of send_timeout to not change open V1L transactions.
This also exposed the fact that we are using send_timeout also for
sending the bereq.body to the backend. Is this what we want?
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index 0bc52606c..47c9fce5c 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -59,7 +59,7 @@ void V1P_Charge(struct req *, const struct v1p_acct *, struct VSC_vbe *);
void V1L_Chunked(const struct worker *w);
void V1L_EndChunk(const struct worker *w);
void V1L_Open(struct worker *, struct ws *, int *fd, struct vsl_log *,
- double t0, unsigned niov);
+ vtim_real deadline, unsigned niov);
unsigned V1L_Flush(const struct worker *w);
unsigned V1L_Close(struct worker *w, uint64_t *cnt);
size_t V1L_Write(const struct worker *w, const void *ptr, ssize_t len);
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index b2e061391..ff21ede7f 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -131,7 +131,8 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
AZ(req->wrk->v1l);
V1L_Open(req->wrk, req->wrk->aws,
- &req->sp->fd, req->vsl, req->t_prev, cache_param->http1_iovs);
+ &req->sp->fd, req->vsl, req->t_prev + cache_param->send_timeout,
+ cache_param->http1_iovs);
if (WS_Overflowed(req->wrk->aws)) {
v1d_error(req, "workspace_thread overflow");
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index d8ce8a1a6..dc1515ef1 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -96,7 +96,9 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
}
VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */
- V1L_Open(wrk, wrk->aws, htc->rfd, bo->vsl, bo->t_prev, 0);
+ /* XXX: what is the right timeout ? Isn't send_timeout client side? */
+ V1L_Open(wrk, wrk->aws, htc->rfd, bo->vsl,
+ bo->t_prev + cache_param->send_timeout, 0);
hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req);
/* Deal with any message-body the request might (still) have */
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index c8352af54..8d03d9b4f 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -60,7 +60,7 @@ struct v1l {
ssize_t liov;
ssize_t cliov;
unsigned ciov; /* Chunked header marker */
- double t0;
+ vtim_real deadline;
struct vsl_log *vsl;
ssize_t cnt; /* Flushed byte count */
struct ws *ws;
@@ -74,7 +74,7 @@ struct v1l {
void
V1L_Open(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
- double t0, unsigned niov)
+ vtim_real deadline, unsigned niov)
{
struct v1l *v1l;
unsigned u;
@@ -114,7 +114,7 @@ V1L_Open(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
v1l->siov = u;
v1l->ciov = u;
v1l->wfd = fd;
- v1l->t0 = t0;
+ v1l->deadline = deadline;
v1l->vsl = vsl;
wrk->v1l = v1l;
@@ -209,7 +209,7 @@ V1L_Flush(const struct worker *wrk)
* counter to prevent slowloris attacks
*/
- if (VTIM_real() - v1l->t0 > cache_param->send_timeout) {
+ if (VTIM_real() > v1l->deadline) {
VSLb(v1l->vsl, SLT_Debug,
"Hit total send timeout, "
"wrote = %zd/%zd; not retrying",
More information about the varnish-commit
mailing list