[master] f33a076 Give struct htc the same "tell it what vsl_buffer to use" treatment.

Poul-Henning Kamp phk at varnish-cache.org
Tue Feb 14 11:51:39 CET 2012


commit f33a076b477487e66bea47e77c78408f1bf80a29
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 10:50:49 2012 +0000

    Give struct htc the same "tell it what vsl_buffer to use" treatment.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2349470..8ff3688 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -189,7 +189,7 @@ struct http_conn {
 #define HTTP_CONN_MAGIC		0x3e19edd1
 
 	int			fd;
-	unsigned		vsl_id;
+	struct vsl_log		*vsl;
 	unsigned		maxbytes;
 	unsigned		maxhdr;
 	struct ws		*ws;
@@ -831,11 +831,11 @@ void http_Unset(struct http *hp, const char *hdr);
 void http_CollectHdr(struct http *hp, const char *hdr);
 
 /* cache_httpconn.c */
-void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id,
+void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *,
     unsigned maxbytes, unsigned maxhdr);
 int HTC_Reinit(struct http_conn *htc);
 int HTC_Rx(struct http_conn *htc);
-ssize_t HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len);
+ssize_t HTC_Read(struct http_conn *htc, void *d, size_t len);
 int HTC_Complete(struct http_conn *htc);
 
 #define HTTPH(a, b, c) extern char b[];
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 8aa80d1..57e5616 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -116,7 +116,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
 		SES_GetReq(sp);
 		req = sp->req;
 		CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-		HTC_Init(req->htc, req->ws, sp->fd, sp->vsl_id,
+		HTC_Init(req->htc, req->ws, sp->fd, sp->req->vsl,
 		    cache_param->http_req_size,
 		    cache_param->http_req_hdr_len);
 	}
diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h
index 4867614..bcc815b 100644
--- a/bin/varnishd/cache/cache_esi.h
+++ b/bin/varnishd/cache/cache_esi.h
@@ -42,7 +42,7 @@
 typedef ssize_t vep_callback_t(struct worker *w, ssize_t l, enum vgz_flag flg);
 
 void VEP_Init(struct worker *w, vep_callback_t *cb);
-void VEP_Parse(const struct worker *w, const char *p, size_t l);
+void VEP_Parse(const struct busyobj *, const char *p, size_t l);
 struct vsb *VEP_Finish(const struct worker *w);
 
 
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 64adf51..620082d 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -64,7 +64,7 @@ struct vef_priv {
  */
 
 static ssize_t
-vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen,
+vef_read(struct http_conn *htc, void *buf, ssize_t buflen,
     ssize_t bytes)
 {
 	ssize_t d;
@@ -76,7 +76,7 @@ vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen,
 		if (d < bytes)
 			bytes = d;
 	}
-	return (HTC_Read(wrk, htc, buf, bytes));
+	return (HTC_Read(htc, buf, bytes));
 }
 
 /*---------------------------------------------------------------------
@@ -97,11 +97,11 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef,
 		st = FetchStorage(wrk, 0);
 		if (st == NULL)
 			return (-1);
-		wl = vef_read(wrk, htc,
+		wl = vef_read(htc,
 		    st->ptr + st->len, st->space - st->len, bytes);
 		if (wl <= 0)
 			return (wl);
-		VEP_Parse(wrk, (const char *)st->ptr + st->len, wl);
+		VEP_Parse(wrk->busyobj, (const char *)st->ptr + st->len, wl);
 		st->len += wl;
 		wrk->busyobj->fetch_obj->len += wl;
 		bytes -= wl;
@@ -129,7 +129,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef,
 
 	while (bytes > 0) {
 		if (VGZ_IbufEmpty(vg) && bytes > 0) {
-			wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes);
+			wl = vef_read(htc, vef->ibuf, vef->ibuf_sz, bytes);
 			if (wl <= 0)
 				return (wl);
 			VGZ_Ibuf(vg, vef->ibuf, wl);
@@ -139,7 +139,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef,
 			return(-1);
 		i = VGZ_Gunzip(vg, &dp, &dl);
 		xxxassert(i == VGZ_OK || i == VGZ_END);
-		VEP_Parse(wrk, dp, dl);
+		VEP_Parse(wrk->busyobj, dp, dl);
 		wrk->busyobj->fetch_obj->len += dl;
 	}
 	return (1);
@@ -167,7 +167,7 @@ vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 
-	VEP_Parse(wrk, vef->ibuf_i, wl);
+	VEP_Parse(wrk->busyobj, vef->ibuf_i, wl);
 	vef->ibuf_i += wl;
 	assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i);
 	if (vef->error) {
@@ -235,7 +235,7 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg)
  */
 
 static int
-vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef,
+vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef,
     struct http_conn *htc, ssize_t bytes)
 {
 	ssize_t wl;
@@ -246,7 +246,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef,
 
 	while (bytes > 0) {
 		wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf);
-		wl = vef_read(wrk, htc, vef->ibuf_i, wl, bytes);
+		wl = vef_read(htc, vef->ibuf_i, wl, bytes);
 		if (wl <= 0)
 			return (wl);
 		bytes -= wl;
@@ -261,7 +261,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef,
  */
 
 static int
-vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef,
+vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef,
     struct http_conn *htc, size_t bytes)
 {
 	ssize_t wl;
@@ -274,7 +274,7 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef,
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 
 	while (bytes > 0) {
-		wl = vef_read(wrk, htc, vef->ibuf2, vef->ibuf2_sz, bytes);
+		wl = vef_read(htc, vef->ibuf2, vef->ibuf2_sz, bytes);
 		if (wl <= 0)
 			return (wl);
 		bytes -= wl;
diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 3154784..433208d 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -549,16 +549,15 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
  */
 
 void
-VEP_Parse(const struct worker *wrk, const char *p, size_t l)
+VEP_Parse(const struct busyobj *bo, const char *p, size_t l)
 {
 	struct vep_state *vep;
 	const char *e;
 	struct vep_match *vm;
 	int i;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-	vep = wrk->busyobj->vep;
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	vep = bo->vep;
 	CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
 	assert(l > 0);
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index f5995ca..8b94fd7 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -121,7 +121,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes)
 		l = st->space - st->len;
 		if (l > bytes)
 			l = bytes;
-		wl = HTC_Read(wrk, htc, st->ptr + st->len, l);
+		wl = HTC_Read(htc, st->ptr + st->len, l);
 		if (wl <= 0)
 			return (wl);
 		st->len += wl;
@@ -261,7 +261,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc)
 	do {
 		/* Skip leading whitespace */
 		do {
-			if (HTC_Read(wrk, htc, buf, 1) <= 0)
+			if (HTC_Read(htc, buf, 1) <= 0)
 				return (-1);
 		} while (vct_islws(buf[0]));
 
@@ -271,7 +271,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc)
 		/* Collect hex digits, skipping leading zeros */
 		for (u = 1; u < sizeof buf; u++) {
 			do {
-				if (HTC_Read(wrk, htc, buf + u, 1) <= 0)
+				if (HTC_Read(htc, buf + u, 1) <= 0)
 					return (-1);
 			} while (u == 1 && buf[0] == '0' && buf[u] == '0');
 			if (!vct_ishex(buf[u]))
@@ -283,7 +283,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc)
 
 		/* Skip trailing white space */
 		while(vct_islws(buf[u]) && buf[u] != '\n')
-			if (HTC_Read(wrk, htc, buf + u, 1) <= 0)
+			if (HTC_Read(htc, buf + u, 1) <= 0)
 				return (-1);
 
 		if (buf[u] != '\n')
@@ -297,10 +297,10 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc)
 		if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0)
 			return (-1);
 
-		i = HTC_Read(wrk, htc, buf, 1);
+		i = HTC_Read(htc, buf, 1);
 		if (i <= 0)
 			return (-1);
-		if (buf[0] == '\r' && HTC_Read(wrk, htc, buf, 1) <= 0)
+		if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0)
 			return (-1);
 		if (buf[0] != '\n')
 			return (FetchError(wrk,"chunked tail no NL"));
@@ -352,7 +352,7 @@ FetchReqBody(const struct sess *sp, int sendbody)
 				rdcnt = sizeof buf;
 			else
 				rdcnt = content_length;
-			rdcnt = HTC_Read(sp->wrk, sp->req->htc, buf, rdcnt);
+			rdcnt = HTC_Read(sp->req->htc, buf, rdcnt);
 			if (rdcnt <= 0)
 				return (1);
 			content_length -= rdcnt;
@@ -447,7 +447,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
 
 	/* Receive response */
 
-	HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl_id,
+	HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl,
 	    cache_param->http_resp_size,
 	    cache_param->http_resp_hdr_len);
 
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index cf270c5..5901930 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -471,7 +471,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes)
 			l = vg->m_sz;
 			if (l > bytes)
 				l = bytes;
-			wl = HTC_Read(wrk, htc, vg->m_buf, l);
+			wl = HTC_Read(htc, vg->m_buf, l);
 			if (wl <= 0)
 				return (wl);
 			VGZ_Ibuf(vg, vg->m_buf, wl);
@@ -554,7 +554,7 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes)
 			l = vg->m_sz;
 			if (l > bytes)
 				l = bytes;
-			wl = HTC_Read(wrk, htc, vg->m_buf, l);
+			wl = HTC_Read(htc, vg->m_buf, l);
 			if (wl <= 0)
 				return (wl);
 			VGZ_Ibuf(vg, vg->m_buf, wl);
@@ -650,7 +650,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes)
 		l = st->space - st->len;
 		if (l > bytes)
 			l = bytes;
-		wl = HTC_Read(wrk, htc, st->ptr + st->len, l);
+		wl = HTC_Read(htc, st->ptr + st->len, l);
 		if (wl <= 0)
 			return (wl);
 		bytes -= wl;
diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c
index 1a1eaf0..d0b7199 100644
--- a/bin/varnishd/cache/cache_httpconn.c
+++ b/bin/varnishd/cache/cache_httpconn.c
@@ -88,14 +88,14 @@ htc_header_complete(txt *t)
 /*--------------------------------------------------------------------*/
 
 void
-HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id,
+HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
     unsigned maxbytes, unsigned maxhdr)
 {
 
 	htc->magic = HTTP_CONN_MAGIC;
 	htc->ws = ws;
 	htc->fd = fd;
-	htc->vsl_id = vsl_id;
+	htc->vsl = vsl;
 	htc->maxbytes = maxbytes;
 	htc->maxhdr = maxhdr;
 
@@ -200,13 +200,12 @@ HTC_Rx(struct http_conn *htc)
  */
 
 ssize_t
-HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len)
+HTC_Read(struct http_conn *htc, void *d, size_t len)
 {
 	size_t l;
 	unsigned char *p;
 	ssize_t i;
 
-	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	l = 0;
 	p = d;
@@ -225,7 +224,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len)
 		return (l);
 	i = read(htc->fd, p, len);
 	if (i < 0) {
-		WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno));
+		WSL(htc->vsl, SLT_FetchError, -1, "%s", strerror(errno));
 		return (i);
 	}
 	return (i + l);



More information about the varnish-commit mailing list