Commit 245ea1da authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Push busyobj out of STV_NewObject()

parent baf85418
......@@ -1216,7 +1216,8 @@ void RFC2616_Weaken_Etag(struct http *hp);
void RFC2616_Vary_AE(struct http *hp);
/* stevedore.c */
int STV_NewObject(struct busyobj *, const char *hint, unsigned len);
int STV_NewObject(struct objcore *, struct vsl_log *, struct dstat *,
const char *hint, unsigned len);
struct storage *STV_alloc(struct stevedore *, size_t size);
void STV_trim(struct storage *st, size_t size, int move_ok);
void STV_free(struct storage *st);
......
......@@ -66,7 +66,8 @@ vbf_allocobj(struct busyobj *bo, unsigned l)
bo->storage_hint = NULL;
if (STV_NewObject(bo, storage_hint, l))
if (STV_NewObject(bo->fetch_objcore, bo->vsl, bo->stats,
storage_hint, l))
return (1);
if (storage_hint != NULL && !strcmp(storage_hint, TRANSIENT_STORAGE))
......@@ -81,7 +82,8 @@ vbf_allocobj(struct busyobj *bo, unsigned l)
oc->exp.ttl = cache_param->shortlived;
oc->exp.grace = 0.0;
oc->exp.keep = 0.0;
return (STV_NewObject(bo, TRANSIENT_STORAGE, l));
return (STV_NewObject(bo->fetch_objcore, bo->vsl, bo->stats,
TRANSIENT_STORAGE, l));
}
/*--------------------------------------------------------------------
......
......@@ -246,27 +246,27 @@ stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
*/
int
STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
STV_NewObject(struct objcore *oc, struct vsl_log *vsl, struct dstat *stats,
const char *hint, unsigned wsl)
{
struct objcore *oc;
struct stevedore *stv, *stv0;
unsigned ltot;
int i, j;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
oc = bo->fetch_objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(vsl);
AN(stats);
assert(wsl > 0);
wsl = PRNDUP(wsl);
ltot = sizeof(struct object) + wsl;
stv = stv0 = stv_pick_stevedore(bo->vsl, &hint);
stv = stv0 = stv_pick_stevedore(vsl, &hint);
AN(stv->allocobj);
j = stv->allocobj(stv, oc, ltot);
if (j == 0 && hint == NULL) {
do {
stv = stv_pick_stevedore(bo->vsl, &hint);
stv = stv_pick_stevedore(vsl, &hint);
AN(stv->allocobj);
j = stv->allocobj(stv, oc, ltot);
} while (j == 0 && stv != stv0);
......@@ -274,7 +274,7 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
if (j == 0) {
/* no luck; try to free some space and keep trying */
for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) {
if (EXP_NukeOne(bo->vsl, bo->stats, stv->lru) == -1)
if (EXP_NukeOne(vsl, stats, stv->lru) == -1)
break;
j = stv->allocobj(stv, oc, ltot);
}
......@@ -283,8 +283,8 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
if (j == 0)
return (0);
bo->stats->n_object++;
VSLb(bo->vsl, SLT_Storage, "%s %s",
stats->n_object++;
VSLb(vsl, SLT_Storage, "%s %s",
oc->stobj->stevedore->name, oc->stobj->stevedore->ident);
return (1);
}
......
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