Skip to content

Commit

Permalink
backend: Inline vbe_connwait_dequeue
Browse files Browse the repository at this point in the history
  • Loading branch information
walid-git committed Jan 15, 2024
1 parent 476161c commit dba733c
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions bin/varnishd/cache/cache_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,6 @@ vbe_connwait_signal_locked(struct backend *bp)
}
}

static void
vbe_connwait_dequeue(struct backend *bp, struct backend_cw *cw, int lock_it)
{
if (lock_it)
Lck_Lock(bp->director->mtx);
VTAILQ_REMOVE(&bp->cw_head, cw, cw_list);
vbe_connwait_signal_locked(bp);
if (lock_it)
Lck_Unlock(bp->director->mtx);
}

/*--------------------------------------------------------------------
* Get a connection to the backend
*
Expand Down Expand Up @@ -229,8 +218,12 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
if (bo->htc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "out of workspace");
/* XXX: counter ? */
if (cw_state == CW_QUEUED)
vbe_connwait_dequeue(bp, cw, 1);
if (cw_state == CW_QUEUED) {
Lck_Lock(bp->director->mtx);
VTAILQ_REMOVE(&bp->cw_head, cw, cw_list);
vbe_connwait_signal_locked(bp);
Lck_Unlock(bp->director->mtx);
}
AZ(pthread_cond_destroy(&cw->cw_cond));
return (NULL);
}
Expand All @@ -248,8 +241,12 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
VRT_BACKEND_string(dir), err, VAS_errtxt(err));
VSC_C_main->backend_fail++;
bo->htc = NULL;
if (cw_state == CW_QUEUED)
vbe_connwait_dequeue(bp, cw, 1);
if (cw_state == CW_QUEUED) {
Lck_Lock(bp->director->mtx);
VTAILQ_REMOVE(&bp->cw_head, cw, cw_list);
vbe_connwait_signal_locked(bp);
Lck_Unlock(bp->director->mtx);
}
AZ(pthread_cond_destroy(&cw->cw_cond));
return (NULL);
}
Expand All @@ -263,8 +260,10 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
bp->n_conn++;
bp->vsc->conn++;
bp->vsc->req++;
if (cw_state == CW_QUEUED)
vbe_connwait_dequeue(bp, cw, 0);
if (cw_state == CW_QUEUED) {
VTAILQ_REMOVE(&bp->cw_head, cw, cw_list);
vbe_connwait_signal_locked(bp);
}

Lck_Unlock(bp->director->mtx);

Expand Down

0 comments on commit dba733c

Please sign in to comment.