Commit 19409dba authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Push a privat argument back into stevedore.c



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5553 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 218de765
......@@ -804,7 +804,7 @@ ESI_Parse(struct sess *sp)
esi_error(ew, ew->t.e, -1,
"ESI 1.0 unterminated <!--esi comment");
st = STV_alloc(sp, ew->space, sp->obj->objcore);
st = STV_alloc(sp, ew->space);
AN(st);
assert(st->space >= ew->space);
......
......@@ -64,7 +64,7 @@ fetch_straight(const struct sess *sp, struct http_conn *htc, const char *b)
assert((uintmax_t)cl == cll); /* Protect against bogusly large values */
while (cl > 0) {
st = STV_alloc(sp, cl, NULL);
st = STV_alloc(sp, cl);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
sl = st->space;
if (sl > cl)
......@@ -165,7 +165,7 @@ fetch_chunked(const struct sess *sp, struct http_conn *htc)
v = u;
if (u < params->fetch_chunksize * 1024)
v = params->fetch_chunksize * 1024;
st = STV_alloc(sp, v, NULL);
st = STV_alloc(sp, v);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
}
v = st->space - st->len;
......@@ -258,8 +258,7 @@ fetch_eof(const struct sess *sp, struct http_conn *htc)
if (v == 0) {
if (st != NULL && fetchfrag > 0)
dump_st(sp, st);
st = STV_alloc(sp, params->fetch_chunksize * 1024LL,
NULL);
st = STV_alloc(sp, params->fetch_chunksize * 1024LL);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr + st->len;
v = st->space - st->len;
......
......@@ -119,6 +119,51 @@ STV_InitObj(const struct sess *sp, struct object *o, unsigned wsl,
VTAILQ_INIT(&o->store);
sp->wrk->stats.n_object++;
}
/*********************************************************************/
static struct storage *
stv_alloc(const struct sess *sp, size_t size, struct objcore *oc)
{
struct storage *st;
struct stevedore *stv = NULL;
unsigned fail = 0;
/*
* Always try the stevedore which allocated the object in order to
* not needlessly split an object across multiple stevedores.
*/
if (sp->obj != NULL) {
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
if (sp->obj->objstore != NULL) {
stv = sp->obj->objstore->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
}
}
for (;;) {
if (stv == NULL) {
stv = stv_pick_stevedore();
fail = 0;
}
/* try to allocate from it */
AN(stv->alloc);
st = stv->alloc(stv, size, oc);
if (st != NULL)
break;
/* no luck; try to free some space and keep trying */
if (EXP_NukeOne(sp, stv->lru) == -1)
break;
/* Enough is enough: try another if we have one */
if (++fail == 50)
stv = NULL;
}
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
return (st);
}
/*********************************************************************/
......@@ -142,7 +187,7 @@ STV_NewObject(const struct sess *sp, unsigned l, double ttl, unsigned nhttp)
STV_InitObj(sp, o, l, lh, nhttp);
return (o);
}
st = STV_alloc(sp, sizeof *o + l + lh, sp->objcore);
st = stv_alloc(sp, sizeof *o + l + lh, sp->objcore);
XXXAN(st);
xxxassert(st->space >= (sizeof *o + l + lh));
......@@ -161,46 +206,10 @@ STV_NewObject(const struct sess *sp, unsigned l, double ttl, unsigned nhttp)
/*********************************************************************/
struct storage *
STV_alloc(const struct sess *sp, size_t size, struct objcore *oc)
STV_alloc(const struct sess *sp, size_t size)
{
struct storage *st;
struct stevedore *stv = NULL;
unsigned fail = 0;
/*
* Always try the stevedore which allocated the object in order to
* not needlessly split an object across multiple stevedores.
*/
if (sp->obj != NULL) {
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
if (sp->obj->objstore != NULL) {
stv = sp->obj->objstore->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
}
}
for (;;) {
if (stv == NULL) {
stv = stv_pick_stevedore();
fail = 0;
}
/* try to allocate from it */
AN(stv->alloc);
st = stv->alloc(stv, size, oc);
if (st != NULL)
break;
/* no luck; try to free some space and keep trying */
if (EXP_NukeOne(sp, stv->lru) == -1)
break;
/* Enough is enough: try another if we have one */
if (++fail == 50)
stv = NULL;
}
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
return (st);
return (stv_alloc(sp, size, NULL));
}
void
......
......@@ -69,7 +69,7 @@ struct stevedore {
struct object *STV_NewObject(const struct sess *sp, unsigned len, double ttl,
unsigned nhttp);
struct storage *STV_alloc(const struct sess *sp, size_t size, struct objcore *oc);
struct storage *STV_alloc(const struct sess *sp, size_t size);
void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st);
void STV_open(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