void VBE_ClosedFd(struct sess *sp);
void VBE_RecycleFd(struct sess *sp);
struct bereq * VBE_new_bereq(void);
-void VBE_free_bereq(struct bereq *bereq);
+void VBE_free_bereq(struct bereq **bereq);
void VBE_AddHostHeader(const struct sess *sp);
void VBE_Poll(void);
*/
void
-VBE_free_bereq(struct bereq *bereq)
+VBE_free_bereq(struct bereq **bereqp)
{
+ struct bereq *bereq;
+
+ AN(bereqp);
+ bereq = *bereqp;
+ *bereqp = NULL;
CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC);
WS_Reset(bereq->ws, NULL);
RES_WriteObj(sp);
AZ(sp->wrk->wfd);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Deref(&sp->obj);
sp->step = STP_DONE;
return (0);
}
if (i) {
sp->err_code = 503;
sp->step = STP_ERROR;
- VBE_free_bereq(sp->bereq);
- sp->bereq = NULL;
- sp->obj->ttl = 0;
- sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ VBE_free_bereq(&sp->bereq);
+ HSH_Drop(sp);
+ AZ(sp->obj);
return (0);
}
sp->err_code = http_GetStatus(sp->obj->http);
VCL_fetch_method(sp);
- VBE_free_bereq(sp->bereq);
- sp->bereq = NULL;
+ VBE_free_bereq(&sp->bereq);
switch (sp->handling) {
case VCL_RET_RESTART:
- sp->obj->ttl = 0;
- sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Drop(sp);
sp->director = NULL;
sp->restarts++;
sp->step = STP_RECV;
break;
case VCL_RET_ERROR:
sp->step = STP_ERROR;
- sp->obj->ttl = 0;
- sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Drop(sp);
return (0);
default:
WRONG("Illegal action in vcl_fetch{}");
}
/* Drop our object, we won't need it */
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Deref(&sp->obj);
switch(sp->handling) {
case VCL_RET_PASS:
if (sp->obj->pass) {
VSL_stats->cache_hitpass++;
WSP(sp, SLT_HitPass, "%u", sp->obj->xid);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Deref(&sp->obj);
sp->step = STP_PASS;
return (0);
}
http_FilterHeader(sp, HTTPH_R_FETCH);
VCL_miss_method(sp);
+ AZ(sp->obj->cacheable);
switch(sp->handling) {
case VCL_RET_ERROR:
- sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
- VBE_free_bereq(sp->bereq);
- sp->bereq = NULL;
+ HSH_Drop(sp);
+ VBE_free_bereq(&sp->bereq);
sp->step = STP_ERROR;
return (0);
case VCL_RET_PASS:
- sp->obj->cacheable = 0;
- HSH_Unbusy(sp);
- HSH_Deref(sp->obj);
- sp->obj = NULL;
+ HSH_Drop(sp);
+ VBE_free_bereq(&sp->bereq);
sp->step = STP_PASS;
- VBE_free_bereq(sp->bereq);
- sp->bereq = NULL;
return (0);
case VCL_RET_FETCH:
sp->step = STP_FETCH;
VSL_stats->n_expired++;
Lck_Unlock(&exp_mtx);
del_objexp(o);
- HSH_Deref(o);
+ HSH_Deref(&o);
}
}
}
if (sp->handling == VCL_RET_DISCARD) {
WSL(sp->wrk, SLT_ExpKill, 0, "%u LRU", o->xid);
del_objexp(o);
- HSH_Deref(o);
+ HSH_Deref(&o);
return (1);
}
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC);
AN(sp->director);
- assert(sp->obj->busy != 0);
+ AN(sp->obj->busy);
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
}
}
+void
+HSH_Drop(struct sess *sp)
+{
+ struct object *o;
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ o = sp->obj;
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+ assert(o->busy);
+ assert(o->refcnt > 0);
+ o->ttl = 0;
+ o->cacheable = 0;
+ HSH_Unbusy(sp);
+ HSH_Deref(&sp->obj);
+}
+
void
HSH_Unbusy(const struct sess *sp)
{
if (oh != NULL)
Lck_Unlock(&oh->mtx);
if (parent != NULL)
- HSH_Deref(parent);
+ HSH_Deref(&parent);
}
void
}
void
-HSH_Deref(struct object *o)
+HSH_Deref(struct object **oo)
{
+ struct object *o;
struct objhead *oh;
unsigned r;
+ AN(oo);
+ o = *oo;
+ *oo = NULL;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oh = o->objhead;
if (oh != NULL) {
return;
}
- VBE_free_bereq(bereq);
- bereq = NULL;
+ VBE_free_bereq(&bereq);
sp->t_resp = TIM_real();
struct object *HSH_Lookup(struct sess *sp);
void HSH_Unbusy(const struct sess *sp);
void HSH_Ref(struct object *o);
-void HSH_Deref(struct object *o);
+void HSH_Deref(struct object **o);
+void HSH_Drop(struct sess *sp);
double HSH_Grace(double g);
void HSH_Init(void);
void HSH_AddString(struct sess *sp, const char *str);