Skip to content

Commit

Permalink
backend: no need to signal cw when we increase
Browse files Browse the repository at this point in the history
This would allow connection count to exceed the .max_connections property.

Signed-off-by: Asad Sajjad Ahmed <asadsa@varnish-software.com>
  • Loading branch information
asadsa92 committed Aug 19, 2024
1 parent 90204fd commit 57f5470
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions bin/varnishd/cache/cache_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ VBE_Connect_Error(struct VSC_vbe *vsc, int err)
/*--------------------------------------------------------------------*/

static void
vbe_connwait_signal_locked(const struct backend *bp)
vbe_connwait_signal_locked(struct backend *bp)
{
struct connwait *cw;

Lck_AssertHeld(bp->director->mtx);

assert(bp->n_conn > 0);
bp->n_conn--;

if (bp->n_conn < bp->max_connections) {
cw = VTAILQ_FIRST(&bp->cw_head);
if (cw != NULL) {
Expand All @@ -162,7 +165,6 @@ vbe_connwait_dequeue_locked(struct backend *bp, struct connwait *cw)
Lck_AssertHeld(bp->director->mtx);
bp->n_conn++;
VTAILQ_REMOVE(&bp->cw_head, cw, cw_list);
vbe_connwait_signal_locked(bp);
cw->cw_state = CW_DEQUEUED;
}

Expand Down Expand Up @@ -279,7 +281,6 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
if (pfd == NULL) {
Lck_Lock(bp->director->mtx);
VBE_Connect_Error(bp->vsc, err);
bp->n_conn--;
vbe_connwait_signal_locked(bp);
Lck_Unlock(bp->director->mtx);
VSLb(bo->vsl, SLT_FetchError,
Expand Down Expand Up @@ -311,7 +312,6 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
VCP_Close(&pfd);
AZ(pfd);
Lck_Lock(bp->director->mtx);
bp->n_conn--;
vbe_connwait_signal_locked(bp);
Lck_Unlock(bp->director->mtx);
return (NULL);
Expand Down Expand Up @@ -372,8 +372,6 @@ vbe_dir_finish(VRT_CTX, VCL_BACKEND d)
VSC_C_main->backend_recycle++;
VCP_Recycle(bo->wrk, &pfd);
}
assert(bp->n_conn > 0);
bp->n_conn--;
AN(bp->vsc);
bp->vsc->conn--;
#define ACCT(foo) bp->vsc->foo += bo->acct.foo;
Expand Down

0 comments on commit 57f5470

Please sign in to comment.