r4046 - in trunk/varnish-cache/bin: varnishd varnishtest varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Fri May 1 12:34:12 CEST 2009


Author: phk
Date: 2009-05-01 12:34:12 +0200 (Fri, 01 May 2009)
New Revision: 4046

Added:
   trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Change the way we close client sessions.

Previously we always used SO_LINGER to make sure that all queued data
got transmitted, no matter under which circumstances we closed the
client connection.

Change this so that SO_LINGER is only activated for orderly connection
closure (ie: "Connection: close" from client or error handling), in
all other cases (usually the client connecting on us, abandon any data
queued for transmission.

This _may_ reduce the tendency of worker threads to get hung up on
network failures a little bit.



Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2009-05-01 09:57:11 UTC (rev 4045)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2009-05-01 10:34:12 UTC (rev 4046)
@@ -68,7 +68,9 @@
 static pthread_t	vca_thread_acct;
 static struct timeval	tv_sndtimeo;
 static struct timeval	tv_rcvtimeo;
-static struct linger	linger;
+static const struct linger linger = {
+	.l_onoff	=	1,
+};
 
 static unsigned char	need_sndtimeo, need_rcvtimeo, need_linger, need_test;
 

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-05-01 09:57:11 UTC (rev 4045)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-05-01 10:34:12 UTC (rev 4046)
@@ -242,8 +242,15 @@
 
 	sp->t_req = NAN;
 
-	if (sp->fd >= 0 && sp->doclose != NULL)
+	if (sp->fd >= 0 && sp->doclose != NULL) {
+		/*
+		 * This is an orderly close of the connection; ditch linger 
+		 * before we close, to get queued data transmitted.
+		 */
+		struct linger lin = { 0, 0 };
+		AZ(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof lin));
 		vca_close_session(sp, sp->doclose);
+	}
 	if (sp->fd < 0) {
 		SES_Charge(sp);
 		VSL_stats->sess_closed++;

Added: trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00029.vtc	2009-05-01 10:34:12 UTC (rev 4046)
@@ -0,0 +1,18 @@
+# $Id$
+
+test "Test orderly connection closure"
+
+
+server s1 {
+	rxreq
+	txresp -bodylen 130000
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+	txreq -hdr "Connection: close"
+	delay 3
+	rxresp
+	expect resp.bodylen == 130000
+} -run

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2009-05-01 09:57:11 UTC (rev 4045)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2009-05-01 10:34:12 UTC (rev 4046)
@@ -769,7 +769,7 @@
 	hp->vl = vl;
 	hp->client = client;
 	hp->timeout = 3000;
-	hp->nrxbuf = 64*1024;
+	hp->nrxbuf = 640*1024;
 	hp->vsb = vsb_newauto();
 	hp->rxbuf = malloc(hp->nrxbuf);		/* XXX */
 	AN(hp->rxbuf);



More information about the varnish-commit mailing list