[master] 9633e66 Led VDI_CloseFd() take an the vbc to be closed as argument.

Poul-Henning Kamp phk at varnish-cache.org
Mon Dec 5 09:34:44 CET 2011


commit 9633e660b238f3456baa004caf58a10e1403cb41
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 5 08:34:27 2011 +0000

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

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index ff9dcea..4cfad78 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 501293d..997ecac 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -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);
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index eba6183..434277e 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -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 ----------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 38a2cf3..1d4eff3 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -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);
 
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 4180d39..9bf8b79 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -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);
 }



More information about the varnish-commit mailing list