Commit 57240f5a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Decontaminate STV_alloc() to not need session

parent 3999568c
......@@ -950,7 +950,8 @@ int RFC2616_Do_Cond(const struct sess *sp);
/* stevedore.c */
struct object *STV_NewObject(struct sess *sp, const char *hint, unsigned len,
struct exp *, uint16_t nhttp);
struct storage *STV_alloc(const struct sess *sp, size_t size);
struct storage *STV_alloc(struct worker *w, const struct object *obj,
size_t size);
void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st);
void STV_open(void);
......
......@@ -368,7 +368,7 @@ vfp_esi_end(struct sess *sp)
l = VSB_len(vsb);
assert(l > 0);
/* XXX: This is a huge waste of storage... */
sp->obj->esidata = STV_alloc(sp, l);
sp->obj->esidata = STV_alloc(sp->wrk, sp->obj, l);
XXXAN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
sp->obj->esidata->len = l;
......
......@@ -159,7 +159,7 @@ FetchStorage(const struct sess *sp, ssize_t sz)
l = sz;
if (l == 0)
l = params->fetch_chunksize * 1024LL;
st = STV_alloc(sp, l);
st = STV_alloc(sp->wrk, sp->obj, l);
if (st == NULL) {
errno = ENOMEM;
return (NULL);
......
......@@ -154,7 +154,7 @@ stv_pick_stevedore(const struct sess *sp, const char **hint)
/*-------------------------------------------------------------------*/
static struct storage *
stv_alloc(const struct sess *sp, size_t size)
stv_alloc(struct worker *w, const struct object *obj, size_t size)
{
struct storage *st;
struct stevedore *stv;
......@@ -164,8 +164,9 @@ stv_alloc(const struct sess *sp, size_t size)
* Always use the stevedore which allocated the object in order to
* keep an object inside the same stevedore.
*/
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
stv = sp->obj->objstore->stevedore;
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
stv = obj->objstore->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
if (size > (size_t)(params->fetch_maxchunksize) << 10)
......@@ -184,7 +185,7 @@ stv_alloc(const struct sess *sp, size_t size)
}
/* no luck; try to free some space and keep trying */
if (EXP_NukeOne(sp->wrk, stv->lru) == -1)
if (EXP_NukeOne(w, stv->lru) == -1)
break;
/* Enough is enough: try another if we have one */
......@@ -370,10 +371,10 @@ STV_Freestore(struct object *o)
/*-------------------------------------------------------------------*/
struct storage *
STV_alloc(const struct sess *sp, size_t size)
STV_alloc(struct worker *w, const struct object *obj, size_t size)
{
return (stv_alloc(sp, size));
return (stv_alloc(w, obj, size));
}
void
......
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