w = sp->wrk;
if (sp->obj == NULL) {
HSH_Prealloc(sp);
- sp->obj = sp->wrk->nobj;
+ sp->obj = HSH_NewObject(sp);
sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req;
- sp->wrk->nobj = NULL;
} else {
/* XXX: Null the headers ? */
}
VSL_stats->cache_miss++;
AZ(oc->obj);
- o = sp->wrk->nobj;
- sp->wrk->nobj = NULL;
+ o = HSH_NewObject(sp);
o->objhead = oh;
o->objcore = oc;
assert(sp->handling == VCL_RET_PASS);
sp->acct_req.pass++;
HSH_Prealloc(sp);
- sp->obj = sp->wrk->nobj;
- sp->wrk->nobj = NULL;
+ sp->obj = HSH_NewObject(sp);
sp->sendbody = 1;
sp->step = STP_FETCH;
return (0);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_ORNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
- CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
switch (sp->step) {
default:
WRONG("State engine misfire");
}
- CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
}
WSL_Flush(w, 0);
return (g);
}
+struct object *
+HSH_NewObject(struct sess *sp)
+{
+ struct object *o;
+ struct storage *st;
+
+ st = STV_alloc(sp, params->obj_workspace);
+ XXXAN(st);
+ assert(st->space > sizeof *o);
+ 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;
+ o->http->magic = HTTP_MAGIC;
+ o->refcnt = 1;
+ o->grace = NAN;
+ o->entered = NAN;
+ VTAILQ_INIT(&o->store);
+ VTAILQ_INIT(&o->esibits);
+ sp->wrk->stats->n_object++;
+ return (o);
+}
+
/* Precreate an objhead and object for later use */
void
-HSH_Prealloc(struct sess *sp)
+HSH_Prealloc(const struct sess *sp)
{
struct worker *w;
struct objhead *oh;
struct objcore *oc;
- struct object *o;
- struct storage *st;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
}
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;
- WS_Assert(o->ws_o);
- http_Setup(o->http, o->ws_o);
- o->magic = OBJECT_MAGIC;
- o->http->magic = HTTP_MAGIC;
- o->refcnt = 1;
- o->grace = NAN;
- o->entered = NAN;
- VTAILQ_INIT(&o->store);
- VTAILQ_INIT(&o->esibits);
- w->nobj = o;
- w->stats->n_object++;
-
- }
- CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
}
void
w->nobjhead = NULL;
w->stats->n_objecthead--;
}
- if (w->nobj != NULL) {
- STV_free(w->nobj->objstore);
- w->nobj = NULL;
- w->stats->n_object--;
- }
}
void