r4167 - branches/2.0/varnish-cache/bin/varnishd

sky at projects.linpro.no sky at projects.linpro.no
Fri Jul 31 11:12:56 CEST 2009


Author: sky
Date: 2009-07-31 11:12:55 +0200 (Fri, 31 Jul 2009)
New Revision: 4167

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_center.c
   branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
   branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h
Log:
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.

Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-07-30 07:54:37 UTC (rev 4166)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-07-31 09:12:55 UTC (rev 4167)
@@ -307,7 +307,7 @@
 
 	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 @@
 	}
 	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;

Modified: branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-07-30 07:54:37 UTC (rev 4166)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-07-31 09:12:55 UTC (rev 4167)
@@ -82,13 +82,14 @@
 
 /* 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 @@
 		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 @@
 	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 @@
 
 	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)

Modified: branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h	2009-07-30 07:54:37 UTC (rev 4166)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h	2009-07-31 09:12:55 UTC (rev 4167)
@@ -49,7 +49,7 @@
 };
 
 /* 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);



More information about the varnish-commit mailing list