r4117 - branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd

sky at projects.linpro.no sky at projects.linpro.no
Wed Jun 17 15:50:26 CEST 2009


Author: sky
Date: 2009-06-17 15:50:26 +0200 (Wed, 17 Jun 2009)
New Revision: 4117

Modified:
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache.h
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_center.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_esi.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_fetch.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_http.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pipe.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pool.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_response.c
   branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_wrw.c
Log:
add a WRW context struct so we can a) abstract gzip into wrw b) have multiple wrw outstanding if we so see fit in the future

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache.h
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache.h	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache.h	2009-06-17 13:50:26 UTC (rev 4117)
@@ -95,6 +95,8 @@
 struct ban;
 struct SHA256Context;
 
+struct wrw_context;
+
 struct smp_object;
 struct smp_seg;
 
@@ -194,6 +196,18 @@
 
 /*--------------------------------------------------------------------*/
 
+
+struct wrw_context {
+	unsigned               magic;
+#define WRW_MAGIC              0x6395adce
+
+	int			*fd;
+	unsigned		err;	/* valid after WRK_Flush() */
+	struct iovec		iov[MAX_IOVS];
+	int			niov;
+	ssize_t			liov;
+};
+
 struct worker {
 	unsigned		magic;
 #define WORKER_MAGIC		0x6391adcf
@@ -208,12 +222,6 @@
 	VTAILQ_ENTRY(worker)	list;
 	struct workreq		*wrq;
 
-	int			*wfd;
-	unsigned		werr;	/* valid after WRK_Flush() */
-	struct iovec		iov[MAX_IOVS];
-	int			niov;
-	ssize_t			liov;
-
 	struct VCL_conf		*vcl;
 
 	unsigned char		*wlb, *wlp, *wle;
@@ -352,6 +360,10 @@
 
 	struct worker		*wrk;
 
+	/* used for the delivery phase */
+	struct wrw_context      *wrw;
+	struct wrw_context      *resp_wrw;
+	
 	socklen_t		sockaddrlen;
 	socklen_t		mysockaddrlen;
 	struct sockaddr		*sockaddr;
@@ -502,7 +514,7 @@
 const char *http_StatusMessage(unsigned);
 void HTTP_Init(void);
 void http_ClrHeader(struct http *to);
-unsigned http_Write(struct worker *w, const struct http *hp, int resp);
+unsigned http_Write(struct worker *w, struct wrw_context *wrw, const struct http *hp, int resp);
 void http_CopyResp(struct http *to, const struct http *fm);
 void http_SetResp(struct http *to, const char *proto, const char *status,
     const char *response);
@@ -583,11 +595,12 @@
 void WRK_QueueSession(struct sess *sp);
 void WRK_SumStat(const struct worker *w);
 
-void WRW_Reserve(struct worker *w, int *fd);
-unsigned WRW_Flush(struct worker *w);
-unsigned WRW_FlushRelease(struct worker *w);
-unsigned WRW_Write(struct worker *w, const void *ptr, int len);
-unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf);
+struct wrw_context *WRW_New(struct sess *sp, int *fd);
+void WRW_Reserve(struct wrw_context *wrw, int *fd);
+unsigned WRW_Flush(struct wrw_context *wrw, struct worker *w);
+unsigned WRW_FlushRelease(struct wrw_context *wrw, struct worker *w);
+unsigned WRW_Write(struct wrw_context *wrw, struct worker *w, const void *ptr, int len);
+unsigned WRW_WriteH(struct wrw_context *wrw, struct worker *w, const txt *hh, const char *suf);
 #ifdef SENDFILE_WORKS
 void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
 #endif  /* SENDFILE_WORKS */

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_center.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_center.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -199,7 +199,7 @@
 	sp->restarts = 0;
 
 	RES_WriteObj(sp);
-	AZ(sp->wrk->wfd);
+	//	AZ(sp->wrk->wfd);
 	HSH_Deref(sp->wrk, &sp->obj);
 	sp->wrk->resp = NULL;
 	sp->step = STP_DONE;
@@ -531,7 +531,7 @@
 		sp->obj->last_modified = TIM_parse(b);
 	
 	i = FetchBody(sp);
-	AZ(sp->wrk->wfd);
+	//	AZ(sp->wrk->wfd);
 	AZ(sp->vbe);
 	AN(sp->director);
 
@@ -936,7 +936,7 @@
 	assert(sp->handling == VCL_RET_PIPE);
 
 	PipeSession(sp);
-	AZ(sp->wrk->wfd);
+	//	AZ(sp->wrk->wfd);
 	sp->wrk->bereq = NULL;
 	sp->step = STP_DONE;
 	return (0);
@@ -1174,7 +1174,7 @@
 		CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
 	}
 	WSL_Flush(w, 0);
