[master] 71c443fa5 Refactor delivery a little bit
Poul-Henning Kamp
phk at FreeBSD.org
Fri Oct 12 13:28:09 UTC 2018
commit 71c443fa516ed1ac5bea8cee50988043997c8029
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Oct 12 13:27:32 2018 +0000
Refactor delivery a little bit
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index ee589d19e..961a3f953 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -372,8 +372,9 @@ cnt_transmit(struct worker *wrk, struct req *req)
} else if (status < 200 || status == 204 || status == 304) {
req->resp_len = -1;
sendbody = 0;
- } else
+ } else {
sendbody = 1;
+ }
err = 0;
if (sendbody >= 0) {
@@ -408,9 +409,11 @@ cnt_transmit(struct worker *wrk, struct req *req)
"Content-Length: %jd", req->resp_len);
}
- if (err == 0)
+ if (err == 0) {
+ if (req->resp_len == 0)
+ sendbody = 0;
req->transport->deliver(req, boc, sendbody);
- else {
+ } else {
VSLb(req->vsl, SLT_Error, "Failure to push processors");
req->doclose = SC_OVERLOAD;
}
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index c075dd908..7c617ebe7 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -91,6 +91,16 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
CHECK_OBJ_ORNULL(boc, BOC_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
+ if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) {
+ req->doclose = SC_RESP_CLOSE;
+ } else if (req->doclose) {
+ if (!http_HdrIs(req->resp, H_Connection, "close")) {
+ http_Unset(req->resp, H_Connection);
+ http_SetHeader(req->resp, "Connection: close");
+ }
+ } else if (!http_GetHdr(req->resp, H_Connection, NULL))
+ http_SetHeader(req->resp, "Connection: keep-alive");
+
if (sendbody) {
if (http_GetHdr(req->resp, H_Content_Length, NULL))
req->res_mode |= RES_LEN;
@@ -101,17 +111,12 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
req->res_mode |= RES_EOF;
req->doclose = SC_TX_EOF;
}
- }
-
- if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) {
- req->doclose = SC_RESP_CLOSE;
- } else if (req->doclose) {
- if (!http_HdrIs(req->resp, H_Connection, "close")) {
- http_Unset(req->resp, H_Connection);
- http_SetHeader(req->resp, "Connection: close");
+ if (VDP_Push(req, &v1d_vdp, NULL)) {
+ v1d_error(req, "workspace_thread overflow");
+ AZ(req->wrk->v1l);
+ return;
}
- } else if (!http_GetHdr(req->resp, H_Connection, NULL))
- http_SetHeader(req->resp, "Connection: keep-alive");
+ }
if (WS_Overflowed(req->ws)) {
v1d_error(req, "workspace_client overflow");
@@ -123,15 +128,6 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
return;
}
- if (req->resp_len == 0)
- sendbody = 0;
-
- if (sendbody && VDP_Push(req, &v1d_vdp, NULL)) {
- v1d_error(req, "workspace_thread overflow");
- AZ(req->wrk->v1l);
- return;
- }
-
AZ(req->wrk->v1l);
V1L_Open(req->wrk, req->wrk->aws,
&req->sp->fd, req->vsl, req->t_prev, 0);
@@ -144,9 +140,6 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
hdrbytes = HTTP1_Write(req->wrk, req->resp, HTTP1_Resp);
- if (DO_DEBUG(DBG_FLUSH_HEAD))
- (void)V1L_Flush(req->wrk);
-
if (!sendbody || req->res_mode & RES_ESI) {
if (V1L_Close(req->wrk, &bytes) && req->sp->fd >= 0) {
Req_Fail(req, SC_REM_CLOSE);
@@ -157,7 +150,8 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
* header-bytes have been attempted sent. */
req->acct.resp_hdrbytes += bytes;
hdrbytes = 0;
- }
+ } else if (DO_DEBUG(DBG_FLUSH_HEAD))
+ (void)V1L_Flush(req->wrk);
if (!sendbody) {
AZ(req->wrk->v1l);
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index 446cdaa6e..5ca7ee3c3 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -285,9 +285,6 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody)
AZ(req->wrk->v1l);
- if (sendbody && req->resp_len == 0)
- sendbody = 0;
-
r2->t_send = req->t_prev;
H2_Send_Get(req->wrk, r2->h2sess, r2);
More information about the varnish-commit
mailing list