[master] 6dfad3d Totally eliminate sp->wrk
Poul-Henning Kamp
phk at varnish-cache.org
Mon Jun 25 10:13:09 CEST 2012
commit 6dfad3d42c9c919d9a82cd5065880e48215e646d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jun 25 08:13:01 2012 +0000
Totally eliminate sp->wrk
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3a8559f..8499a12 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -660,7 +660,6 @@ struct sess {
/* Cross references ------------------------------------------*/
struct sesspool *sesspool;
- struct worker *wrk;
struct req *req;
struct pool_task task;
@@ -926,7 +925,7 @@ unsigned WRW_WriteH(const struct worker *w, const txt *hh, const char *suf);
/* cache_session.c [SES] */
void SES_Close(struct sess *sp, const char *reason);
void SES_Delete(struct sess *sp, const char *reason, double now);
-void SES_Charge(struct sess *sp);
+void SES_Charge(struct worker *, struct sess *);
struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
void SES_DeletePool(struct sesspool *sp);
int SES_Schedule(struct sess *sp);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 1eb397e..bd28916 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -191,7 +191,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
if (when < now || tmo == 0) {
sp->t_rx = NAN;
wrk->stats.sess_herd++;
- SES_Charge(sp);
+ SES_Charge(wrk, sp);
SES_ReleaseReq(sp);
WAIT_Enter(sp);
return (1);
@@ -206,7 +206,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
}
}
}
- SES_Charge(sp);
+ SES_Charge(wrk, sp);
SES_Delete(sp, why, now);
return (1);
}
@@ -360,11 +360,9 @@ CNT_Session(struct worker *wrk, struct sess *sp)
sp->req->req_step == R_STP_START)));
if (sp->sess_step == S_STP_WORKING) {
- done = CNT_Request(sp->wrk, sp->req);
- if (done == 2) {
- sp->wrk = NULL;
+ done = CNT_Request(wrk, sp->req);
+ if (done == 2)
return;
- }
assert(done == 1);
sdr = cnt_sess_done(sp, wrk, sp->req);
switch (sdr) {
@@ -1626,7 +1624,7 @@ CNT_Request(struct worker *wrk, struct req *req)
CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC);
}
if (done == 1)
- SES_Charge(req->sp);
+ SES_Charge(wrk, req->sp);
req->wrk = NULL;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index c6f56e3..d3976d8 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -424,7 +424,7 @@ HSH_Lookup(struct req *req)
if (cache_param->diag_bitmap & 0x20)
VSLb(req->vsl, SLT_Debug,
"on waiting list <%p>", oh);
- SES_Charge(req->sp);
+ SES_Charge(req->wrk, req->sp);
/*
* The objhead reference transfers to the sess, we get it
* back when the sess comes off the waiting list and
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 01b0b18..57ad270 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -61,15 +61,19 @@ struct sesspool {
*/
void
-SES_Charge(struct sess *sp)
+SES_Charge(struct worker *wrk, struct sess *sp)
{
- struct acct *a = &sp->wrk->acct_tmp;
+ struct acct *a;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC);
+
+ a = &wrk->acct_tmp;
sp->req->req_bodybytes += a->bodybytes;
#define ACCT(foo) \
- sp->wrk->stats.s_##foo += a->foo; \
+ wrk->stats.s_##foo += a->foo; \
sp->acct_ses.foo += a->foo; \
a->foo = 0;
#include "tbl/acct_fields.h"
@@ -126,8 +130,6 @@ ses_pool_task(struct worker *wrk, void *arg)
AZ(wrk->aws->r);
wrk->lastused = NAN;
THR_SetSession(sp);
- AZ(sp->wrk);
- sp->wrk = wrk;
CNT_Session(wrk, sp);
sp = NULL; /* Cannot access sp any longer */
THR_SetSession(NULL);
@@ -174,12 +176,10 @@ SES_Schedule(struct sess *sp)
struct sesspool *pp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- AZ(sp->wrk);
pp = sp->sesspool;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
- AZ(sp->wrk);
sp->task.func = ses_pool_task;
sp->task.priv = sp;
@@ -243,7 +243,6 @@ void
SES_Delete(struct sess *sp, const char *reason, double now)
{
struct acct *b;
- struct worker *wrk;
struct sesspool *pp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -251,9 +250,6 @@ SES_Delete(struct sess *sp, const char *reason, double now)
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
- wrk = sp->wrk;
- CHECK_OBJ_ORNULL(wrk, WORKER_MAGIC);
-
if (reason != NULL)
SES_Close(sp, reason);
if (isnan(now))
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index b0f461a..3816a26 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -67,10 +67,8 @@ WAIT_Enter(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
AZ(sp->req);
assert(sp->fd >= 0);
- sp->wrk = NULL;
/*
* Set nonblocking in the worker-thread, before passing to the
More information about the varnish-commit
mailing list