[master] a34c900 Eliminate some wrk->sp usage.

Poul-Henning Kamp phk at varnish-cache.org
Sun Feb 19 10:04:38 CET 2012


commit a34c900c15f9b751bf18b4ac26b0991e9fbd0d5a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Feb 19 09:04:30 2012 +0000

    Eliminate some wrk->sp usage.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2dd32bf..c9cef7b 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -673,7 +673,7 @@ struct sess {
 void VCA_Init(void);
 void VCA_Shutdown(void);
 int VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa);
-void VCA_SetupSess(struct worker *w);
+void VCA_SetupSess(struct worker *w, struct sess *sp);
 void VCA_FailSess(struct worker *w);
 
 /* cache_backend.c */
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 4d7b771..8848682 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -233,6 +233,7 @@ VCA_FailSess(struct worker *wrk)
 	AZ(close(wa->acceptsock));
 	wrk->stats.sess_drop++;
 	vca_pace_bad();
+	WS_Release(wrk->aws, 0);
 }
 
 /*--------------------------------------------------------------------
@@ -240,15 +241,13 @@ VCA_FailSess(struct worker *wrk)
  */
 
 void
-VCA_SetupSess(struct worker *wrk)
+VCA_SetupSess(struct worker *wrk, struct sess *sp)
 {
-	struct sess *sp;
 	struct wrk_accept *wa;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
-	sp = wrk->sp;
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
 	sp->vxid = wa->vxid;
 	sp->vseq = 0;
 	sp->fd = wa->acceptsock;
@@ -262,6 +261,7 @@ VCA_SetupSess(struct worker *wrk)
 	sp->sockaddrlen = wa->acceptaddrlen;
 	vca_pace_good();
 	wrk->stats.sess_conn++;
+	WS_Release(wrk->aws, 0);
 
 	if (need_test)
 		sock_test(sp->fd);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 9619a6e..bb01b52 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -285,7 +285,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 		if (wrk->busyobj != NULL) {
 			AN(wrk->busyobj->do_stream);
 			VDI_CloseFd(wrk, &wrk->busyobj->vbc);
-			HSH_Drop(wrk);
+			HSH_Drop(wrk, &sp->req->obj);
 			VBO_DerefBusyObj(wrk, &wrk->busyobj);
 		} else {
 			(void)HSH_Deref(&wrk->stats, NULL, &req->obj);
@@ -509,7 +509,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 
 	if (req->handling == VCL_RET_RESTART &&
 	    req->restarts <  cache_param->max_restarts) {
-		HSH_Drop(wrk);
+		HSH_Drop(wrk, &sp->req->obj);
 		VBO_DerefBusyObj(wrk, &wrk->busyobj);
 		req->director = NULL;
 		req->restarts++;
@@ -892,7 +892,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 	AN(req->director);
 
 	if (i) {
-		HSH_Drop(wrk);
+		HSH_Drop(wrk, &sp->req->obj);
 		VBO_DerefBusyObj(wrk, &wrk->busyobj);
 		AZ(req->obj);
 		req->err_code = 503;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 3d44cc4..eff6357 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -577,18 +577,17 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
  */
 
 void
-HSH_Drop(struct worker *wrk)
+HSH_Drop(struct worker *wrk, struct object **oo)
 {
-	struct object *o;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	o = wrk->sp->req->obj;
-	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	AssertObjCorePassOrBusy(o->objcore);
-	o->exp.ttl = -1.;
-	if (o->objcore != NULL)		/* Pass has no objcore */
-		HSH_Unbusy(o->objcore);
-	(void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj);
+	AN(oo);
+	CHECK_OBJ_NOTNULL(*oo, OBJECT_MAGIC);
+	AssertObjCorePassOrBusy((*oo)->objcore);
+	(*oo)->exp.ttl = -1.;
+	if ((*oo)->objcore != NULL)		/* Pass has no objcore */
+		HSH_Unbusy((*oo)->objcore);
+	(void)HSH_Deref(&wrk->stats, NULL, oo);
 }
 
 void
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 15efc5f..542ec2e 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -181,12 +181,11 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
 	wrk->sp = ses_new(pp);
 	if (wrk->sp == NULL) {
 		VCA_FailSess(wrk);
-		return;
+	} else {
+		VCA_SetupSess(wrk, wrk->sp);
+		wrk->sp->step = STP_FIRST;
+		ses_pool_task(wrk, wrk->sp);
 	}
-	VCA_SetupSess(wrk);
-	wrk->sp->step = STP_FIRST;
-	WS_Release(wrk->aws, 0);
-	ses_pool_task(wrk, wrk->sp);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index ac8ce7e..f2b41e2 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -56,7 +56,7 @@ void HSH_Cleanup(struct worker *w);
 struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh);
 void HSH_Unbusy(struct objcore *);
 void HSH_Ref(struct objcore *o);
-void HSH_Drop(struct worker *wrk);
+void HSH_Drop(struct worker *, struct object **);
 void HSH_Init(const struct hash_slinger *slinger);
 void HSH_AddString(const struct sess *sp, const char *str);
 struct objcore *HSH_Insert(const struct sess *sp);



More information about the varnish-commit mailing list