[3.0] c7b92c9 Try harder to fix solaris IOV_MAX related issue.

Tollef Fog Heen tfheen at varnish-cache.org
Thu Oct 6 11:25:24 CEST 2011


commit c7b92c906bff03e44461878580187903ce48f6a8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Oct 1 01:12:19 2011 +0000

    Try harder to fix solaris IOV_MAX related issue.

diff --git a/bin/varnishd/cache_wrw.c b/bin/varnishd/cache_wrw.c
index 946f488..61aa2e5 100644
--- a/bin/varnishd/cache_wrw.c
+++ b/bin/varnishd/cache_wrw.c
@@ -179,14 +179,16 @@ WRW_Write(struct worker *w, const void *ptr, int len)
 		return (0);
 	if (len == -1)
 		len = strlen(ptr);
-	if (wrw->niov == wrw->siov + (wrw->ciov < wrw->siov ? 1 : 0))
+	if (wrw->niov >= wrw->siov - (wrw->ciov < wrw->siov ? 1 : 0))
 		(void)WRW_Flush(w);
 	wrw->iov[wrw->niov].iov_base = TRUST_ME(ptr);
 	wrw->iov[wrw->niov].iov_len = len;
 	wrw->liov += len;
-	if (wrw->ciov < wrw->siov)
-		wrw->cliov += len;
 	wrw->niov++;
+	if (wrw->ciov < wrw->siov) {
+		assert(wrw->niov < wrw->siov);
+		wrw->cliov += len;
+	}
 	return (len);
 }
 
@@ -208,6 +210,7 @@ WRW_Chunked(struct worker *w)
 	wrw->ciov = wrw->niov++;
 	wrw->cliov = 0;
 	assert(wrw->ciov < wrw->siov);
+	assert(wrw->niov < wrw->siov);
 }
 
 /*



More information about the varnish-commit mailing list