Commit ecff5b15 authored by Artur Bergman's avatar Artur Bergman

backport changes from trunk that doesn't allocate transient objects from the...

backport changes from trunk that doesn't allocate transient objects from the store, this means all error requests from recv no longer go through the STV_allocator.

git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@4167 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 85f1e407
......@@ -307,7 +307,7 @@ cnt_error(struct sess *sp)
w = sp->wrk;
if (sp->obj == NULL) {
HSH_Prealloc(sp);
HSH_Prealloc(sp, 1);
sp->obj = sp->wrk->nobj;
sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req;
......@@ -734,7 +734,7 @@ cnt_pass(struct sess *sp)
}
assert(sp->handling == VCL_RET_PASS);
sp->acct_req.pass++;
HSH_Prealloc(sp);
HSH_Prealloc(sp, 0);
sp->obj = sp->wrk->nobj;
sp->wrk->nobj = NULL;
sp->obj->busy = 1;
......
......@@ -82,13 +82,14 @@ HSH_Grace(double g)
/* Precreate an objhead and object for later use */
void
HSH_Prealloc(struct sess *sp)
HSH_Prealloc(struct sess *sp, int transient)
{
struct worker *w;
struct objhead *oh;
struct object *o;
struct storage *st;
void *p;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk;
......@@ -106,16 +107,26 @@ HSH_Prealloc(struct sess *sp)
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
if (w->nobj == NULL) {
st = STV_alloc(sp, params->obj_workspace);
XXXAN(st);
assert(st->space > sizeof *w->nobj);
o = (void *)st->ptr; /* XXX: align ? */
st->len = sizeof *o;
memset(o, 0, sizeof *o);
o->objstore = st;
WS_Init(o->ws_o, "obj",
st->ptr + st->len, st->space - st->len);
st->len = st->space;
if (transient) {
p = malloc(sizeof *o + params->obj_workspace);
XXXAN(p);
o = p;
p = o + 1;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
WS_Init(o->ws_o, "obj", p, params->obj_workspace);
} else {
st = STV_alloc(sp, params->obj_workspace);
XXXAN(st);
assert(st->space > sizeof *w->nobj);
o = (void *)st->ptr; /* XXX: align ? */
st->len = sizeof *o;
memset(o, 0, sizeof *o);
o->objstore = st;
WS_Init(o->ws_o, "obj",
st->ptr + st->len, st->space - st->len);
st->len = st->space;
}
WS_Assert(o->ws_o);
http_Setup(o->http, o->ws_o);
o->magic = OBJECT_MAGIC;
......@@ -239,7 +250,7 @@ HSH_Lookup(struct sess *sp)
AN(hash);
w = sp->wrk;
HSH_Prealloc(sp);
HSH_Prealloc(sp, 0);
SHA256_Final(sp->wrk->nobjhead->digest, sp->wrk->sha256ctx);
if (sp->objhead != NULL) {
......@@ -458,7 +469,11 @@ HSH_Deref(struct object **oo)
ESI_Destroy(o);
HSH_Freestore(o);
STV_free(o->objstore);
if (o->objstore != NULL)
STV_free(o->objstore);
else
FREE_OBJ(o);
VSL_stats->n_object--;
if (oh == NULL)
......
......@@ -49,7 +49,7 @@ struct hash_slinger {
};
/* cache_hash.c */
void HSH_Prealloc(struct sess *sp);
void HSH_Prealloc(struct sess *sp, int transient);
void HSH_Freestore(struct object *o);
void HSH_Copy(const struct sess *sp, struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
......
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