r4183 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Aug 17 12:53:18 CEST 2009


Author: phk
Date: 2009-08-17 12:53:17 +0200 (Mon, 17 Aug 2009)
New Revision: 4183

Modified:
   trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c
   trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c
   trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c
   trunk/varnish-cache/bin/varnishd/cache_waiter_ports.c
Log:
Disable SO_LINGER when we time out a connection due to sess_timeout,
so that we do not RST connections that have still not transmitted their
data.

Since we were able to get the writev(2) to detach the socket, we should
not end up sleeping in the close(2) either.

We still RST the socket for all error conditions.

Ideally I would still like to RST connections that have no outstanding
data after their sess_timeout, in order to avoid the 2*RTT+misc
timeouts delays associated with loosing a TCP socket for a client
that have gone to meet some other IP#.

In particular with load-balancers, this allows the load balancer to
declare the session dead right away, and reuse it for something more
productive.

Unfortunately, this lacks OS support in all presently released
OS'es: you cannot ask if a socket is done transmitting what you
asked it to.

FreeBSD-8.0 will have experimental support for this (FIONWRITE)
and I will revisit it in that context.




Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c	2009-08-17 08:45:36 UTC (rev 4182)
+++ trunk/varnish-cache/bin/varnishd/cache_waiter_epoll.c	2009-08-17 10:53:17 UTC (rev 4183)
@@ -190,6 +190,7 @@
 			if (sp->t_open > deadline)
 				break;
 			VTAILQ_REMOVE(&sesshead, sp, list);
+			TCP_linger(sp->fd, 0);
 			vca_close_session(sp, "timeout");
 			SES_Delete(sp);
 		}

Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c	2009-08-17 08:45:36 UTC (rev 4182)
+++ trunk/varnish-cache/bin/varnishd/cache_waiter_kqueue.c	2009-08-17 10:53:17 UTC (rev 4183)
@@ -198,6 +198,7 @@
 			if (sp->t_open > deadline)
 				break;
 			VTAILQ_REMOVE(&sesshead, sp, list);
+			TCP_linger(sp->fd, 0);
 			vca_close_session(sp, "timeout");
 			SES_Delete(sp);
 		}

Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c	2009-08-17 08:45:36 UTC (rev 4182)
+++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c	2009-08-17 10:53:17 UTC (rev 4183)
@@ -147,6 +147,7 @@
 				continue;
 			VTAILQ_REMOVE(&sesshead, sp, list);
 			vca_unpoll(fd);
+			TCP_linger(sp->fd, 0);
 			vca_close_session(sp, "timeout");
 			SES_Delete(sp);
 		}

Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_ports.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_waiter_ports.c	2009-08-17 08:45:36 UTC (rev 4182)
+++ trunk/varnish-cache/bin/varnishd/cache_waiter_ports.c	2009-08-17 10:53:17 UTC (rev 4183)
@@ -139,6 +139,7 @@
 			VTAILQ_REMOVE(&sesshead, sp, list);
 			if(sp->fd != -1)
 				vca_del(sp->fd);
+			TCP_linger(sp->fd, 0);
 			vca_close_session(sp, "timeout");
 			SES_Delete(sp);
 		}



More information about the varnish-commit mailing list