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