]> err.no Git - varnish/commitdiff
If after handling a request we find anything in our input buffer,
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Sep 2006 07:37:20 +0000 (07:37 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Sep 2006 07:37:20 +0000 (07:37 +0000)
don't waste time putting the session on the herder, but go right
back and take the next request in the current worker thread.

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

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

index 293fdbf6a2fc5c5116922bc89006206f539b0ceb..68b0a9d3dabaf050d41cbed6e205994276db5cb1 100644 (file)
@@ -158,14 +158,6 @@ vca_return_session(struct sess *sp)
        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
        AZ(sp->obj);
        AZ(sp->vcl);
-       if (sp->fd >= 0) {
-               VSL(SLT_SessionReuse, sp->fd, "%s %s", sp->addr, sp->port);
-               sp->t_open = sp->t_end;
-               if (http_RecvPrepAgain(sp->http)) {
-                       vca_handover(sp, 0);
-                       return;
-               }
-       }
        vca_act->recycle(sp);
 }
 
index 93b6a5af793607f677faa701eab54dc9dc107e01..5317d6b4af4274244612182ae307886b5f4f3849 100644 (file)
@@ -40,6 +40,39 @@ DOT start -> RECV
 
 static unsigned xids;
 
+/*--------------------------------------------------------------------
+ * The very first request
+ */
+static int
+cnt_again(struct sess *sp)
+{
+       int i;
+
+       assert(sp->xid == 0);
+       sp->wrk->idle = sp->t_open.tv_sec;
+
+       if (http_RecvPrepAgain(sp->http)) {
+               sp->step = STP_RECV;
+               return (0);
+       }
+       do 
+               i = http_RecvSome(sp->fd, sp->http);
+       while (i == -1);
+       if (i == 0) {
+               sp->step = STP_RECV;
+               return (0);
+       }
+       if (i == 1)
+               vca_close_session(sp, "overflow");
+       else if (i == 2)
+               vca_close_session(sp, "no request");
+       else
+               INCOMPL();
+       sp->step = STP_DONE;
+       return (0);
+}
+
+
 /*--------------------------------------------------------------------
  * We have a refcounted object on the session, now deliver it.
  *
@@ -120,6 +153,23 @@ cnt_done(struct sess *sp)
            (long)sp->t_end.tv_sec, (long)sp->t_end.tv_nsec,
            dh, dp, da);
 
+       sp->xid = 0;
+       sp->t_open = sp->t_end;
+       if (sp->fd > 0) {
+               VSL(SLT_SessionReuse, sp->fd, "%s %s", sp->addr, sp->port);
+
+               /* If we have anything in the input buffer, start over */
+               /*
+                * XXX: we might even want to do a short timed read (poll)
+                * XXX: here to see if something is pending in the kernel
+                */
+               
+               if (sp->http->t < sp->http->v) {
+                       sp->step = STP_AGAIN;
+                       return (0);
+               }
+       }
+
        SES_Charge(sp);
        vca_return_session(sp);
        return (1);
index eff825a8b1dd51f210ca1edd3be7647610b568fd..4ce97f17aa1add90ad1d4deb767b4a7e3280a2e5 100644 (file)
@@ -1,5 +1,6 @@
 /* $Id$ */
 
+STEP(again,    AGAIN)
 STEP(first,    FIRST)
 STEP(recv,     RECV)
 STEP(pipe,     PIPE)