-	AZ(w->wfd);
+	//	AZ(w->wfd);
 }
 
 /*

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_esi.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_esi.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_esi.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -760,27 +760,29 @@
 {
 	struct esi_bit *eb;
 	struct object *obj;
+	struct wrw_context *wrw;
 	struct worker *w;
 	char *ws_wm;
 	struct http http_save;
 
 	w = sp->wrk;
-	WRW_Reserve(w, &sp->fd);
+	wrw = sp->resp_wrw;
+
 	http_save.magic = 0;
 	VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
 		if (Tlen(eb->verbatim)) {
 			if (sp->http->protover >= 1.1)
-				(void)WRW_Write(w, eb->chunk_length, -1);
-			sp->acct_req.bodybytes += WRW_Write(w,
+				(void)WRW_Write(wrw, w, eb->chunk_length, -1);
+			sp->acct_req.bodybytes += WRW_Write(wrw, w,
 			    eb->verbatim.b, Tlen(eb->verbatim));
 			if (sp->http->protover >= 1.1)
-				(void)WRW_Write(w, "\r\n", -1);
+				(void)WRW_Write(wrw, w, "\r\n", -1);
 		}
 		if (eb->include.b == NULL ||
 		    sp->esis >= params->max_esi_includes)
 			continue;
 
-		if (WRW_FlushRelease(w)) {
+		if (WRW_Flush(wrw, w)) {
 			vca_close_session(sp, "remote closed");
 			return;
 		}
@@ -839,7 +841,6 @@
 		/* Reset the workspace */
 		WS_Reset(sp->ws, ws_wm);
 
-		WRW_Reserve(sp->wrk, &sp->fd);
 		if (sp->fd < 0)
 			break;
 	}
@@ -847,8 +848,8 @@
 	if (http_save.magic)
 		*sp->http = http_save;
 	if (sp->esis == 0 && sp->http->protover >= 1.1)
-		(void)WRW_Write(sp->wrk, "0\r\n\r\n", -1);
-	if (WRW_FlushRelease(sp->wrk))
+		(void)WRW_Write(wrw, w, "0\r\n\r\n", -1);
+	if (WRW_Flush(sp->resp_wrw, sp->wrk))
 		vca_close_session(sp, "remote closed");
 }
 

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_fetch.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_fetch.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -293,8 +293,8 @@
 			content_length -= rdcnt;
 			if (!sp->sendbody)
 				continue;
-			(void)WRW_Write(sp->wrk, buf, rdcnt); /* XXX: stats ? */
-			if (WRW_Flush(sp->wrk))
+			(void)WRW_Write(sp->wrw, sp->wrk, buf, rdcnt); /* XXX: stats ? */
+			if (WRW_Flush(sp->wrw, sp->wrk))
 				return (2);
 		}
 	}
@@ -313,6 +313,7 @@
 {
 	struct vbe_conn *vc;
 	struct worker *w;
+
 	char *b;
 	struct http *hp;
 	int i;
@@ -348,12 +349,12 @@
 		VBE_AddHostHeader(sp);
 
 	TCP_blocking(vc->fd);	/* XXX: we should timeout instead */
-	WRW_Reserve(w, &vc->fd);
-	(void)http_Write(w, hp, 0);	/* XXX: stats ? */
+	sp->wrw = WRW_New(sp, &vc->fd);
+	(void)http_Write(w, sp->wrw, hp, 0);	/* XXX: stats ? */
 
 	/* Deal with any message-body the request might have */
 	i = FetchReqBody(sp);
-	if (WRW_FlushRelease(w) || i > 0) {
+	if (WRW_FlushRelease(sp->wrw, w) || i > 0) {
 		VBE_ClosedFd(sp);
 		/* XXX: other cleanup ? */
 		return (__LINE__);

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_http.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_http.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -828,36 +828,36 @@
 /*--------------------------------------------------------------------*/
 
 unsigned
-http_Write(struct worker *w, const struct http *hp, int resp)
+http_Write(struct worker *w, struct wrw_context *wrw, const struct http *hp, int resp)
 {
 	unsigned u, l;
 
 	if (resp) {
 		AN(hp->hd[HTTP_HDR_STATUS].b);
-		l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_PROTO);
-		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_STATUS);
-		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_RESPONSE);
+		l = WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_PROTO], " ");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_PROTO);
+		l += WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_STATUS], " ");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_STATUS);
+		l += WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_RESPONSE);
 	} else {
 		AN(hp->hd[HTTP_HDR_URL].b);
-		l = WRW_WriteH(w, &hp->hd[HTTP_HDR_REQ], " ");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_REQ);
-		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_URL);
-		l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
-		WSLH(w, *w->wfd, hp, HTTP_HDR_PROTO);
+		l = WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_REQ], " ");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_REQ);
+		l += WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_URL], " ");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_URL);
+		l += WRW_WriteH(wrw, w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
+		WSLH(w, *wrw->fd, hp, HTTP_HDR_PROTO);
 	}
 	for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
 		if (hp->hd[u].b == NULL)
 			continue;
 		AN(hp->hd[u].b);
 		AN(hp->hd[u].e);
