]> err.no Git - varnish/commitdiff
Create the possiblity for the the acceptor to send the session directly
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 21 Aug 2006 12:12:16 +0000 (12:12 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 21 Aug 2006 12:12:16 +0000 (12:12 +0000)
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.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@866 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_acceptor.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/steps.h

index ef84e85ddf6cbb0e837bd07f793f91572f1641d7..4ff494fc9e0e5787c0280c2145cfb6c7a237d440 100644 (file)
@@ -84,6 +84,15 @@ vca_accept_sess(int fd)
        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);
@@ -107,6 +116,16 @@ vca_handover(struct sess *sp, int bad)
        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
index c78ab2c7b31d6725d7f65ce814685b5a390f88b7..5746f4f4927b30a219415377be031d97265b9e9d 100644 (file)
@@ -28,4 +28,5 @@ extern struct acceptor acceptor_poll;
 /* vca_acceptor.c */
 struct sess *vca_accept_sess(int fd);
 void vca_handover(struct sess *sp, int bad);
+void vca_handfirst(struct sess *sp);
 
index cf6d43206a424842a77b974aaeffb6947b5884fb..b4468a48240ff0837d221130eb7903e94402debf 100644 (file)
@@ -235,6 +235,36 @@ cnt_fetch(struct sess *sp)
        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.
index 1e2a9bd7f645064a5f76879bf888e94f268a39a9..eff825a8b1dd51f210ca1edd3be7647610b568fd 100644 (file)
@@ -1,5 +1,6 @@
 /* $Id$ */
 
+STEP(first,    FIRST)
 STEP(recv,     RECV)
 STEP(pipe,     PIPE)
 STEP(pass,     PASS)