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

Lock the backend tcp-pools under the backends_mtx, rather than the

(implicit) CLI lock.
parent 7585d89a
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
static VTAILQ_HEAD(, backend) backends = VTAILQ_HEAD_INITIALIZER(backends); static VTAILQ_HEAD(, backend) backends = VTAILQ_HEAD_INITIALIZER(backends);
static struct lock backends_mtx; static struct lock backends_mtx;
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* Create/Delete a new director::backend instance. * Create/Delete a new director::backend instance.
*/ */
...@@ -59,6 +60,7 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) ...@@ -59,6 +60,7 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
struct backend *b; struct backend *b;
char buf[128]; char buf[128];
struct vcl *vcl; struct vcl *vcl;
struct tcp_pool *tp = NULL;
const struct vrt_backend_probe *vbp; const struct vrt_backend_probe *vbp;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
...@@ -87,25 +89,28 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) ...@@ -87,25 +89,28 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
b->vcl = vcl; b->vcl = vcl;
b->tcp_pool = VBT_Ref(vrt->ipv4_suckaddr, vrt->ipv6_suckaddr);
b->healthy = 1; b->healthy = 1;
b->health_changed = VTIM_real(); b->health_changed = VTIM_real();
b->admin_health = ah_probe; b->admin_health = ah_probe;
vbp = vrt->probe;
if (vbp == NULL)
vbp = VCL_DefaultProbe(vcl);
Lck_Lock(&backends_mtx); Lck_Lock(&backends_mtx);
VTAILQ_INSERT_TAIL(&backends, b, list); VTAILQ_INSERT_TAIL(&backends, b, list);
VSC_C_main->n_backend++; VSC_C_main->n_backend++;
b->tcp_pool = VBT_Ref(vrt->ipv4_suckaddr, vrt->ipv6_suckaddr);
if (vbp != NULL) {
tp = VBT_Ref(vrt->ipv4_suckaddr, vrt->ipv6_suckaddr);
assert(b->tcp_pool == tp);
}
Lck_Unlock(&backends_mtx); Lck_Unlock(&backends_mtx);
VBE_fill_director(b); VBE_fill_director(b);
vbp = vrt->probe;
if (vbp == NULL)
vbp = VCL_DefaultProbe(vcl);
if (vbp != NULL) if (vbp != NULL)
VBP_Insert(b, vbp, VBP_Insert(b, vbp, tp);
VBT_Ref(vrt->ipv4_suckaddr, vrt->ipv6_suckaddr));
VCL_AddBackend(ctx->vcl, b); VCL_AddBackend(ctx->vcl, b);
...@@ -167,6 +172,7 @@ VBE_Delete(struct backend *be) ...@@ -167,6 +172,7 @@ VBE_Delete(struct backend *be)
Lck_Lock(&backends_mtx); Lck_Lock(&backends_mtx);
VTAILQ_REMOVE(&backends, be, list); VTAILQ_REMOVE(&backends, be, list);
VSC_C_main->n_backend--; VSC_C_main->n_backend--;
VBT_Rel(&be->tcp_pool);
Lck_Unlock(&backends_mtx); Lck_Unlock(&backends_mtx);
#define DA(x) do { if (be->x != NULL) free(be->x); } while (0) #define DA(x) do { if (be->x != NULL) free(be->x); } while (0)
...@@ -177,7 +183,6 @@ VBE_Delete(struct backend *be) ...@@ -177,7 +183,6 @@ VBE_Delete(struct backend *be)
free(be->display_name); free(be->display_name);
AZ(be->vsc); AZ(be->vsc);
VBT_Rel(&be->tcp_pool);
Lck_Delete(&be->mtx); Lck_Delete(&be->mtx);
FREE_OBJ(be); FREE_OBJ(be);
} }
......
...@@ -127,7 +127,6 @@ VBT_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6) ...@@ -127,7 +127,6 @@ VBT_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6)
{ {
struct tcp_pool *tp; struct tcp_pool *tp;
ASSERT_CLI();
VTAILQ_FOREACH(tp, &pools, list) { VTAILQ_FOREACH(tp, &pools, list) {
assert(tp->refcnt > 0); assert(tp->refcnt > 0);
if (ip4 == NULL) { if (ip4 == NULL) {
......
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