Skip to content

Commit

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

static void
backend_cw_fini(struct backend_cw *cw)
{
CHECK_OBJ_NOTNULL(cw, BACKEND_CW_MAGIC);
AN(cw->cw_state != CW_QUEUED);
PTOK(pthread_cond_destroy(&cw->cw_cond));
}

/*--------------------------------------------------------------------
* Get a connection to the backend
*
Expand Down Expand Up @@ -212,7 +220,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));
backend_cw_fini(cw);
return (NULL);
}

Expand All @@ -226,7 +234,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));
backend_cw_fini(cw);
return (NULL);
}
bo->htc->doclose = SC_NULL;
Expand All @@ -248,7 +256,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));
backend_cw_fini(cw);
return (NULL);
}

Expand Down Expand Up @@ -286,7 +294,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));
backend_cw_fini(cw);
return (NULL);
}
bo->acct.bereq_hdrbytes += err;
Expand All @@ -305,7 +313,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));
backend_cw_fini(cw);
return (pfd);
}

Expand Down

0 comments on commit 8fa9f61

Please sign in to comment.