Commit d3780078 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Properly give esi_level>0 requests their own VDP stack which

passes down to parents VDP stack.

Always close all the VDPs.
parent 18c88fbd
...@@ -83,3 +83,12 @@ VDP_pop(struct req *req, vdp_bytes *func) ...@@ -83,3 +83,12 @@ VDP_pop(struct req *req, vdp_bytes *func)
AZ(vdp->priv); AZ(vdp->priv);
req->vdp_nxt = VTAILQ_FIRST(&req->vdp); req->vdp_nxt = VTAILQ_FIRST(&req->vdp);
} }
void
VDP_close(struct req *req)
{
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
while (!VTAILQ_EMPTY(&req->vdp))
VDP_pop(req, VTAILQ_FIRST(&req->vdp)->func);
}
...@@ -41,6 +41,27 @@ ...@@ -41,6 +41,27 @@
#include "vend.h" #include "vend.h"
#include "vgz.h" #include "vgz.h"
/*--------------------------------------------------------------------*/
static int __match_proto__(vdp_bytes)
ved_vdp_bytes(struct req *req, enum vdp_action act, void **priv,
const void *ptr, ssize_t len)
{
struct req *preq;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (act == VDP_INIT)
return (0);
if (act == VDP_FINI) {
*priv = NULL;
return (0);
}
CAST_OBJ_NOTNULL(preq, *priv, REQ_MAGIC);
req->acct.resp_bodybytes += len;
return (VDP_bytes(preq, act, ptr, len));
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
...@@ -112,13 +133,16 @@ ved_include(struct req *preq, const char *src, const char *host) ...@@ -112,13 +133,16 @@ ved_include(struct req *preq, const char *src, const char *host)
req->l_crc = preq->l_crc; req->l_crc = preq->l_crc;
req->vdp = preq->vdp; req->vdp_nxt = 0;
req->vdp_nxt = preq->vdp_nxt; VTAILQ_INIT(&req->vdp);
VDP_push(req, ved_vdp_bytes, preq);
THR_SetRequest(req); THR_SetRequest(req);
VSLb_ts_req(req, "Start", W_TIM_real(wrk)); VSLb_ts_req(req, "Start", W_TIM_real(wrk));
req->ws_req = WS_Snapshot(req->ws);
while (1) { while (1) {
req->wrk = wrk; req->wrk = wrk;
s = CNT_Request(wrk, req); s = CNT_Request(wrk, req);
...@@ -132,8 +156,7 @@ ved_include(struct req *preq, const char *src, const char *host) ...@@ -132,8 +156,7 @@ ved_include(struct req *preq, const char *src, const char *host)
} }
AN(V1L_IsReleased(wrk)); AN(V1L_IsReleased(wrk));
/* Charge the transmitted body byte counts also to the parent request */ VDP_close(req);
preq->acct.resp_bodybytes += req->acct.resp_bodybytes;
CNT_AcctLogCharge(wrk->stats, req); CNT_AcctLogCharge(wrk->stats, req);
VSL_End(req->vsl); VSL_End(req->vsl);
......
...@@ -89,10 +89,10 @@ enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); ...@@ -89,10 +89,10 @@ enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr);
enum vdp_action { enum vdp_action {
VDP_INIT, VDP_INIT,
VDP_FINI,
VDP_NULL, VDP_NULL,
VDP_FLUSH, VDP_FLUSH,
VDP_FINISH, VDP_FINISH,
VDP_FINI,
}; };
typedef int vdp_bytes(struct req *, enum vdp_action, void **priv, typedef int vdp_bytes(struct req *, enum vdp_action, void **priv,
...@@ -109,6 +109,7 @@ struct vdp_entry { ...@@ -109,6 +109,7 @@ struct vdp_entry {
int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len);
void VDP_push(struct req *, vdp_bytes *func, void *priv); void VDP_push(struct req *, vdp_bytes *func, void *priv);
void VDP_pop(struct req *, vdp_bytes *func); void VDP_pop(struct req *, vdp_bytes *func);
void VDP_close(struct req *req);
vdp_bytes VDP_gunzip; vdp_bytes VDP_gunzip;
vdp_bytes VED_pretend_gzip; vdp_bytes VED_pretend_gzip;
......
...@@ -384,4 +384,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo) ...@@ -384,4 +384,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
if ((V1L_FlushRelease(req->wrk) || ois != OIS_DONE) && if ((V1L_FlushRelease(req->wrk) || ois != OIS_DONE) &&
req->sp->fd >= 0) req->sp->fd >= 0)
SES_Close(req->sp, SC_REM_CLOSE); SES_Close(req->sp, SC_REM_CLOSE);
if (req->esi_level == 0)
VDP_close(req);
} }
...@@ -93,7 +93,7 @@ V1L_Reserve(struct worker *wrk, int *fd, struct vsl_log *vsl, double t0) ...@@ -93,7 +93,7 @@ V1L_Reserve(struct worker *wrk, int *fd, struct vsl_log *vsl, double t0)
wrk->v1l = v1l; wrk->v1l = v1l;
} }
unsigned unsigned
V1L_FlushRelease(struct worker *wrk) V1L_FlushRelease(struct worker *wrk)
{ {
struct v1l *v1l; struct v1l *v1l;
......
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