[master] 8287ce7 Eliminate maxbytes entirely from struct http_conn

Poul-Henning Kamp phk at FreeBSD.org
Tue Apr 5 12:13:05 CEST 2016


commit 8287ce7d065e99f0621a06a671be15f2dc02bc75
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 5 10:11:48 2016 +0000

    Eliminate maxbytes entirely from struct http_conn

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 9789b4d..ee024c5 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -224,7 +224,6 @@ struct http_conn {
 
 	int			fd;
 	enum sess_close		doclose;
-	unsigned		maxbytes;
 	enum body_status	body_status;
 	struct ws		*ws;
 	char			*rxbuf_b;
@@ -962,7 +961,7 @@ enum htc_status_e {
 	HTC_S_IDLE =		 3,
 };
 
-void SES_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes);
+void SES_RxInit(struct http_conn *htc, struct ws *ws);
 void SES_RxReInit(struct http_conn *htc);
 enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *,
     double *t1, double *t2, double ti, double tn, int maxbytes);
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 982e1e8..faeaeb8 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -376,7 +376,7 @@ vca_make_session(struct worker *wrk, void *arg)
 	req = Req_New(wrk, sp);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	req->htc->fd = sp->fd;
-	SES_RxInit(req->htc, req->ws, cache_param->http_req_size);
+	SES_RxInit(req->htc, req->ws);
 
 	SES_SetTransport(wrk, sp, req, wa->acceptlsock->transport);
 }
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 6b5cccb..c9c7fa7 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -183,14 +183,13 @@ SES_Get_String_Attr(const struct sess *sp, enum sess_attr a)
 /*--------------------------------------------------------------------*/
 
 void
-SES_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes)
+SES_RxInit(struct http_conn *htc, struct ws *ws)
 {
 
 	htc->magic = HTTP_CONN_MAGIC;
 	htc->ws = ws;
-	htc->maxbytes = maxbytes;
 
-	(void)WS_Reserve(htc->ws, htc->maxbytes);
+	(void)WS_Reserve(htc->ws, 0);
 	htc->rxbuf_b = ws->f;
 	htc->rxbuf_e = ws->f;
 	*htc->rxbuf_e = '\0';
@@ -210,7 +209,7 @@ SES_RxReInit(struct http_conn *htc)
 	ssize_t l;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
-	(void)WS_Reserve(htc->ws, htc->maxbytes);
+	(void)WS_Reserve(htc->ws, 0);
 	htc->rxbuf_b = htc->ws->f;
 	htc->rxbuf_e = htc->ws->f;
 	if (htc->pipeline_b != NULL) {
@@ -245,6 +244,9 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func,
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 
+	if (htc->ws->r - htc->rxbuf_b < maxbytes)
+		maxbytes = (htc->ws->r - htc->rxbuf_b);
+
 	AZ(isnan(tn));
 	if (t1 != NULL)
 		assert(isnan(*t1));
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 902076a..0c6a225 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -151,7 +151,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
 
 	/* Receive response */
 
-	SES_RxInit(htc, bo->ws, cache_param->http_resp_size);
+	SES_RxInit(htc, bo->ws);
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
 
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 3dd63b0..ba937d2 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -130,7 +130,7 @@ http1_unwait(struct worker *wrk, void *arg)
 	req = Req_New(wrk, sp);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	req->htc->fd = sp->fd;
-	SES_RxInit(req->htc, req->ws, cache_param->http_req_size);
+	SES_RxInit(req->htc, req->ws);
 	http1_setstate(sp, H1NEWREQ);
 	wrk->task.func = http1_req;
 	wrk->task.priv = req;



More information about the varnish-commit mailing list