[master] 8e216d5 Make it the callers responsibility to release the workspace

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 23 21:19:51 CET 2015


commit 8e216d58e83a65e9e3c85fbbaa0d6de2469cce20
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 23 20:19:31 2015 +0000

    Make it the callers responsibility to release the workspace

diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 2e7f784..ca0a539 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -214,19 +214,11 @@ SES_Rx(struct http_conn *htc)
 	AZ(htc->pipeline_b);
 	AZ(htc->pipeline_e);
 	i = (htc->ws->r - htc->rxbuf_e) - 1;	/* space for NUL */
-	if (i <= 0) {
-		WS_ReleaseP(htc->ws, htc->rxbuf_b);
+	if (i <= 0)
 		return (HTC_S_OVERFLOW);
-	}
 	i = read(htc->fd, htc->rxbuf_e, i);
-	if (i <= 0) {
-		/*
-		 * We wouldn't come here if we had a complete HTTP header
-		 * so consequently an EOF can not be OK
-		 */
-		WS_ReleaseP(htc->ws, htc->rxbuf_b);
+	if (i <= 0)
 		return (HTC_S_EOF);
-	}
 	htc->rxbuf_e += i;
 	*htc->rxbuf_e = '\0';
 	return (HTC_S_OK);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 6308b8c..855268b 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -157,6 +157,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
 		if (hs == HTC_S_OK)
 			hs = HTTP1_Complete(htc);
 		if (hs == HTC_S_OVERFLOW) {
+			WS_ReleaseP(htc->ws, htc->rxbuf_b);
 			bo->acct.beresp_hdrbytes +=
 			    htc->rxbuf_e - htc->rxbuf_b;
 			VSLb(bo->vsl, SLT_FetchError,
@@ -166,6 +167,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
 			return (-1);
 		}
 		if (hs == HTC_S_EOF) {
+			WS_ReleaseP(htc->ws, htc->rxbuf_b);
 			bo->acct.beresp_hdrbytes +=
 			    htc->rxbuf_e - htc->rxbuf_b;
 			VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 706f03f..75ab85a 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -95,9 +95,11 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req)
 			    req->htc->rxbuf_e - req->htc->rxbuf_b;
 			return (REQ_FSM_MORE);
 		} else if (hs == HTC_S_EOF) {
+			WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b);
 			why = SC_REM_CLOSE;
 			break;
 		} else if (hs == HTC_S_OVERFLOW) {
+			WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b);
 			why = SC_RX_OVERFLOW;
 			break;
 		} else if (hs == HTC_S_EMPTY) {



More information about the varnish-commit mailing list