-		l += WRW_WriteH(w, &hp->hd[u], "\r\n");
-		WSLH(w, *w->wfd, hp, u);
+		l += WRW_WriteH(wrw, w, &hp->hd[u], "\r\n");
+		WSLH(w, *wrw->fd, hp, u);
 	}
-	l += WRW_Write(w, "\r\n", -1);
+	l += WRW_Write(wrw, w, "\r\n", -1);
 	return (l);
 }
 

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pipe.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pipe.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -68,6 +68,7 @@
 {
 	struct vbe_conn *vc;
 	struct worker *w;
+	struct wrw_context *wrw;
 	struct pollfd fds[2];
 	int i;
 
@@ -81,14 +82,15 @@
 	vc = sp->vbe;
 	TCP_blocking(vc->fd);
 
-	WRW_Reserve(w, &vc->fd);
-	sp->acct_req.hdrbytes += http_Write(w, sp->wrk->bereq, 0);
+	
+	wrw = WRW_New(sp, &vc->fd);
+	sp->acct_req.hdrbytes += http_Write(w, wrw, sp->wrk->bereq, 0);
 
 	if (sp->htc->pipeline.b != NULL)
 		sp->acct_req.bodybytes +=
-		    WRW_Write(w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
+		    WRW_Write(wrw, w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
 
-	i = WRW_FlushRelease(w);
+	i = WRW_FlushRelease(wrw, w);
 
 	if (i) {
 		vca_close_session(sp, "pipe");

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pool.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_pool.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -179,7 +179,6 @@
 		AZ(w->beresp);
 		AZ(w->resp);
 		WS_Assert(w->ws);
-		AZ(w->wfd);
 		assert(w->wlp == w->wlb);
 		w->wrq = NULL;
 		if (!Lck_Trylock(&wstat_mtx)) {

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_response.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_response.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -139,15 +139,15 @@
 	char lenbuf[20];
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
-	WRW_Reserve(sp->wrk, &sp->fd);
+	if (!sp->resp_wrw)
+		sp->resp_wrw = WRW_New(sp, &sp->fd);
 
 	if (sp->disable_esi || !sp->esis)
-		sp->acct_req.hdrbytes += http_Write(sp->wrk, sp->wrk->resp, 1);
+		sp->acct_req.hdrbytes += http_Write(sp->wrk, sp->resp_wrw, sp->wrk->resp, 1);
 
 	if (!sp->disable_esi && sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) {
-		if (WRW_FlushRelease(sp->wrk)) {
+		if (WRW_Flush(sp->resp_wrw, sp->wrk)) {
 			vca_close_session(sp, "remote closed");
 			return;
 		}
@@ -161,7 +161,7 @@
 		    sp->http->protover >= 1.1 &&
 		    sp->obj->len > 0) {
 			sprintf(lenbuf, "%x\r\n", sp->obj->len);
-			(void)WRW_Write(sp->wrk, lenbuf, -1);
+			(void)WRW_Write(sp->resp_wrw, sp->wrk, lenbuf, -1);
 		}
 
 		VTAILQ_FOREACH(st, &sp->obj->store, list) {
@@ -185,15 +185,18 @@
 			}
 #endif /* SENDFILE_WORKS */
 			VSL_stats->n_objwrite++;
-			(void)WRW_Write(sp->wrk, st->ptr, st->len);
+			(void)WRW_Write(sp->resp_wrw, sp->wrk, st->ptr, st->len);
 		}
 		assert(u == sp->obj->len);
 		if (!sp->disable_esi &&
 		    sp->esis > 0 &&
 		    sp->http->protover >= 1.1 &&
 		    sp->obj->len > 0)
-			(void)WRW_Write(sp->wrk, "\r\n", -1);
+			(void)WRW_Write(sp->resp_wrw, sp->wrk, "\r\n", -1);
 	}
-	if (WRW_FlushRelease(sp->wrk))
+	if (WRW_Flush(sp->resp_wrw, sp->wrk))
 		vca_close_session(sp, "remote closed");
+
+	if (!sp->esis)
+		sp->resp_wrw = 0;
 }

Modified: branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_wrw.c
===================================================================
--- branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_wrw.c	2009-06-17 13:36:25 UTC (rev 4116)
+++ branches/sky/wrw_context_gzip/varnish-cache/bin/varnishd/cache_wrw.c	2009-06-17 13:50:26 UTC (rev 4117)
@@ -70,95 +70,114 @@
  * thread to complete the request without holding stuff locked.
  */
 
+struct wrw_context *
+WRW_New(struct sess *sp, int *fd)
+{
+	struct wrw_context *wrw;
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+
+	wrw = (struct wrw_context *) WS_Alloc(sp->ws, (unsigned int) sizeof(struct wrw_context));
+	wrw->magic = WRW_MAGIC;
+	wrw->fd = fd;
+	wrw->err = 0;
+	wrw->liov = 0;
+	wrw->niov = 0;
+	
+	return wrw;
+}
+
 void
-WRW_Reserve(struct worker *w, int *fd)
+WRW_Reserve(struct wrw_context *wrw, int *fd)
 {
 
-	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	AZ(w->wfd);
-	w->werr = 0;
-	w->liov = 0;
-	w->niov = 0;
-	w->wfd = fd;
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
+	AZ(wrw->fd);
+	wrw->err = 0;
+	wrw->liov = 0;
+	wrw->niov = 0;
+	wrw->fd = fd;
 }
 
 static void
-WRW_Release(struct worker *w)
+WRW_Release(struct wrw_context *wrw)
 {
 
-	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	w->werr = 0;
-	w->liov = 0;
-	w->niov = 0;
-	w->wfd = NULL;
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
+	wrw->err = 0;
+	wrw->liov = 0;
+	wrw->niov = 0;
+	wrw->fd = NULL;
 }
 
 unsigned
-WRW_Flush(struct worker *w)
+WRW_Flush(struct wrw_context *wrw, struct worker *w)
 {
 	ssize_t i;
 
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
 	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	AN(w->wfd);
-	if (*w->wfd >= 0 && w->niov > 0 && w->werr == 0) {
-		i = writev(*w->wfd, w->iov, w->niov);
-		if (i != w->liov) {
-			w->werr++;
-			WSL(w, SLT_Debug, *w->wfd,
+	AN(wrw->fd);
+	if (*wrw->fd >= 0 && wrw->niov > 0 && wrw->err == 0) {
+		i = writev(*wrw->fd, wrw->iov, wrw->niov);
+		if (i != wrw->liov) {
+			wrw->err++;
+			WSL(w, SLT_Debug, *wrw->fd,
 			    "Write error, len = %d/%d, errno = %s",
-			    i, w->liov, strerror(errno));
+			    i, wrw->liov, strerror(errno));
 		}
 	}
-	w->liov = 0;
-	w->niov = 0;
-	return (w->werr);
+	wrw->liov = 0;
+	wrw->niov = 0;
+	return (wrw->err);
 }
 
 unsigned
-WRW_FlushRelease(struct worker *w)
+WRW_FlushRelease(struct wrw_context *wrw, struct worker *w)
 {
 	unsigned u;
 
-	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	AN(w->wfd);
-	u = WRW_Flush(w);
-	WRW_Release(w);
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
+	AN(wrw->fd);
+	u = WRW_Flush(wrw, w);
+	WRW_Release(wrw);
 	return (u);
 }
 
 unsigned
-WRW_WriteH(struct worker *w, const txt *hh, const char *suf)
+WRW_WriteH(struct wrw_context *wrw, struct worker *w, const txt *hh, const char *suf)
 {
 	unsigned u;
 
-	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	AN(w->wfd);
-	AN(w);
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
+	AN(wrw->fd);
+	AN(wrw);
 	AN(hh);
 	AN(hh->b);
 	AN(hh->e);
-	u = WRW_Write(w, hh->b, hh->e - hh->b);
+	u = WRW_Write(wrw, w, hh->b, hh->e - hh->b);
 	if (suf != NULL)
-		u += WRW_Write(w, suf, -1);
+		u += WRW_Write(wrw, w, suf, -1);
 	return (u);
 }
 
 unsigned
-WRW_Write(struct worker *w, const void *ptr, int len)
+WRW_Write(struct wrw_context *wrw, struct worker *w, const void *ptr, int len)
 {
 
 	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
-	AN(w->wfd);
-	if (len == 0 || *w->wfd < 0)
+	CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC);
+
+	AN(wrw->fd);
+	if (len == 0 || *wrw->fd < 0)
 		return (0);
 	if (len == -1)
 		len = strlen(ptr);
-	if (w->niov == MAX_IOVS)
-		(void)WRW_Flush(w);
-	w->iov[w->niov].iov_base = TRUST_ME(ptr);
-	w->iov[w->niov].iov_len = len;
-	w->liov += len;
-	w->niov++;
+	if (wrw->niov == MAX_IOVS)
+		(void)WRW_Flush(wrw, w);
+	wrw->iov[wrw->niov].iov_base = TRUST_ME(ptr);
+	wrw->iov[wrw->niov].iov_len = len;
+	wrw->liov += len;
+	wrw->niov++;
 	return (len);
 }
 



More information about the varnish-commit mailing list