Commit 7d36ca38 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Try to simplify the variable structure around the decision to populate a

busy cache entry or to ditch it.

Ditch it as soon as we can, so we don't hold other clients on a busy objcore
longer than necessary.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4222 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a0313019
...@@ -333,7 +333,8 @@ cnt_error(struct sess *sp) ...@@ -333,7 +333,8 @@ cnt_error(struct sess *sp)
w = sp->wrk; w = sp->wrk;
if (sp->obj == NULL) { if (sp->obj == NULL) {
HSH_Prealloc(sp); HSH_Prealloc(sp);
sp->obj = HSH_NewObject(sp, 1); sp->wrk->cacheable = 0;
sp->obj = HSH_NewObject(sp);
sp->obj->xid = sp->xid; sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req; sp->obj->entered = sp->t_req;
} else { } else {
...@@ -411,7 +412,7 @@ DOT errfetch [label="ERROR",shape=plaintext] ...@@ -411,7 +412,7 @@ DOT errfetch [label="ERROR",shape=plaintext]
static int static int
cnt_fetch(struct sess *sp) cnt_fetch(struct sess *sp)
{ {
int i, transient; int i;
struct http *hp, *hp2; struct http *hp, *hp2;
char *b; char *b;
unsigned handling; unsigned handling;
...@@ -436,10 +437,12 @@ cnt_fetch(struct sess *sp) ...@@ -436,10 +437,12 @@ cnt_fetch(struct sess *sp)
*sp->wrk->beresp1 = *sp->wrk->beresp; *sp->wrk->beresp1 = *sp->wrk->beresp;
if (i) { if (i) {
if (sp->objhead) { if (sp->objcore != NULL) {
CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
HSH_DerefObjCore(sp); HSH_DerefObjCore(sp);
AZ(sp->objhead);
AZ(sp->objcore);
} }
AZ(sp->obj); AZ(sp->obj);
sp->wrk->bereq = NULL; sp->wrk->bereq = NULL;
...@@ -475,7 +478,7 @@ cnt_fetch(struct sess *sp) ...@@ -475,7 +478,7 @@ cnt_fetch(struct sess *sp)
sp->wrk->age = 0; sp->wrk->age = 0;
sp->wrk->ttl = RFC2616_Ttl(sp); sp->wrk->ttl = RFC2616_Ttl(sp);
if (sp->wrk->ttl == 0.) if (sp->objcore == NULL)
sp->wrk->cacheable = 0; sp->wrk->cacheable = 0;
sp->wrk->do_esi = 0; sp->wrk->do_esi = 0;
...@@ -490,23 +493,28 @@ cnt_fetch(struct sess *sp) ...@@ -490,23 +493,28 @@ cnt_fetch(struct sess *sp)
*/ */
handling = sp->handling; handling = sp->handling;
if (sp->objhead == NULL) if (sp->objcore == NULL) {
/* This is a pass from vcl_recv */ /* This is a pass from vcl_recv */
transient = 1; AZ(sp->objhead);
else if (sp->handling == VCL_RET_PASS) sp->wrk->cacheable = 0;
/* A pass from vcl_fetch is not transient */ } else if (!sp->wrk->cacheable) {
transient = 0; if (sp->objhead != NULL)
else if (sp->handling == VCL_RET_DELIVER) HSH_DerefObjCore(sp);
/* Regular object */ }
transient = 0;
else if (sp->wrk->cacheable) {
transient = 1; CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
} else {
AZ(sp->objhead);
AZ(sp->objcore);
}
/* /*
* XXX: If we have a Length: header, we should allocate the body * XXX: If we have a Length: header, we should allocate the body
* XXX: also. * XXX: also.
*/ */
sp->obj = HSH_NewObject(sp, transient); sp->obj = HSH_NewObject(sp);
if (sp->objhead != NULL) { if (sp->objhead != NULL) {
CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
...@@ -558,7 +566,7 @@ cnt_fetch(struct sess *sp) ...@@ -558,7 +566,7 @@ cnt_fetch(struct sess *sp)
return (0); return (0);
} }
if (!transient) if (sp->wrk->cacheable)
HSH_Object(sp); HSH_Object(sp);
if (sp->wrk->do_esi) if (sp->wrk->do_esi)
...@@ -594,7 +602,7 @@ cnt_fetch(struct sess *sp) ...@@ -594,7 +602,7 @@ cnt_fetch(struct sess *sp)
} }
sp->obj->cacheable = 1; sp->obj->cacheable = 1;
if (!transient) { if (sp->wrk->cacheable) {
VRY_Create(sp); VRY_Create(sp);
EXP_Insert(sp->obj); EXP_Insert(sp->obj);
AN(sp->obj->ban); AN(sp->obj->ban);
......
...@@ -82,13 +82,13 @@ HSH_Grace(double g) ...@@ -82,13 +82,13 @@ HSH_Grace(double g)
} }
struct object * struct object *
HSH_NewObject(struct sess *sp, int transient) HSH_NewObject(struct sess *sp)
{ {
struct object *o; struct object *o;
struct storage *st; struct storage *st;
void *p; void *p;
if (transient) { if (!sp->wrk->cacheable) {
p = malloc(sizeof *o + params->obj_workspace); p = malloc(sizeof *o + params->obj_workspace);
XXXAN(p); XXXAN(p);
o = p; o = p;
......
...@@ -50,7 +50,7 @@ struct hash_slinger { ...@@ -50,7 +50,7 @@ struct hash_slinger {
}; };
/* cache_hash.c */ /* cache_hash.c */
struct object *HSH_NewObject(struct sess *sp, int transient); struct object *HSH_NewObject(struct sess *sp);
void HSH_Object(const struct sess *sp); void HSH_Object(const struct sess *sp);
void HSH_Prealloc(const struct sess *sp); void HSH_Prealloc(const struct sess *sp);
void HSH_Cleanup(struct worker *w); void HSH_Cleanup(struct worker *w);
......
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