Commit b53d6441 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Rename backend connections to the VTLA "VBC"



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5088 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e6b353b0
......@@ -426,7 +426,7 @@ struct sess {
VTAILQ_ENTRY(sess) list;
struct director *director;
struct vbe_conn *vbe;
struct vbc *vbc;
struct object *obj;
struct objcore *objcore;
struct objhead *objhead;
......@@ -448,10 +448,10 @@ struct sess {
/* -------------------------------------------------------------------*/
/* Backend connection */
struct vbe_conn {
struct vbc {
unsigned magic;
#define VBE_CONN_MAGIC 0x0c5e6592
VTAILQ_ENTRY(vbe_conn) list;
#define VBC_MAGIC 0x0c5e6592
VTAILQ_ENTRY(vbc) list;
struct backend *backend;
int fd;
......@@ -473,7 +473,7 @@ extern pthread_t VCA_thread;
/* cache_backend.c */
struct vbe_conn *VBE_GetFd(const struct director *, struct sess *sp);
struct vbc *VBE_GetFd(const struct director *, struct sess *sp);
int VBE_Healthy(double now, const struct director *, uintptr_t target);
int VBE_Healthy_sp(const struct sess *sp, const struct director *);
void VBE_CloseFd(struct sess *sp);
......
......@@ -49,9 +49,9 @@ SVNID("$Id$")
#include "vrt.h"
/*
* List of cached vbe_conns, used if enabled in params/heritage
* List of cached vbcs, used if enabled in params/heritage
*/
static VTAILQ_HEAD(,vbe_conn) vbe_conns = VTAILQ_HEAD_INITIALIZER(vbe_conns);
static VTAILQ_HEAD(,vbc) vbcs = VTAILQ_HEAD_INITIALIZER(vbcs);
/*--------------------------------------------------------------------
* Create default Host: header for backend request
......@@ -62,29 +62,29 @@ VBE_AddHostHeader(const struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk->bereq, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbe, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbe->backend, BACKEND_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->bereq,
"Host: %s", sp->vbe->backend->hosthdr);
"Host: %s", sp->vbc->backend->hosthdr);
}
/* Private interface from backend_cfg.c */
void
VBE_ReleaseConn(struct vbe_conn *vc)
VBE_ReleaseConn(struct vbc *vc)
{
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(vc, VBC_MAGIC);
assert(vc->backend == NULL);
assert(vc->fd < 0);
if (params->cache_vbe_conns) {
if (params->cache_vbcs) {
Lck_Lock(&VBE_mtx);
VTAILQ_INSERT_HEAD(&vbe_conns, vc, list);
VTAILQ_INSERT_HEAD(&vbcs, vc, list);
VSC_main->backend_unused++;
Lck_Unlock(&VBE_mtx);
} else {
Lck_Lock(&VBE_mtx);
VSC_main->n_vbe_conn--;
VSC_main->n_vbc--;
Lck_Unlock(&VBE_mtx);
free(vc);
}
......@@ -197,23 +197,23 @@ vbe_CheckFd(int fd)
}
/*--------------------------------------------------------------------
* Manage a pool of vbe_conn structures.
* Manage a pool of vbc structures.
* XXX: as an experiment, make this caching controled by a parameter
* XXX: so we can see if it has any effect.
*/
static struct vbe_conn *
static struct vbc *
vbe_NewConn(void)
{
struct vbe_conn *vc;
struct vbc *vc;
vc = VTAILQ_FIRST(&vbe_conns);
vc = VTAILQ_FIRST(&vbcs);
if (vc != NULL) {
Lck_Lock(&VBE_mtx);
vc = VTAILQ_FIRST(&vbe_conns);
vc = VTAILQ_FIRST(&vbcs);
if (vc != NULL) {
VSC_main->backend_unused--;
VTAILQ_REMOVE(&vbe_conns, vc, list);
VTAILQ_REMOVE(&vbcs, vc, list);
}
Lck_Unlock(&VBE_mtx);
}
......@@ -221,10 +221,10 @@ vbe_NewConn(void)
return (vc);
vc = calloc(sizeof *vc, 1);
XXXAN(vc);
vc->magic = VBE_CONN_MAGIC;
vc->magic = VBC_MAGIC;
vc->fd = -1;
Lck_Lock(&VBE_mtx);
VSC_main->n_vbe_conn++;
VSC_main->n_vbc++;
Lck_Unlock(&VBE_mtx);
return (vc);
}
......@@ -312,15 +312,15 @@ vbe_Healthy(double now, uintptr_t target, struct backend *backend)
* Get a connection to a particular backend.
*/
static struct vbe_conn *
static struct vbc *
vbe_GetVbe(struct sess *sp, struct backend *bp)
{
struct vbe_conn *vc;
struct vbc *vc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
/* first look for vbe_conn's we can recycle */
/* first look for vbc's we can recycle */
while (1) {
Lck_Lock(&bp->mtx);
vc = VTAILQ_FIRST(&bp->connlist);
......@@ -341,7 +341,7 @@ vbe_GetVbe(struct sess *sp, struct backend *bp)
return (vc);
}
VSC_main->backend_toolate++;
sp->vbe = vc;
sp->vbc = vc;
VBE_CloseFd(sp);
}
......@@ -378,18 +378,18 @@ VBE_CloseFd(struct sess *sp)
{
struct backend *bp;
CHECK_OBJ_NOTNULL(sp->vbe, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbe->backend, BACKEND_MAGIC);
assert(sp->vbe->fd >= 0);
CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
assert(sp->vbc->fd >= 0);
bp = sp->vbe->backend;
bp = sp->vbc->backend;
WSL(sp->wrk, SLT_BackendClose, sp->vbe->fd, "%s", bp->vcl_name);
TCP_close(&sp->vbe->fd);
WSL(sp->wrk, SLT_BackendClose, sp->vbc->fd, "%s", bp->vcl_name);
TCP_close(&sp->vbc->fd);
VBE_DropRefConn(bp);
sp->vbe->backend = NULL;
VBE_ReleaseConn(sp->vbe);
sp->vbe = NULL;
sp->vbc->backend = NULL;
VBE_ReleaseConn(sp->vbc);
sp->vbc = NULL;
}
/* Recycle a connection ----------------------------------------------*/
......@@ -399,13 +399,13 @@ VBE_RecycleFd(struct sess *sp)
{
struct backend *bp;
CHECK_OBJ_NOTNULL(sp->vbe, VBE_CONN_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbe->backend, BACKEND_MAGIC);
assert(sp->vbe->fd >= 0);
CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
assert(sp->vbc->fd >= 0);
bp = sp->vbe->backend;
bp = sp->vbc->backend;
WSL(sp->wrk, SLT_BackendReuse, sp->vbe->fd, "%s", bp->vcl_name);
WSL(sp->wrk, SLT_BackendReuse, sp->vbc->fd, "%s", bp->vcl_name);
/*
* Flush the shmlog, so that another session reusing this backend
* will log chronologically later than our use of it.
......@@ -413,14 +413,14 @@ VBE_RecycleFd(struct sess *sp)
WSL_Flush(sp->wrk, 0);
Lck_Lock(&bp->mtx);
VSC_main->backend_recycle++;
VTAILQ_INSERT_HEAD(&bp->connlist, sp->vbe, list);
sp->vbe = NULL;
VTAILQ_INSERT_HEAD(&bp->connlist, sp->vbc, list);
sp->vbc = NULL;
VBE_DropRefLocked(bp);
}
/* Get a connection --------------------------------------------------*/
struct vbe_conn *
struct vbc *
VBE_GetFd(const struct director *d, struct sess *sp)
{
......@@ -554,11 +554,11 @@ vdi_get_backend_if_simple(const struct director *d)
return vs->backend;
}
static struct vbe_conn *
static struct vbc *
vdi_simple_getfd(const struct director *d, struct sess *sp)
{
struct vdi_simple *vs;
struct vbe_conn *vc;
struct vbc *vc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
......
......@@ -38,10 +38,10 @@
* A backend is a TCP destination, possibly multi-homed and it has a
* number of associated properties and statistics.
*
* A vbe_conn is an open TCP connection to a backend.
* A vbc is an open TCP connection to a backend.
*
* A bereq is a memory carrier for handling a HTTP transaction with
* a backend over a vbe_conn.
* a backend over a vbc.
*
* A director is a piece of code that selects which backend to use,
* by whatever method or metric it chooses.
......@@ -53,7 +53,7 @@
*
* When a VCL tries to instantiate a backend, any existing backend
* with the same identity (== definition in VCL) will be used instead
* so that vbe_conn's can be reused across VCL changes.
* so that vbc's can be reused across VCL changes.
*
* Directors disapper with the VCL that created them.
*
......@@ -69,7 +69,7 @@
*/
struct vbp_target;
struct vbe_conn;
struct vbc;
struct vrt_backend_probe;
/*--------------------------------------------------------------------
......@@ -77,7 +77,7 @@ struct vrt_backend_probe;
* backends to use.
*/
typedef struct vbe_conn *vdi_getfd_f(const struct director *, struct sess *sp);
typedef struct vbc *vdi_getfd_f(const struct director *, struct sess *sp);
typedef void vdi_fini_f(struct director *);
typedef unsigned vdi_healthy(double now, const struct director *,
uintptr_t target);
......@@ -133,7 +133,7 @@ struct backend {
unsigned max_conn;
unsigned n_conn;
VTAILQ_HEAD(, vbe_conn) connlist;
VTAILQ_HEAD(, vbc) connlist;
struct vbp_target *probe;
unsigned healthy;
......@@ -142,7 +142,7 @@ struct backend {
};
/* cache_backend.c */
void VBE_ReleaseConn(struct vbe_conn *vc);
void VBE_ReleaseConn(struct vbc *vc);
struct backend *vdi_get_backend_if_simple(const struct director *d);
/* cache_backend_cfg.c */
......
......@@ -101,7 +101,7 @@ void
VBE_DropRefLocked(struct backend *b)
{
int i;
struct vbe_conn *vbe, *vbe2;
struct vbc *vbe, *vbe2;
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
assert(b->refcount > 0);
......
......@@ -229,7 +229,7 @@ cnt_done(struct sess *sp)
CHECK_OBJ_ORNULL(sp->vcl, VCL_CONF_MAGIC);
AZ(sp->obj);
AZ(sp->vbe);
AZ(sp->vbc);
sp->director = NULL;
sp->restarts = 0;
......@@ -432,7 +432,7 @@ cnt_fetch(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
AN(sp->director);
AZ(sp->vbe);
AZ(sp->vbc);
/* sp->wrk->http[0] is (still) bereq */
sp->wrk->beresp = sp->wrk->http[1];
......@@ -592,7 +592,7 @@ cnt_fetch(struct sess *sp)
i = FetchBody(sp);
AZ(sp->wrk->wfd);
AZ(sp->vbe);
AZ(sp->vbc);
AN(sp->director);
if (i) {
......
......@@ -135,7 +135,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
SZOF(struct objcore);
SZOF(struct objhead);
SZOF(struct sess);
SZOF(struct vbe_conn);
SZOF(struct vbc);
SZOF(struct vsc_main);
SZOF(struct lock);
}
......
......@@ -383,12 +383,12 @@ vdi_dns_find_backend(const struct sess *sp, struct vdi_dns *vs)
return ret;
}
static struct vbe_conn *
static struct vbc *
vdi_dns_getfd(const struct director *director, struct sess *sp)
{
struct vdi_dns *vs;
struct director *dir;
struct vbe_conn *vbe;
struct vbc *vbe;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(director, DIRECTOR_MAGIC);
......
......@@ -80,14 +80,14 @@ struct vdi_random {
unsigned nhosts;
};
static struct vbe_conn *
static struct vbc *
vdi_random_getfd(const struct director *d, struct sess *sp)
{
int i, k;
struct vdi_random *vs;
double r, s1;
unsigned u = 0;
struct vbe_conn *vbe;
struct vbc *vbe;
struct director *d2;
struct SHA256Context ctx;
uint8_t sign[SHA256_LEN], *hp;
......
......@@ -59,13 +59,13 @@ struct vdi_round_robin {
unsigned next_host;
};
static struct vbe_conn *
static struct vbc *
vdi_round_robin_getfd(const struct director *d, struct sess *sp)
{
int i;
struct vdi_round_robin *vs;
struct director *backend;
struct vbe_conn *vbe;
struct vbc *vbe;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
......
......@@ -329,7 +329,7 @@ FetchReqBody(struct sess *sp)
int
FetchHdr(struct sess *sp)
{
struct vbe_conn *vc;
struct vbc *vc;
struct worker *w;
char *b;
struct http *hp;
......@@ -351,12 +351,12 @@ FetchHdr(struct sess *sp)
w = sp->wrk;
hp = sp->wrk->bereq;
sp->vbe = VBE_GetFd(NULL, sp);
if (sp->vbe == NULL) {
sp->vbc = VBE_GetFd(NULL, sp);
if (sp->vbc == NULL) {
WSP(sp, SLT_FetchError, "no backend connection");
return (__LINE__);
}
vc = sp->vbe;
vc = sp->vbc;
/*
* Now that we know our backend, we can set a default Host:
......@@ -424,7 +424,7 @@ FetchHdr(struct sess *sp)
int
FetchBody(struct sess *sp)
{
struct vbe_conn *vc;
struct vbc *vc;
char *b;
int cls;
struct http *hp;
......@@ -442,7 +442,7 @@ FetchBody(struct sess *sp)
if (sp->obj->objcore != NULL) /* pass has no objcore */
AN(ObjIsBusy(sp->obj));
vc = sp->vbe;
vc = sp->vbc;
is_head = (strcasecmp(http_GetReq(sp->wrk->bereq), "head") == 0);
......@@ -520,7 +520,7 @@ FetchBody(struct sess *sp)
return (__LINE__);
}
WSL(sp->wrk, SLT_Length, sp->vbe->fd, "%u", sp->obj->len);
WSL(sp->wrk, SLT_Length, sp->vbc->fd, "%u", sp->obj->len);
{
/* Sanity check fetch methods accounting */
......
......@@ -89,14 +89,14 @@ pan_ws(const struct ws *ws, int indent)
/*--------------------------------------------------------------------*/
static void
pan_vbe(const struct vbe_conn *vbe)
pan_vbc(const struct vbc *vbc)
{
struct backend *be;
be = vbe->backend;
be = vbc->backend;
vsb_printf(vsp, " backend = %p fd = %d {\n", be, vbe->fd);
vsb_printf(vsp, " backend = %p fd = %d {\n", be, vbc->fd);
vsb_printf(vsp, " vcl_name = \"%s\",\n", be->vcl_name);
vsb_printf(vsp, " },\n");
}
......@@ -252,8 +252,8 @@ pan_sess(const struct sess *sp)
if (VALID_OBJ(sp->vcl, VCL_CONF_MAGIC))
pan_vcl(sp->vcl);
if (VALID_OBJ(sp->vbe, BACKEND_MAGIC))
pan_vbe(sp->vbe);
if (VALID_OBJ(sp->vbc, BACKEND_MAGIC))
pan_vbc(sp->vbc);
if (VALID_OBJ(sp->obj, OBJECT_MAGIC))
pan_object(sp->obj);
......
......@@ -65,7 +65,7 @@ rdf(int fd0, int fd1)
void
PipeSession(struct sess *sp)
{
struct vbe_conn *vc;
struct vbc *vc;
struct worker *w;
struct pollfd fds[2];
int i;
......@@ -74,10 +74,10 @@ PipeSession(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk;
sp->vbe = VBE_GetFd(NULL, sp);
if (sp->vbe == NULL)
sp->vbc = VBE_GetFd(NULL, sp);
if (sp->vbc == NULL)
return;
vc = sp->vbe;
vc = sp->vbc;
(void)TCP_blocking(vc->fd);
WRW_Reserve(w, &vc->fd);
......
......@@ -293,12 +293,12 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
struct trouble *tr2;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (!sp->vbe)
if (!sp->vbc)
return;
CHECK_OBJ_NOTNULL(sp->vbe, VBE_CONN_MAGIC);
if (!sp->vbe->backend)
CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC);
if (!sp->vbc->backend)
return;
CHECK_OBJ_NOTNULL(sp->vbe->backend, BACKEND_MAGIC);
CHECK_OBJ_NOTNULL(sp->vbc->backend, BACKEND_MAGIC);
if (!sp->objhead)
return;
CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
......@@ -317,8 +317,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->vbe->backend->mtx);
VTAILQ_FOREACH_SAFE(tr, &sp->vbe->backend->troublelist, list, tr2) {
Lck_Lock(&sp->vbc->backend->mtx);
VTAILQ_FOREACH_SAFE(tr, &sp->vbc->backend->troublelist, list, tr2) {
if (tr->timeout < new->timeout) {
VTAILQ_INSERT_BEFORE(tr, new, list);
new = NULL;
......@@ -330,9 +330,9 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
* items have a longer timeout.
*/
if (new)
VTAILQ_INSERT_TAIL(&sp->vbe->backend->troublelist, new, list);
VTAILQ_INSERT_TAIL(&sp->vbc->backend->troublelist, new, list);
Lck_Unlock(&sp->vbe->backend->mtx);
Lck_Unlock(&sp->vbc->backend->mtx);
}
int
......
......@@ -144,8 +144,8 @@ struct params {
/* Rush exponent */
unsigned rush_exponent;
/* Cache vbe_conns */
unsigned cache_vbe_conns;
/* Cache vbcs */
unsigned cache_vbcs;
/* Default connection_timeout */
double connect_timeout;
......
......@@ -655,8 +655,8 @@ static const struct parspec input_parspec[] = {
"Maximum depth of esi:include processing.\n",
0,
"5", "includes" },
{ "cache_vbe_conns", tweak_bool, &master.cache_vbe_conns, 0, 0,
"Cache vbe_conn's or rely on malloc, that's the question.",
{ "cache_vbcs", tweak_bool, &master.cache_vbcs, 0, 0,
"Cache vbc's or rely on malloc, that's the question.",
EXPERIMENTAL,
"off", "bool" },
{ "connect_timeout", tweak_timeout_double,
......
......@@ -75,7 +75,7 @@ MAC_STAT(n_objecthead, uint64_t, 1, 'i', "N struct objecthead")
MAC_STAT(n_smf, uint64_t, 0, 'i', "N struct smf")
MAC_STAT(n_smf_frag, uint64_t, 0, 'i', "N small free smf")
MAC_STAT(n_smf_large, uint64_t, 0, 'i', "N large free smf")
MAC_STAT(n_vbe_conn, uint64_t, 0, 'i', "N struct vbe_conn")
MAC_STAT(n_vbc, uint64_t, 0, 'i', "N struct vbc")
MAC_STAT(n_wrk, uint64_t, 0, 'i', "N worker threads")
MAC_STAT(n_wrk_create, uint64_t, 0, 'a', "N worker threads created")
MAC_STAT(n_wrk_failed, uint64_t, 0, 'a',
......
......@@ -76,7 +76,7 @@ VSC_F_MAIN(n_objecthead, uint64_t, 1, 'i', "N struct objecthead")
VSC_F_MAIN(n_smf, uint64_t, 0, 'i', "N struct smf")
VSC_F_MAIN(n_smf_frag, uint64_t, 0, 'i', "N small free smf")
VSC_F_MAIN(n_smf_large, uint64_t, 0, 'i', "N large free smf")
VSC_F_MAIN(n_vbe_conn, uint64_t, 0, 'i', "N struct vbe_conn")
VSC_F_MAIN(n_vbc, uint64_t, 0, 'i', "N struct vbc")
VSC_F_MAIN(n_wrk, uint64_t, 0, 'i', "N worker threads")
VSC_F_MAIN(n_wrk_create, uint64_t, 0, 'a', "N worker threads created")
VSC_F_MAIN(n_wrk_failed, uint64_t, 0, 'a',
......
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