[experimental-ims] 6d50fb2 Try harder to fix solaris IOV_MAX related issue.

Geoff Simmons geoff at varnish-cache.org
Mon Jan 9 21:52:02 CET 2012


commit 6d50fb287fda1826020bef4e0256d83d35c68d83
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