Commit 54b7af96 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Always close directors through the VDI api.

parent bd069ef4
......@@ -341,8 +341,8 @@ VBE_DiscardHealth(const struct director *vdi)
/* Close a connection ------------------------------------------------*/
void
VBE_CloseFd(struct vbc **vbp, const struct acct_bereq *acct_bereq)
static void
vbe_CloseFd(struct vbc **vbp, const struct acct_bereq *acct_bereq)
{
struct backend *bp;
struct vbc *vc;
......@@ -356,8 +356,6 @@ VBE_CloseFd(struct vbc **vbp, const struct acct_bereq *acct_bereq)
bp = vc->backend;
VSLb(vc->vsl, SLT_BackendClose, "%d %s", vc->fd, bp->display_name);
vc->vsl = NULL;
VTCP_close(&vc->fd);
VBE_DropRefConn(bp, acct_bereq);
......@@ -382,8 +380,6 @@ vbe_RecycleFd(struct vbc **vbp, const struct acct_bereq *acct_bereq)
bp = vc->backend;
VSLb(vc->vsl, SLT_BackendReuse, "%d %s", vc->fd, bp->display_name);
vc->vsl = NULL;
Lck_Lock(&bp->mtx);
......@@ -458,17 +454,20 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
if (i == 1) {
AZ(bo->vbc);
VSC_C_main->backend_retry++;
bo->vbc = VDI_GetFd(d, wrk, bo);
bo->doclose = SC_NULL;
bo->vbc = vbe_dir_getfd(d, bo);
if (bo->vbc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
return (-1);
}
i = V1F_fetch_hdr(wrk, bo);
}
if (i != 0)
if (i != 0) {
bo->doclose = SC_NULL;
AZ(bo->vbc);
else
} else {
AN(bo->vbc);
}
return (i);
}
......@@ -494,11 +493,20 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (bo->vbc != NULL) {
if (bo->doclose != SC_NULL)
VBE_CloseFd(&bo->vbc, &bo->acct);
else
if (bo->doclose != SC_NULL) {
VSLb(bo->vsl, SLT_BackendClose,
"%d %s", bo->vbc->fd,
bo->vbc->backend->display_name);
vbe_CloseFd(&bo->vbc, &bo->acct);
} else {
VSLb(bo->vsl, SLT_BackendReuse,
"%d %s", bo->vbc->fd,
bo->vbc->backend->display_name);
vbe_RecycleFd(&bo->vbc, &bo->acct);
}
}
AZ(bo->vbc);
}
static struct suckaddr * __match_proto__(vdi_suckaddr_f)
......
......@@ -105,7 +105,6 @@ struct vbc {
void VBE_ReleaseConn(struct vbc *vc);
void VBE_UseHealth(const struct director *vdi);
void VBE_DiscardHealth(const struct director *vdi);
void VBE_CloseFd(struct vbc **vbp, const struct acct_bereq *);
/* cache_backend_cfg.c */
void VBE_DropRefConn(struct backend *, const struct acct_bereq *);
......
......@@ -144,7 +144,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
VSLb(bo->vsl, SLT_FetchError, "backend write error: %d (%s)",
errno, strerror(errno));
VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk));
VBE_CloseFd(&bo->vbc, &bo->acct);
bo->doclose = SC_TX_ERROR;
VDI_Finish(bo->director_resp, bo->wrk, bo);
/* XXX: other cleanup ? */
return (retry);
}
......@@ -171,7 +172,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
VSLb(bo->vsl, SLT_FetchError,
"http %sread error: overflow",
first ? "first " : "");
VBE_CloseFd(&bo->vbc, &bo->acct);
bo->doclose = SC_RX_OVERFLOW;
VDI_Finish(bo->director_resp, bo->wrk, bo);
/* XXX: other cleanup ? */
return (-1);
}
......@@ -180,7 +182,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
htc->rxbuf_e - htc->rxbuf_b;
VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
first ? "first " : "");
VBE_CloseFd(&bo->vbc, &bo->acct);
bo->doclose = SC_RX_TIMEOUT;
VDI_Finish(bo->director_resp, bo->wrk, bo);
/* XXX: other cleanup ? */
return (retry);
}
......@@ -197,7 +200,8 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
if (HTTP1_DissectResponse(hp, htc)) {
VSLb(bo->vsl, SLT_FetchError, "http format error");
VBE_CloseFd(&bo->vbc, &bo->acct);
bo->doclose = SC_RX_JUNK;
VDI_Finish(bo->director_resp, bo->wrk, bo);
/* XXX: other cleanup ? */
return (-1);
}
......
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