Commit 3450da1f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

fiddle the VFP's a little bit.

parent 39da3b44
...@@ -259,9 +259,9 @@ struct dstat { ...@@ -259,9 +259,9 @@ struct dstat {
/* Fetch processors --------------------------------------------------*/ /* Fetch processors --------------------------------------------------*/
typedef void vfp_begin_f(void *priv, size_t ); typedef void vfp_begin_f(struct busyobj *bo, size_t );
typedef int vfp_bytes_f(void *priv, struct http_conn *, ssize_t); typedef int vfp_bytes_f(struct busyobj *bo, struct http_conn *, ssize_t);
typedef int vfp_end_f(void *priv); typedef int vfp_end_f(struct busyobj *bo);
struct vfp { struct vfp {
vfp_begin_f *begin; vfp_begin_f *begin;
......
...@@ -295,12 +295,11 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, ...@@ -295,12 +295,11 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef,
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_esi_begin(void *priv, size_t estimate) vfp_esi_begin(struct busyobj *bo, size_t estimate)
{ {
struct busyobj *bo;
struct vef_priv *vef; struct vef_priv *vef;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
(void)estimate; (void)estimate;
ALLOC_OBJ(vef, VEF_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC);
...@@ -340,13 +339,12 @@ vfp_esi_begin(void *priv, size_t estimate) ...@@ -340,13 +339,12 @@ vfp_esi_begin(void *priv, size_t estimate)
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes) vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
{ {
struct busyobj *bo;
struct vef_priv *vef; struct vef_priv *vef;
int i; int i;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vef = bo->vef_priv; vef = bo->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
...@@ -365,15 +363,14 @@ vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes) ...@@ -365,15 +363,14 @@ vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_esi_end(void *priv) vfp_esi_end(struct busyobj *bo)
{ {
struct busyobj *bo;
struct vsb *vsb; struct vsb *vsb;
struct vef_priv *vef; struct vef_priv *vef;
ssize_t l; ssize_t l;
int retval = 0; int retval = 0;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AN(bo->vep); AN(bo->vep);
if (bo->state == BOS_FAILED) if (bo->state == BOS_FAILED)
......
...@@ -89,11 +89,10 @@ VFP_Error(struct busyobj *bo, const char *error) ...@@ -89,11 +89,10 @@ VFP_Error(struct busyobj *bo, const char *error)
* as seen on the socket, or zero if unknown. * as seen on the socket, or zero if unknown.
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_nop_begin(void *priv, size_t estimate) vfp_nop_begin(struct busyobj *bo, size_t estimate)
{ {
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (estimate > 0) if (estimate > 0)
(void)VFP_GetStorage(bo, estimate); (void)VFP_GetStorage(bo, estimate);
...@@ -111,13 +110,12 @@ vfp_nop_begin(void *priv, size_t estimate) ...@@ -111,13 +110,12 @@ vfp_nop_begin(void *priv, size_t estimate)
*/ */
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes) vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
{ {
ssize_t l, wl; ssize_t l, wl;
struct storage *st; struct storage *st;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
while (bytes > 0) { while (bytes > 0) {
st = VFP_GetStorage(bo, 0); st = VFP_GetStorage(bo, 0);
...@@ -146,23 +144,10 @@ vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes) ...@@ -146,23 +144,10 @@ vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
*/ */
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_nop_end(void *priv) vfp_nop_end(struct busyobj *bo)
{ {
struct storage *st;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); (void)bo;
st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
if (st == NULL)
return (0);
if (st->len == 0) {
VTAILQ_REMOVE(&bo->fetch_obj->store, st, list);
STV_free(st);
return (0);
}
if (st->len < st->space)
STV_trim(st, st->len, 1);
return (0); return (0);
} }
......
...@@ -441,11 +441,10 @@ VGZ_Destroy(struct vgz **vgp) ...@@ -441,11 +441,10 @@ VGZ_Destroy(struct vgz **vgp)
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_gunzip_begin(void *priv, size_t estimate) vfp_gunzip_begin(struct busyobj *bo, size_t estimate)
{ {
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
(void)estimate; (void)estimate;
AZ(bo->vgz_rx); AZ(bo->vgz_rx);
bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -"); bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -");
...@@ -453,16 +452,15 @@ vfp_gunzip_begin(void *priv, size_t estimate) ...@@ -453,16 +452,15 @@ vfp_gunzip_begin(void *priv, size_t estimate)
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
ssize_t l, wl; ssize_t l, wl;
int i = -100; int i = -100;
size_t dl; size_t dl;
const void *dp; const void *dp;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
...@@ -490,12 +488,11 @@ vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) ...@@ -490,12 +488,11 @@ vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_gunzip_end(void *priv) vfp_gunzip_end(struct busyobj *bo)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
bo->vgz_rx = NULL; bo->vgz_rx = NULL;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
...@@ -521,28 +518,26 @@ struct vfp vfp_gunzip = { ...@@ -521,28 +518,26 @@ struct vfp vfp_gunzip = {
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_gzip_begin(void *priv, size_t estimate) vfp_gzip_begin(struct busyobj *bo, size_t estimate)
{ {
(void)estimate; (void)estimate;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
AZ(bo->vgz_rx); AZ(bo->vgz_rx);
bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -"); bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -");
XXXAZ(vgz_getmbuf(bo->vgz_rx)); XXXAZ(vgz_getmbuf(bo->vgz_rx));
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_gzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
ssize_t l, wl; ssize_t l, wl;
int i = -100; int i = -100;
size_t dl; size_t dl;
const void *dp; const void *dp;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
...@@ -567,15 +562,14 @@ vfp_gzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) ...@@ -567,15 +562,14 @@ vfp_gzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_gzip_end(void *priv) vfp_gzip_end(struct busyobj *bo)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
size_t dl; size_t dl;
const void *dp; const void *dp;
int i; int i;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
bo->vgz_rx = NULL; bo->vgz_rx = NULL;
...@@ -610,11 +604,10 @@ struct vfp vfp_gzip = { ...@@ -610,11 +604,10 @@ struct vfp vfp_gzip = {
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_testgzip_begin(void *priv, size_t estimate) vfp_testgzip_begin(struct busyobj *bo, size_t estimate)
{ {
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
(void)estimate; (void)estimate;
bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -"); bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -");
CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC); CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC);
...@@ -622,17 +615,16 @@ vfp_testgzip_begin(void *priv, size_t estimate) ...@@ -622,17 +615,16 @@ vfp_testgzip_begin(void *priv, size_t estimate)
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
ssize_t l, wl; ssize_t l, wl;
int i = -100; int i = -100;
size_t dl; size_t dl;
const void *dp; const void *dp;
struct storage *st; struct storage *st;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
...@@ -666,12 +658,11 @@ vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes) ...@@ -666,12 +658,11 @@ vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_testgzip_end(void *priv) vfp_testgzip_end(struct busyobj *bo)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vg = bo->vgz_rx; vg = bo->vgz_rx;
bo->vgz_rx = NULL; bo->vgz_rx = NULL;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
......
...@@ -384,13 +384,18 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) ...@@ -384,13 +384,18 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo)
} }
AZ(bo->vgz_rx); AZ(bo->vgz_rx);
#if 0
/* /*
* We always call vfp_nop_end() to ditch or trim the last storage * Trim or delete the last segment, if any
* segment, to avoid having to replicate that code in all vfp's.
*/ */
AZ(vfp_nop_end(bo));
#endif st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
if (st != NULL) {
if (st->len == 0) {
VTAILQ_REMOVE(&bo->fetch_obj->store, st, list);
STV_free(st);
} else if (st->len < st->space)
STV_trim(st, st->len, 1);
}
bo->vfp = NULL; bo->vfp = NULL;
......
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