Commit fda295b7 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Only add size of struct object when using default storeobj_methods

This is to not leak the size of struct object to stevedores that might
have their own cache_obj.c implementation.
parent 6c14014d
......@@ -219,12 +219,14 @@ STV_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr)
int
stv_default_allocobj(const struct stevedore *stv, struct objcore *oc,
unsigned ltot)
unsigned wsl)
{
struct object *o;
struct storage *st;
unsigned ltot;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
ltot = sizeof(struct object) + PRNDUP(wsl);
st = stv->alloc(stv, ltot);
if (st == NULL)
return (0);
......@@ -250,24 +252,20 @@ STV_NewObject(struct objcore *oc, struct worker *wrk,
const char *hint, unsigned wsl)
{
struct stevedore *stv, *stv0;
unsigned ltot;
int i, j;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
assert(wsl > 0);
wsl = PRNDUP(wsl);
ltot = sizeof(struct object) + wsl;
stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint);
AN(stv->allocobj);
j = stv->allocobj(stv, oc, ltot);
j = stv->allocobj(stv, oc, wsl);
if (j == 0 && hint == NULL) {
do {
stv = stv_pick_stevedore(wrk->vsl, &hint);
AN(stv->allocobj);
j = stv->allocobj(stv, oc, ltot);
j = stv->allocobj(stv, oc, wsl);
} while (j == 0 && stv != stv0);
}
if (j == 0) {
......@@ -275,7 +273,7 @@ STV_NewObject(struct objcore *oc, struct worker *wrk,
for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) {
if (EXP_NukeOne(wrk, stv->lru) == -1)
break;
j = stv->allocobj(stv, oc, ltot);
j = stv->allocobj(stv, oc, wsl);
}
}
......
......@@ -502,7 +502,7 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size,
*/
static int
smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned wsl)
{
struct object *o;
struct storage *st;
......@@ -510,6 +510,7 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
struct smp_seg *sg;
struct smp_object *so;
unsigned objidx;
unsigned ltot;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
......@@ -518,6 +519,7 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
if ((oc->exp.ttl + oc->exp.grace + oc->exp.keep) <= 0.)
return (0);
ltot = sizeof(struct object) + PRNDUP(wsl);
ltot = IRNUP(sc, ltot);
st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg);
......
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