[master] 8c80f86 Move the vbc structure from session to worker
Poul-Henning Kamp
phk at varnish-cache.org
Mon Oct 24 14:08:56 CEST 2011
commit 8c80f8649476d9226e68a3b4ffa28310bc280c94
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 24 12:08:37 2011 +0000
Move the vbc structure from session to worker
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 018355e..59d5fa8 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -338,6 +338,7 @@ struct worker {
const char *storage_hint;
/* Fetch stuff */
+ struct vbc *vbc;
enum body_status body_status;
struct vfp *vfp;
struct vgz *vgz_rx;
@@ -606,7 +607,6 @@ struct sess {
VTAILQ_ENTRY(sess) list;
struct director *director;
- struct vbc *vbc;
struct object *obj;
struct objcore *objcore;
struct VCL_conf *vcl;
@@ -641,8 +641,8 @@ void VBE_UseHealth(const struct director *vdi);
struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
int VDI_Healthy(const struct director *, const struct sess *sp);
-void VDI_CloseFd(struct sess *sp);
-void VDI_RecycleFd(struct sess *sp);
+void VDI_CloseFd(struct worker *wrk);
+void VDI_RecycleFd(struct worker *wrk);
void VDI_AddHostHeader(const struct sess *sp);
void VBE_Poll(void);
diff --git a/bin/varnishd/cache_backend.c b/bin/varnishd/cache_backend.c
index 0026259..7bacd26 100644
--- a/bin/varnishd/cache_backend.c
+++ b/bin/varnishd/cache_backend.c
@@ -64,10 +64,10 @@ VDI_AddHostHeader(const struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk->bereq, HTTP_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc->vdis, VDI_SIMPLE_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->wrk->vbc, VBC_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->wrk->vbc->vdis, VDI_SIMPLE_MAGIC);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->bereq,
- "Host: %s", sp->vbc->vdis->vrt->hosthdr);
+ "Host: %s", sp->wrk->vbc->vdis->vrt->hosthdr);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index d60f17e..243123d 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -227,7 +227,7 @@ cnt_prepresp(struct sess *sp)
if (sp->restarts >= params->max_restarts)
break;
if (sp->wrk->do_stream) {
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
HSH_Drop(sp);
} else {
(void)HSH_Deref(sp->wrk, NULL, &sp->obj);
@@ -305,7 +305,7 @@ cnt_done(struct sess *sp)
CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC);
AZ(sp->obj);
- AZ(sp->vbc);
+ AZ(sp->wrk->vbc);
sp->director = NULL;
sp->restarts = 0;
@@ -537,7 +537,7 @@ cnt_fetch(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AN(sp->director);
- AZ(sp->vbc);
+ AZ(sp->wrk->vbc);
AZ(sp->wrk->h_content_length);
AZ(sp->wrk->do_close);
AZ(sp->wrk->storage_hint);
@@ -606,11 +606,11 @@ cnt_fetch(struct sess *sp)
}
/* We are not going to fetch the body, Close the connection */
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
}
/* Clean up partial fetch */
- AZ(sp->vbc);
+ AZ(sp->wrk->vbc);
if (sp->objcore != NULL) {
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
@@ -788,7 +788,7 @@ cnt_fetchbody(struct sess *sp)
if (sp->obj == NULL) {
sp->err_code = 503;
sp->step = STP_ERROR;
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
return (0);
}
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
@@ -854,7 +854,7 @@ cnt_fetchbody(struct sess *sp)
http_Setup(sp->wrk->beresp, NULL);
sp->wrk->vfp = NULL;
assert(WRW_IsReleased(sp->wrk));
- AZ(sp->vbc);
+ AZ(sp->wrk->vbc);
AN(sp->director);
if (i) {
@@ -917,7 +917,7 @@ cnt_streambody(struct sess *sp)
http_Setup(sp->wrk->bereq, NULL);
http_Setup(sp->wrk->beresp, NULL);
sp->wrk->vfp = NULL;
- AZ(sp->vbc);
+ AZ(sp->wrk->vbc);
AN(sp->director);
if (!i && sp->obj->objcore != NULL) {
diff --git a/bin/varnishd/cache_dir.c b/bin/varnishd/cache_dir.c
index 3fd0475..e95b015 100644
--- a/bin/varnishd/cache_dir.c
+++ b/bin/varnishd/cache_dir.c
@@ -40,54 +40,54 @@
/* Close a connection ------------------------------------------------*/
void
-VDI_CloseFd(struct sess *sp)
+VDI_CloseFd(struct worker *wrk)
{
struct backend *bp;
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
- assert(sp->vbc->fd >= 0);
+ CHECK_OBJ_NOTNULL(wrk->vbc, VBC_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk->vbc->backend, BACKEND_MAGIC);
+ assert(wrk->vbc->fd >= 0);
- bp = sp->vbc->backend;
+ bp = wrk->vbc->backend;
- WSL(sp->wrk, SLT_BackendClose, sp->vbc->vsl_id, "%s", bp->vcl_name);
+ WSL(wrk, SLT_BackendClose, wrk->vbc->vsl_id, "%s", bp->vcl_name);
/* Checkpoint log to flush all info related to this connection
before the OS reuses the FD */
- WSL_Flush(sp->wrk, 0);
+ WSL_Flush(wrk, 0);
- VTCP_close(&sp->vbc->fd);
+ VTCP_close(&wrk->vbc->fd);
VBE_DropRefConn(bp);
- sp->vbc->backend = NULL;
- VBE_ReleaseConn(sp->vbc);
- sp->vbc = NULL;
- sp->wrk->do_close = 0;
+ wrk->vbc->backend = NULL;
+ VBE_ReleaseConn(wrk->vbc);
+ wrk->vbc = NULL;
+ wrk->do_close = 0;
}
/* Recycle a connection ----------------------------------------------*/
void
-VDI_RecycleFd(struct sess *sp)
+VDI_RecycleFd(struct worker *wrk)
{
struct backend *bp;
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
- assert(sp->vbc->fd >= 0);
- AZ(sp->wrk->do_close);
+ CHECK_OBJ_NOTNULL(wrk->vbc, VBC_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk->vbc->backend, BACKEND_MAGIC);
+ assert(wrk->vbc->fd >= 0);
+ AZ(wrk->do_close);
- bp = sp->vbc->backend;
+ bp = wrk->vbc->backend;
- WSL(sp->wrk, SLT_BackendReuse, sp->vbc->vsl_id, "%s", bp->vcl_name);
+ WSL(wrk, SLT_BackendReuse, wrk->vbc->vsl_id, "%s", bp->vcl_name);
/*
* Flush the shmlog, so that another session reusing this backend
* will log chronologically later than our use of it.
*/
- WSL_Flush(sp->wrk, 0);
+ WSL_Flush(wrk, 0);
Lck_Lock(&bp->mtx);
VSC_C_main->backend_recycle++;
- VTAILQ_INSERT_HEAD(&bp->connlist, sp->vbc, list);
- sp->vbc = NULL;
+ VTAILQ_INSERT_HEAD(&bp->connlist, wrk->vbc, list);
+ wrk->vbc = NULL;
VBE_DropRefLocked(bp);
}
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 71fc8e2..ba91720 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -394,12 +394,12 @@ FetchHdr(struct sess *sp)
hp = w->bereq;
- sp->vbc = VDI_GetFd(NULL, sp);
- if (sp->vbc == NULL) {
+ sp->wrk->vbc = VDI_GetFd(NULL, sp);
+ if (sp->wrk->vbc == NULL) {
WSP(sp, SLT_FetchError, "no backend connection");
return (-1);
}
- vc = sp->vbc;
+ vc = sp->wrk->vbc;
if (vc->recycled)
retry = 1;
@@ -420,7 +420,7 @@ FetchHdr(struct sess *sp)
if (WRW_FlushRelease(w) || i > 0) {
WSP(sp, SLT_FetchError, "backend write error: %d (%s)",
errno, strerror(errno));
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
/* XXX: other cleanup ? */
return (retry);
}
@@ -443,7 +443,7 @@ FetchHdr(struct sess *sp)
if (i < 0) {
WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)",
i, errno, w->htc->error);
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
/* XXX: other cleanup ? */
/* Retryable if we never received anything */
return (i == -1 ? retry : -1);
@@ -457,7 +457,7 @@ FetchHdr(struct sess *sp)
WSP(sp, SLT_FetchError,
"http first read error: %d %d (%s)",
i, errno, w->htc->error);
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
/* XXX: other cleanup ? */
return (-1);
}
@@ -467,7 +467,7 @@ FetchHdr(struct sess *sp)
if (http_DissectResponse(w, w->htc, hp)) {
WSP(sp, SLT_FetchError, "http format error");
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
/* XXX: other cleanup ? */
return (-1);
}
@@ -541,12 +541,12 @@ FetchBody(struct sess *sp)
*/
AZ(vfp_nop_end(sp));
- WSL(w, SLT_Fetch_Body, sp->vbc->vsl_id, "%u(%s) cls %d mklen %u",
+ WSL(w, SLT_Fetch_Body, sp->wrk->vbc->vsl_id, "%u(%s) cls %d mklen %u",
w->body_status, body_status(w->body_status),
cls, mklen);
if (w->body_status == BS_ERROR) {
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
return (__LINE__);
}
@@ -558,7 +558,7 @@ FetchBody(struct sess *sp)
VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
sp->obj->len = 0;
return (__LINE__);
}
@@ -566,7 +566,7 @@ FetchBody(struct sess *sp)
if (cls == 0 && w->do_close)
cls = 1;
- WSL(w, SLT_Length, sp->vbc->vsl_id, "%u", sp->obj->len);
+ WSL(w, SLT_Length, sp->wrk->vbc->vsl_id, "%u", sp->obj->len);
{
/* Sanity check fetch methods accounting */
@@ -589,9 +589,9 @@ FetchBody(struct sess *sp)
}
if (cls)
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
else
- VDI_RecycleFd(sp);
+ VDI_RecycleFd(sp->wrk);
return (0);
}
diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c
index 76ea866..231adf1 100644
--- a/bin/varnishd/cache_panic.c
+++ b/bin/varnishd/cache_panic.c
@@ -263,8 +263,8 @@ pan_sess(const struct sess *sp)
if (VALID_OBJ(sp->vcl, VCL_CONF_MAGIC))
pan_vcl(sp->vcl);
- if (VALID_OBJ(sp->vbc, BACKEND_MAGIC))
- pan_vbc(sp->vbc);
+ if (VALID_OBJ(sp->wrk->vbc, BACKEND_MAGIC))
+ pan_vbc(sp->wrk->vbc);
if (VALID_OBJ(sp->obj, OBJECT_MAGIC))
pan_object(sp->obj);
diff --git a/bin/varnishd/cache_pipe.c b/bin/varnishd/cache_pipe.c
index 8f109a5..31dcf1a 100644
--- a/bin/varnishd/cache_pipe.c
+++ b/bin/varnishd/cache_pipe.c
@@ -71,10 +71,10 @@ PipeSession(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk;
- sp->vbc = VDI_GetFd(NULL, sp);
- if (sp->vbc == NULL)
+ sp->wrk->vbc = VDI_GetFd(NULL, sp);
+ if (sp->wrk->vbc == NULL)
return;
- vc = sp->vbc;
+ vc = sp->wrk->vbc;
(void)VTCP_blocking(vc->fd);
WRW_Reserve(w, &vc->fd);
@@ -89,7 +89,7 @@ PipeSession(struct sess *sp)
if (i) {
SES_Close(sp, "pipe");
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
return;
}
@@ -129,5 +129,5 @@ PipeSession(struct sess *sp)
}
}
SES_Close(sp, "pipe");
- VDI_CloseFd(sp);
+ VDI_CloseFd(sp->wrk);
}
diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c
index 1a16e16..92d8451 100644
--- a/bin/varnishd/cache_vrt_var.c
+++ b/bin/varnishd/cache_vrt_var.c
@@ -130,14 +130,16 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
struct trouble *new;
struct trouble *tr;
struct trouble *tr2;
+ struct worker *wrk;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (!sp->vbc)
+ wrk = sp->wrk;
+ if (!wrk->vbc)
return;
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- if (!sp->vbc->backend)
+ CHECK_OBJ_NOTNULL(wrk->vbc, VBC_MAGIC);
+ if (!wrk->vbc->backend)
return;
- CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk->vbc->backend, BACKEND_MAGIC);
if (!sp->objcore)
return;
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
@@ -156,8 +158,8 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
* timeout at a later date (ie: sort by which entry will time out
* from the list
*/
- Lck_Lock(&sp->vbc->backend->mtx);
- VTAILQ_FOREACH_SAFE(tr, &sp->vbc->backend->troublelist, list, tr2) {
+ Lck_Lock(&wrk->vbc->backend->mtx);
+ VTAILQ_FOREACH_SAFE(tr, &wrk->vbc->backend->troublelist, list, tr2) {
if (tr->timeout < new->timeout) {
VTAILQ_INSERT_BEFORE(tr, new, list);
new = NULL;
@@ -169,9 +171,9 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
* items have a longer timeout.
*/
if (new)
- VTAILQ_INSERT_TAIL(&sp->vbc->backend->troublelist, new, list);
+ VTAILQ_INSERT_TAIL(&wrk->vbc->backend->troublelist, new, list);
- Lck_Unlock(&sp->vbc->backend->mtx);
+ Lck_Unlock(&wrk->vbc->backend->mtx);
}
/*--------------------------------------------------------------------*/
@@ -250,8 +252,8 @@ VRT_r_beresp_backend_name(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- return(sp->vbc->backend->vcl_name);
+ CHECK_OBJ_NOTNULL(sp->wrk->vbc, VBC_MAGIC);
+ return(sp->wrk->vbc->backend->vcl_name);
}
struct sockaddr_storage *
@@ -259,8 +261,8 @@ VRT_r_beresp_backend_ip(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- return(sp->vbc->addr);
+ CHECK_OBJ_NOTNULL(sp->wrk->vbc, VBC_MAGIC);
+ return(sp->wrk->vbc->addr);
}
int
@@ -268,8 +270,8 @@ VRT_r_beresp_backend_port(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
- return (VTCP_port(sp->vbc->addr));
+ CHECK_OBJ_NOTNULL(sp->wrk->vbc, VBC_MAGIC);
+ return (VTCP_port(sp->wrk->vbc->addr));
}
const char * __match_proto__()
More information about the varnish-commit
mailing list