Commit 75b1392b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make sure any halfbaked object is always deallocated when

we hit stp_error and make a new object.
parent c709e110
......@@ -658,17 +658,15 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
vbf_fetch_body_helper(bo);
}
if (bo->vfc->failed && !bo->do_stream) {
assert(bo->state < BOS_STREAM);
ObjFreeObj(bo->wrk, bo->fetch_objcore);
// XXX: doclose = ?
VDI_Finish(bo->wrk, bo);
return (F_STP_ERROR);
}
if (bo->vfc->failed) {
VDI_Finish(bo->wrk, bo);
return (F_STP_FAIL);
if (!bo->do_stream) {
assert(bo->state < BOS_STREAM);
// XXX: doclose = ?
return (F_STP_ERROR);
} else {
return (F_STP_FAIL);
}
}
if (bo->do_stream)
......@@ -775,8 +773,12 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
assert(bo->director_state == DIR_S_NULL);
if(bo->fetch_objcore->stobj->stevedore != NULL)
ObjFreeObj(bo->wrk, bo->fetch_objcore);
now = W_TIM_real(wrk);
VSLb_ts_busyobj(bo, "Error", now);
......@@ -792,10 +794,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
http_TimeHeader(bo->beresp, "Date: ", now);
http_SetHeader(bo->beresp, "Server: Varnish");
EXP_Clr(&bo->fetch_objcore->exp);
bo->fetch_objcore->exp.t_origin = bo->t_prev;
bo->fetch_objcore->exp.ttl = 0;
bo->fetch_objcore->exp.grace = 0;
bo->fetch_objcore->exp.keep = 0;
VCL_backend_error_method(bo->vcl, wrk, NULL, bo, synth_body);
......
......@@ -52,6 +52,7 @@ obj_getmethods(const struct objcore *oc)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(oc->stobj->stevedore);
CHECK_OBJ_NOTNULL(oc->stobj->stevedore, STEVEDORE_MAGIC);
AN(oc->stobj->stevedore->methods);
return (oc->stobj->stevedore->methods);
......@@ -443,6 +444,7 @@ ObjFreeObj(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(m->freeobj);
m->freeobj(wrk, oc);
AZ(oc->stobj->stevedore);
}
/*====================================================================
......
......@@ -508,6 +508,7 @@ smp_oc_freeobj(struct worker *wrk, struct objcore *oc)
}
Lck_Unlock(&sg->sc->mtx);
memset(oc->stobj, 0, sizeof oc->stobj);
}
/*--------------------------------------------------------------------
......
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