r866 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Aug 21 14:12:17 CEST 2006


Author: phk
Date: 2006-08-21 14:12:16 +0200 (Mon, 21 Aug 2006)
New Revision: 866

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/steps.h
Log:
Create the possiblity for the the acceptor to send the session directly
to the workerpool instead of taking the detour around the session-herder.

This saves a context switch and is presumabley a good idea because the
majority of sessions will have requst already in the pipeline.

For accept filters it makes even more sense because we know this to
be the case.



Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-08-21 11:18:26 UTC (rev 865)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-08-21 12:12:16 UTC (rev 866)
@@ -84,7 +84,16 @@
 	AZ(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv));
 	}
 #endif
+#ifdef SO_RCVTIMEO
+	{
+	struct timeval tv;
 
+	tv.tv_sec = params->sess_timeout;
+	tv.tv_usec = 0;
+	AZ(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv));
+	}
+#endif
+
 	TCP_name(addr, l, sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
 	VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port);
 	return (sp);
@@ -107,6 +116,16 @@
 	WRK_QueueSession(sp);
 }
 
+void
+vca_handfirst(struct sess *sp)
+{
+	sp->step = STP_FIRST;
+	VSL_stats->client_req++;
+	sp->xid = xids++;
+	VSL(SLT_ReqStart, sp->fd, "XID %u", sp->xid);
+	WRK_QueueSession(sp);
+}
+
 /*--------------------------------------------------------------------*/
 
 void

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.h	2006-08-21 11:18:26 UTC (rev 865)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.h	2006-08-21 12:12:16 UTC (rev 866)
@@ -28,4 +28,5 @@
 /* vca_acceptor.c */
 struct sess *vca_accept_sess(int fd);
 void vca_handover(struct sess *sp, int bad);
+void vca_handfirst(struct sess *sp);
 

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2006-08-21 11:18:26 UTC (rev 865)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2006-08-21 12:12:16 UTC (rev 866)
@@ -235,7 +235,37 @@
 	INCOMPL();
 }
 
+static int
+cnt_first(struct sess *sp)
+{
+	int i;
 
+	for (;;) {
+		i = http_RecvSome(sp->fd, sp->http);
+		switch (i) {
+		case -1:
+			continue;
+		case 0:
+			sp->step = STP_RECV;
+			return (0);
+		case 1:
+			vca_close_session(sp, "overflow");
+			SES_Charge(sp);
+			vca_return_session(sp);
+			sp->step = STP_DONE;
+			return (1);
+		case 2:
+			vca_close_session(sp, "no request");
+			SES_Charge(sp);
+			vca_return_session(sp);
+			sp->step = STP_DONE;
+			return (1);
+		default:
+			INCOMPL();
+		}
+	}
+}
+
 /*--------------------------------------------------------------------
  * We had a cache hit.  Ask VCL, then march off as instructed.
  *

Modified: trunk/varnish-cache/bin/varnishd/steps.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/steps.h	2006-08-21 11:18:26 UTC (rev 865)
+++ trunk/varnish-cache/bin/varnishd/steps.h	2006-08-21 12:12:16 UTC (rev 866)
@@ -1,5 +1,6 @@
 /* $Id$ */
 
+STEP(first,	FIRST)
 STEP(recv,	RECV)
 STEP(pipe,	PIPE)
 STEP(pass,	PASS)




More information about the varnish-commit mailing list