Commit 9633e660 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Led VDI_CloseFd() take an the vbc to be closed as argument.

parent 9a5b4779
......@@ -650,7 +650,7 @@ void VBE_UseHealth(const struct director *vdi);
struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
int VDI_Healthy(const struct director *, const struct sess *sp);
void VDI_CloseFd(struct worker *wrk);
void VDI_CloseFd(struct worker *wrk, struct vbc **vbp);
void VDI_RecycleFd(struct worker *wrk);
void VDI_AddHostHeader(const struct sess *sp);
void VBE_Poll(void);
......
......@@ -249,7 +249,7 @@ cnt_prepresp(struct sess *sp)
if (sp->restarts >= cache_param->max_restarts)
break;
if (wrk->busyobj->do_stream) {
VDI_CloseFd(wrk);
VDI_CloseFd(wrk, &wrk->vbc);
HSH_Drop(wrk);
} else {
(void)HSH_Deref(wrk, NULL, &wrk->obj);
......@@ -633,7 +633,7 @@ cnt_fetch(struct sess *sp)
}
/* We are not going to fetch the body, Close the connection */
VDI_CloseFd(wrk);
VDI_CloseFd(wrk, &wrk->vbc);
}
/* Clean up partial fetch */
......@@ -817,7 +817,7 @@ cnt_fetchbody(struct sess *sp)
if (wrk->obj == NULL) {
sp->err_code = 503;
sp->step = STP_ERROR;
VDI_CloseFd(wrk);
VDI_CloseFd(wrk, &wrk->vbc);
return (0);
}
CHECK_OBJ_NOTNULL(wrk->obj, OBJECT_MAGIC);
......
......@@ -40,27 +40,31 @@
/* Close a connection ------------------------------------------------*/
void
VDI_CloseFd(struct worker *wrk)
VDI_CloseFd(struct worker *wrk, struct vbc **vbp)
{
struct backend *bp;
struct vbc *vc;
CHECK_OBJ_NOTNULL(wrk->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(wrk->vbc->backend, BACKEND_MAGIC);
assert(wrk->vbc->fd >= 0);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(vbp);
vc = *vbp;
*vbp = NULL;
CHECK_OBJ_NOTNULL(vc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
assert(vc->fd >= 0);
bp = wrk->vbc->backend;
bp = vc->backend;
WSL(wrk, SLT_BackendClose, wrk->vbc->vsl_id, "%s", bp->display_name);
WSL(wrk, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name);
/* Checkpoint log to flush all info related to this connection
before the OS reuses the FD */
WSL_Flush(wrk, 0);
VTCP_close(&wrk->vbc->fd);
VTCP_close(&vc->fd);
VBE_DropRefConn(bp);
wrk->vbc->backend = NULL;
VBE_ReleaseConn(wrk->vbc);
wrk->vbc = NULL;
vc->backend = NULL;
VBE_ReleaseConn(vc);
}
/* Recycle a connection ----------------------------------------------*/
......
......@@ -427,7 +427,7 @@ FetchHdr(struct sess *sp)
if (WRW_FlushRelease(w) || i > 0) {
WSP(sp, SLT_FetchError, "backend write error: %d (%s)",
errno, strerror(errno));
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
/* XXX: other cleanup ? */
return (retry);
}
......@@ -451,7 +451,7 @@ FetchHdr(struct sess *sp)
if (i < 0) {
WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)",
i, errno, strerror(errno));
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
/* XXX: other cleanup ? */
/* Retryable if we never received anything */
return (i == -1 ? retry : -1);
......@@ -465,7 +465,7 @@ FetchHdr(struct sess *sp)
WSP(sp, SLT_FetchError,
"http first read error: %d %d (%s)",
i, errno, strerror(errno));
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
/* XXX: other cleanup ? */
return (-1);
}
......@@ -475,7 +475,7 @@ FetchHdr(struct sess *sp)
if (http_DissectResponse(w, htc, hp)) {
WSP(sp, SLT_FetchError, "http format error");
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
/* XXX: other cleanup ? */
return (-1);
}
......@@ -571,7 +571,7 @@ FetchBody(struct worker *w, struct object *obj)
cls, mklen);
if (w->busyobj->body_status == BS_ERROR) {
VDI_CloseFd(w);
VDI_CloseFd(w, &w->vbc);
return (__LINE__);
}
......@@ -583,7 +583,7 @@ FetchBody(struct worker *w, struct object *obj)
VTAILQ_REMOVE(&obj->store, st, list);
STV_free(st);
}
VDI_CloseFd(w);
VDI_CloseFd(w, &w->vbc);
obj->len = 0;
return (__LINE__);
}
......@@ -616,7 +616,7 @@ FetchBody(struct worker *w, struct object *obj)
}
if (cls)
VDI_CloseFd(w);
VDI_CloseFd(w, &w->vbc);
else
VDI_RecycleFd(w);
......
......@@ -89,7 +89,7 @@ PipeSession(struct sess *sp)
if (i) {
SES_Close(sp, "pipe");
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
return;
}
......@@ -129,5 +129,5 @@ PipeSession(struct sess *sp)
}
}
SES_Close(sp, "pipe");
VDI_CloseFd(sp->wrk);
VDI_CloseFd(sp->wrk, &sp->wrk->vbc);
}
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