Commit 9bdc3e0b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Eliminate the per-struct-storage stevedore pointer

parent 2f407d89
......@@ -1093,8 +1093,9 @@ void RFC2616_Vary_AE(struct http *hp);
int STV_NewObject(struct objcore *, struct worker *,
const char *hint, unsigned len);
struct storage *STV_alloc(const struct stevedore *, size_t size);
void STV_trim(struct storage *st, size_t size, int move_ok);
void STV_free(struct storage *st);
void STV_trim(const struct stevedore *, struct storage *, size_t size,
int move_ok);
void STV_free(const struct stevedore *, struct storage *st);
void STV_open(void);
void STV_close(void);
int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
......
......@@ -377,9 +377,9 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
return;
if (st->len == 0) {
VTAILQ_REMOVE(&o->list, st, list);
STV_free(st);
STV_free(stv, st);
} else if (st->len < st->space) {
STV_trim(st, st->len, 1);
STV_trim(stv, st, st->len, 1);
}
}
......@@ -393,6 +393,7 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
void
ObjSlim(struct worker *wrk, struct objcore *oc)
{
const struct stevedore *stv;
struct object *o;
struct storage *st, *stn;
const struct storeobj_methods *om = obj_getmethods(oc);
......@@ -404,17 +405,19 @@ ObjSlim(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
stv = oc->stobj->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
o = obj_getobj(wrk, oc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->esidata != NULL) {
STV_free(o->esidata);
STV_free(stv, o->esidata);
o->esidata = NULL;
}
VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
VTAILQ_REMOVE(&o->list, st, list);
STV_free(st);
STV_free(stv, st);
}
}
......
......@@ -70,11 +70,11 @@ default_oc_freeobj(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
ObjSlim(wrk, oc);
CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
oc->stobj->priv = NULL;
oc->stobj->stevedore = NULL;
o->magic = 0;
STV_free(o->objstore);
STV_free(oc->stobj->stevedore, o->objstore);
memset(oc->stobj, 0, sizeof oc->stobj);
wrk->stats->n_object--;
}
......@@ -291,23 +291,23 @@ STV_NewObject(struct objcore *oc, struct worker *wrk,
/*-------------------------------------------------------------------*/
void
STV_trim(struct storage *st, size_t size, int move_ok)
STV_trim(const struct stevedore *stv, struct storage *st, size_t size,
int move_ok)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
AN(st->stevedore);
if (st->stevedore->trim)
st->stevedore->trim(st, size, move_ok);
}
if (stv->trim)
stv->trim(st, size, move_ok); }
void
STV_free(struct storage *st)
STV_free(const struct stevedore *stv, struct storage *st)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
AN(st->stevedore);
AN(st->stevedore->free);
st->stevedore->free(st);
AN(stv->free);
stv->free(st);
}
void
......
......@@ -48,7 +48,6 @@ struct storage {
VTAILQ_ENTRY(storage) list;
const struct stevedore *stevedore;
void *priv;
unsigned char *ptr;
......
......@@ -468,7 +468,6 @@ smf_alloc(const struct stevedore *st, size_t size)
smf->s.priv = smf;
smf->s.ptr = smf->ptr;
smf->s.len = 0;
smf->s.stevedore = st;
return (&smf->s);
}
......
......@@ -117,7 +117,6 @@ sma_alloc(const struct stevedore *st, size_t size)
sma->s.priv = sma;
sma->s.len = 0;
sma->s.space = size;
sma->s.stevedore = st;
sma->s.magic = STORAGE_MAGIC;
return (&sma->s);
}
......
......@@ -493,7 +493,6 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size,
ss->ptr = PRNUP(sc, ss + 1);
ss->space = max_size;
ss->priv = sc;
ss->stevedore = st;
if (ssg != NULL)
*ssg = sg;
return (ss);
......
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