Permalink
Browse files

Lift display_name up from vbe to vdi

  • Loading branch information...
bsdphk committed Nov 14, 2017
1 parent a0a3299 commit c39eb640a28746a9704e09c11fca16e4a237cb06
@@ -77,15 +77,15 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
if (!VDI_Healthy(bp->director, NULL)) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: unhealthy", bp->display_name);
"backend %s: unhealthy", bp->director->display_name);
// XXX: per backend stats ?
VSC_C_main->backend_unhealthy++;
return (NULL);
}
if (bp->max_connections > 0 && bp->n_conn >= bp->max_connections) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: busy", bp->display_name);
"backend %s: busy", bp->director->display_name);
// XXX: per backend stats ?
VSC_C_main->backend_busy++;
return (NULL);
@@ -104,7 +104,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
vtp = VTP_Get(bp->tcp_pool, tmod, wrk);
if (vtp == NULL) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: fail", bp->display_name);
"backend %s: fail", bp->director->display_name);
// XXX: Per backend stats ?
VSC_C_main->backend_fail++;
bo->htc = NULL;
@@ -126,7 +126,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
VTCP_myname(vtp->fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
VTCP_hisname(vtp->fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
VSLb(bo->vsl, SLT_BackendOpen, "%d %s %s %s %s %s",
vtp->fd, bp->display_name, abuf2, pbuf2, abuf1, pbuf1);
vtp->fd, bp->director->display_name, abuf2, pbuf2, abuf1, pbuf1);
INIT_OBJ(bo->htc, HTTP_CONN_MAGIC);
bo->htc->priv = vtp;
@@ -169,12 +169,12 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
VTP_Wait(wrk, vtp);
if (bo->htc->doclose != SC_NULL || bp->proxy_header != 0) {
VSLb(bo->vsl, SLT_BackendClose, "%d %s", vtp->fd,
bp->display_name);
bp->director->display_name);
VTP_Close(&vtp);
Lck_Lock(&bp->mtx);
} else {
VSLb(bo->vsl, SLT_BackendReuse, "%d %s", vtp->fd,
bp->display_name);
bp->director->display_name);
Lck_Lock(&bp->mtx);
VSC_C_main->backend_recycle++;
VTP_Recycle(wrk, &vtp);
@@ -318,7 +318,7 @@ vbe_dir_event(const struct director *d, enum vcl_event_e ev)
if (ev == VCL_EVENT_WARM) {
AZ(bp->vsc);
bp->vsc = VSC_vbe_New(bp->display_name);
bp->vsc = VSC_vbe_New(bp->director->display_name);
AN(bp->vsc);
}
@@ -345,7 +345,7 @@ vbe_panic(const struct director *d, struct vsb *vsb)
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC);
VSB_printf(vsb, "display_name = %s,\n", bp->display_name);
VSB_printf(vsb, "display_name = %s,\n", bp->director->display_name);
if (bp->ipv4_addr != NULL)
VSB_printf(vsb, "ipv4 = %s,\n", bp->ipv4_addr);
if (bp->ipv6_addr != NULL)
@@ -58,9 +58,6 @@ struct backend {
VRT_BACKEND_FIELDS()
char *display_name;
struct vbp_target *probe;
struct VSC_vbe *vsc;
@@ -90,7 +87,3 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
void VBP_Remove(struct backend *b);
void VBP_Control(const struct backend *b, int stop);
void VBP_Status(struct cli *cli, const struct backend *, int details);
/* cache_vcl.c */
int VCL_AddBackend(struct vcl *, struct director *);
void VCL_DelBackend(const struct director *);
@@ -108,7 +108,6 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
{
struct backend *b;
struct director *d;
struct vsb *vsb;
struct vcl *vcl;
const struct vrt_backend_probe *vbp;
int retval;
@@ -132,15 +131,6 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
#undef DA
#undef DN
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "%s.%s", VCL_Name(vcl), vrt->vcl_name);
AZ(VSB_finish(vsb));
b->display_name = strdup(VSB_data(vsb));
AN(b->display_name);
VSB_destroy(&vsb);
VBE_fill_director(b);
b->director->health = 1;
@@ -163,7 +153,7 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
VBP_Insert(b, vbp, b->tcp_pool);
}
retval = VCL_AddBackend(ctx->vcl, b->director);
retval = VCL_AddDirector(ctx->vcl, b->director, vrt->vcl_name);
if (retval == 0)
return (b->director);
@@ -242,7 +232,6 @@ VBE_Delete(const struct director *d)
#undef DA
#undef DN
free(be->display_name);
AZ(be->vsc);
Lck_Delete(&be->mtx);
FREE_OBJ(be);
@@ -315,7 +304,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
VTAILQ_FOREACH(b, &backends, list) {
if (b->director->admin_health == vbe_ah_deleted)
continue;
if (fnmatch(VSB_data(vsb), b->display_name, 0))
if (fnmatch(VSB_data(vsb), b->director->display_name, 0))
continue;
found++;
i = func(cli, b, priv);
@@ -342,7 +331,7 @@ do_list(struct cli *cli, struct backend *b, void *priv)
probes = priv;
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
VCLI_Out(cli, "\n%-30s", b->display_name);
VCLI_Out(cli, "\n%-30s", b->director->display_name);
VCLI_Out(cli, " %-10s", VBE_AdminHealth(b->director->admin_health));
@@ -457,7 +446,7 @@ VBE_Poll(void)
if (be->n_conn > 0)
continue;
Lck_Unlock(&backends_mtx);
VCL_DelBackend(be->director);
VCL_DelDirector(be->director);
Lck_Lock(&backends_mtx);
}
Lck_Unlock(&backends_mtx);
@@ -187,7 +187,7 @@ vbp_update_backend(struct vbp_target *vt)
vt->backend->director->health = 0;
}
VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s",
vt->backend->display_name, logmsg, bits,
vt->backend->director->display_name, logmsg, bits,
vt->good, vt->threshold, vt->window,
vt->last, vt->avg, vt->resp_buf);
VBE_SetHappy(vt->backend, vt->happy);
@@ -79,6 +79,7 @@ struct director {
/* Internal Housekeeping fields */
char *display_name;
VTAILQ_ENTRY(director) list;
struct vcl *vcl;
@@ -88,3 +89,7 @@ struct director {
};
unsigned VDI_Healthy(const struct director *, double *);
/* cache_vcl.c */
int VCL_AddDirector(struct vcl *, struct director *, const char *);
void VCL_DelDirector(struct director *);
@@ -327,13 +327,21 @@ VCL_Rel(struct vcl **vcc)
/*--------------------------------------------------------------------*/
int
VCL_AddBackend(struct vcl *vcl, struct director *d)
VCL_AddDirector(struct vcl *vcl, struct director *d, const char *vcl_name)
{
struct vsb *vsb;
CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
AN(d->destroy);
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "%s.%s", VCL_Name(vcl), vcl_name);
AZ(VSB_finish(vsb));
REPLACE((d->display_name), VSB_data(vsb));
VSB_destroy(&vsb);
AZ(errno=pthread_rwlock_rdlock(&vcl->temp_rwl));
if (vcl->temp == VCL_TEMP_COOLING) {
AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
@@ -356,7 +364,7 @@ VCL_AddBackend(struct vcl *vcl, struct director *d)
}
void
VCL_DelBackend(const struct director *d)
VCL_DelDirector(struct director *d)
{
struct vcl *vcl;
@@ -372,6 +380,7 @@ VCL_DelBackend(const struct director *d)
VDI_Event(d, VCL_EVENT_COLD);
AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl));
AN(d->destroy);
REPLACE(d->display_name, NULL);
d->destroy(d);
}

0 comments on commit c39eb64

Please sign in to comment.