Commit 06d02967 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the VFP_ methods take a "void *priv" rather than a busyobj,

to pave the way for sharing some code on client and backend side.
parent 2592b945
...@@ -268,11 +268,9 @@ struct dstat { ...@@ -268,11 +268,9 @@ struct dstat {
/* Fetch processors --------------------------------------------------*/ /* Fetch processors --------------------------------------------------*/
void VBO_extend(const struct busyobj *, ssize_t); typedef void vfp_begin_f(void *priv, size_t );
typedef int vfp_bytes_f(void *priv, struct http_conn *, ssize_t);
typedef void vfp_begin_f(struct busyobj *, size_t ); typedef int vfp_end_f(void *priv);
typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t);
typedef int vfp_end_f(struct busyobj *);
struct vfp { struct vfp {
vfp_begin_f *begin; vfp_begin_f *begin;
...@@ -787,6 +785,7 @@ void VBO_Init(void); ...@@ -787,6 +785,7 @@ void VBO_Init(void);
struct busyobj *VBO_GetBusyObj(struct worker *, struct req *); struct busyobj *VBO_GetBusyObj(struct worker *, struct req *);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj); void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
void VBO_Free(struct busyobj **vbo); void VBO_Free(struct busyobj **vbo);
void VBO_extend(const struct busyobj *, ssize_t);
/* cache_http1_fsm.c [HTTP1] */ /* cache_http1_fsm.c [HTTP1] */
typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t); typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t);
......
...@@ -296,12 +296,13 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, ...@@ -296,12 +296,13 @@ 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(struct busyobj *bo, size_t estimate) vfp_esi_begin(void *priv, size_t estimate)
{ {
struct busyobj *bo;
struct vef_priv *vef; struct vef_priv *vef;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
(void)estimate; (void)estimate;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
ALLOC_OBJ(vef, VEF_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC);
XXXAN(vef); XXXAN(vef);
...@@ -340,12 +341,13 @@ vfp_esi_begin(struct busyobj *bo, size_t estimate) ...@@ -340,12 +341,13 @@ vfp_esi_begin(struct busyobj *bo, size_t estimate)
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
{ {
struct busyobj *bo;
struct vef_priv *vef; struct vef_priv *vef;
int i; int i;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
vef = bo->vef_priv; vef = bo->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
...@@ -364,14 +366,15 @@ vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) ...@@ -364,14 +366,15 @@ vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_esi_end(struct busyobj *bo) vfp_esi_end(void *priv)
{ {
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;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
AN(bo->vep); AN(bo->vep);
if (bo->state == BOS_FAILED) if (bo->state == BOS_FAILED)
......
...@@ -129,8 +129,11 @@ VFP_End(struct busyobj *bo) ...@@ -129,8 +129,11 @@ VFP_End(struct busyobj *bo)
* 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(struct busyobj *bo, size_t estimate) vfp_nop_begin(void *priv, size_t estimate)
{ {
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
if (estimate > 0) if (estimate > 0)
(void)FetchStorage(bo, estimate); (void)FetchStorage(bo, estimate);
...@@ -148,10 +151,13 @@ vfp_nop_begin(struct busyobj *bo, size_t estimate) ...@@ -148,10 +151,13 @@ vfp_nop_begin(struct busyobj *bo, size_t estimate)
*/ */
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) vfp_nop_bytes(void *priv, 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);
while (bytes > 0) { while (bytes > 0) {
st = FetchStorage(bo, 0); st = FetchStorage(bo, 0);
...@@ -180,10 +186,12 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) ...@@ -180,10 +186,12 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
*/ */
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_nop_end(struct busyobj *bo) vfp_nop_end(void *priv)
{ {
struct storage *st; struct storage *st;
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead); st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
if (st == NULL) if (st == NULL)
return (0); return (0);
......
...@@ -441,25 +441,28 @@ VGZ_Destroy(struct vgz **vgp) ...@@ -441,25 +441,28 @@ VGZ_Destroy(struct vgz **vgp)
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_gunzip_begin(struct busyobj *bo, size_t estimate) vfp_gunzip_begin(void *priv, size_t estimate)
{ {
struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
(void)estimate; (void)estimate;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
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 -");
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_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) vfp_gunzip_bytes(void *priv, 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;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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);
...@@ -487,11 +490,12 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) ...@@ -487,11 +490,12 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_gunzip_end(struct busyobj *bo) vfp_gunzip_end(void *priv)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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);
...@@ -517,26 +521,28 @@ struct vfp vfp_gunzip = { ...@@ -517,26 +521,28 @@ struct vfp vfp_gunzip = {
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_gzip_begin(struct busyobj *bo, size_t estimate) vfp_gzip_begin(void *priv, size_t estimate)
{ {
(void)estimate; (void)estimate;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) vfp_gzip_bytes(void *priv, 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;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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);
...@@ -561,14 +567,15 @@ vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) ...@@ -561,14 +567,15 @@ vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_gzip_end(struct busyobj *bo) vfp_gzip_end(void *priv)
{ {
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;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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;
...@@ -603,9 +610,11 @@ struct vfp vfp_gzip = { ...@@ -603,9 +610,11 @@ struct vfp vfp_gzip = {
*/ */
static void __match_proto__(vfp_begin_f) static void __match_proto__(vfp_begin_f)
vfp_testgzip_begin(struct busyobj *bo, size_t estimate) vfp_testgzip_begin(void *priv, size_t estimate)
{ {
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); struct busyobj *bo;
CAST_OBJ_NOTNULL(bo, priv, 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);
...@@ -613,16 +622,17 @@ vfp_testgzip_begin(struct busyobj *bo, size_t estimate) ...@@ -613,16 +622,17 @@ vfp_testgzip_begin(struct busyobj *bo, size_t estimate)
} }
static int __match_proto__(vfp_bytes_f) static int __match_proto__(vfp_bytes_f)
vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) vfp_testgzip_bytes(void *priv, 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;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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);
...@@ -656,11 +666,12 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) ...@@ -656,11 +666,12 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
} }
static int __match_proto__(vfp_end_f) static int __match_proto__(vfp_end_f)
vfp_testgzip_end(struct busyobj *bo) vfp_testgzip_end(void *priv)
{ {
struct vgz *vg; struct vgz *vg;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, 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);
......
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