In transport delivery functions, close VDPs always

Part 1 of the fix for #4067
parent a73e6a5b
...@@ -850,6 +850,17 @@ static const struct vdp ved_ved = { ...@@ -850,6 +850,17 @@ static const struct vdp ved_ved = {
.fini = ved_vdp_fini, .fini = ved_vdp_fini,
}; };
static void
ved_close(struct req *req, struct boc *boc, int error)
{
req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc);
if (! error)
return;
req->top->topreq->vdc->retval = -1;
req->top->topreq->doclose = req->doclose;
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void v_matchproto_(vtr_deliver_f) static void v_matchproto_(vtr_deliver_f)
...@@ -868,19 +879,22 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) ...@@ -868,19 +879,22 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC); CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC);
if (wantbody == 0) if (wantbody == 0) {
ved_close(req, boc, 0);
return; return;
}
status = req->resp->status % 1000; status = req->resp->status % 1000;
if (!ecx->incl_cont && status != 200 && status != 204) { if (!ecx->incl_cont && status != 200 && status != 204) {
req->top->topreq->vdc->retval = -1; ved_close(req, boc, 1);
req->top->topreq->doclose = req->doclose;
return; return;
} }
if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0) if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0) {
ved_close(req, boc, 0);
return; return;
}
if (http_GetHdr(req->resp, H_Content_Encoding, &p)) if (http_GetHdr(req->resp, H_Content_Encoding, &p))
i = http_coding_eq(p, gzip); i = http_coding_eq(p, gzip);
...@@ -899,7 +913,10 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) ...@@ -899,7 +913,10 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (req->objcore->flags & OC_F_FAILED) { if (req->objcore->flags & OC_F_FAILED) {
/* No way of signalling errors in the middle of /* No way of signalling errors in the middle of
the ESI body. Omit this ESI fragment. */ * the ESI body. Omit this ESI fragment.
* XXX change error argument to 1
*/
ved_close(req, boc, 0);
return; return;
} }
...@@ -926,10 +943,5 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) ...@@ -926,10 +943,5 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (i && req->doclose == SC_NULL) if (i && req->doclose == SC_NULL)
req->doclose = SC_REM_CLOSE; req->doclose = SC_REM_CLOSE;
req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc); ved_close(req, boc, i && !ecx->incl_cont);
if (i && !ecx->incl_cont) {
req->top->topreq->vdc->retval = -1;
req->top->topreq->doclose = req->doclose;
}
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
v1d_error(struct req *req, const char *msg) v1d_error(struct req *req, struct boc *boc, const char *msg)
{ {
static const char r_500[] = static const char r_500[] =
"HTTP/1.1 500 Internal Server Error\r\n" "HTTP/1.1 500 Internal Server Error\r\n"
...@@ -57,6 +57,8 @@ v1d_error(struct req *req, const char *msg) ...@@ -57,6 +57,8 @@ v1d_error(struct req *req, const char *msg)
req->wrk->stats->client_resp_500++; req->wrk->stats->client_resp_500++;
VTCP_Assert(write(req->sp->fd, r_500, sizeof r_500 - 1)); VTCP_Assert(write(req->sp->fd, r_500, sizeof r_500 - 1));
req->doclose = SC_TX_EOF; req->doclose = SC_TX_EOF;
req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -98,18 +100,18 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) ...@@ -98,18 +100,18 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
INIT_OBJ(ctx, VRT_CTX_MAGIC); INIT_OBJ(ctx, VRT_CTX_MAGIC);
VCL_Req2Ctx(ctx, req); VCL_Req2Ctx(ctx, req);
if (VDP_Push(ctx, req->vdc, req->ws, VDP_v1l, NULL)) { if (VDP_Push(ctx, req->vdc, req->ws, VDP_v1l, NULL)) {
v1d_error(req, "Failure to push v1d processor"); v1d_error(req, boc, "Failure to push v1d processor");
return; return;
} }
} }
if (WS_Overflowed(req->ws)) { if (WS_Overflowed(req->ws)) {
v1d_error(req, "workspace_client overflow"); v1d_error(req, boc, "workspace_client overflow");
return; return;
} }
if (WS_Overflowed(req->sp->ws)) { if (WS_Overflowed(req->sp->ws)) {
v1d_error(req, "workspace_session overflow"); v1d_error(req, boc, "workspace_session overflow");
return; return;
} }
...@@ -118,7 +120,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) ...@@ -118,7 +120,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
cache_param->http1_iovs); cache_param->http1_iovs);
if (WS_Overflowed(req->wrk->aws)) { if (WS_Overflowed(req->wrk->aws)) {
v1d_error(req, "workspace_thread overflow"); v1d_error(req, boc, "workspace_thread overflow");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment