Skip to content

Commit

Permalink
backend: Add vbe_conwait_fini
Browse files Browse the repository at this point in the history
  • Loading branch information
walid-git committed Feb 5, 2024
1 parent 8c20fa1 commit 7fb8ce2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bin/varnishd/cache/cache_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ vbe_connwait_dequeue_locked(struct backend *bp, struct connwait *cw)
cw->cw_state = CW_DEQUEUED;
}

static void
vbe_conwait_fini(struct connwait *cw)
{
CHECK_OBJ_NOTNULL(cw, CONNWAIT_MAGIC);
assert(cw->cw_state != CW_QUEUED);
PTOK(pthread_cond_destroy(&cw->cw_cond));
FINI_OBJ(cw);
}

/*--------------------------------------------------------------------
* Get a connection to the backend
*
Expand Down Expand Up @@ -227,7 +236,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
"backend %s: busy", VRT_BACKEND_string(dir));
bp->vsc->busy++;
VSC_C_main->backend_busy++;
PTOK(pthread_cond_destroy(&cw->cw_cond));
vbe_conwait_fini(cw);
return (NULL);
}

Expand All @@ -241,7 +250,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
vbe_connwait_dequeue_locked(bp, cw);
Lck_Unlock(bp->director->mtx);
}
PTOK(pthread_cond_destroy(&cw->cw_cond));
vbe_conwait_fini(cw);
return (NULL);
}
bo->htc->doclose = SC_NULL;
Expand All @@ -263,7 +272,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
vbe_connwait_dequeue_locked(bp, cw);
Lck_Unlock(bp->director->mtx);
}
PTOK(pthread_cond_destroy(&cw->cw_cond));
vbe_conwait_fini(cw);
return (NULL);
}

Expand Down Expand Up @@ -301,7 +310,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
bp->vsc->conn--;
bp->vsc->req--;
Lck_Unlock(bp->director->mtx);
PTOK(pthread_cond_destroy(&cw->cw_cond));
vbe_conwait_fini(cw);
return (NULL);
}
bo->acct.bereq_hdrbytes += err;
Expand All @@ -320,7 +329,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
bo->htc->first_byte_timeout, bo, bp);
FIND_TMO(between_bytes_timeout,
bo->htc->between_bytes_timeout, bo, bp);
PTOK(pthread_cond_destroy(&cw->cw_cond));
vbe_conwait_fini(cw);
return (pfd);
}

Expand Down

0 comments on commit 7fb8ce2

Please sign in to comment.