]> err.no Git - varnish/commitdiff
More acceptor work:
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Oct 2007 08:14:09 +0000 (08:14 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Oct 2007 08:14:09 +0000 (08:14 +0000)
Make HTC_Rx() return a distinct value for overflow/blast.
Teach vca_handover() to handle HTC_Rx() return status
Use HTC_Rx/vca_handover this way in all three acceptors.
Eliminate vca_pollsession()
Teach CNT_First() about HTC_Rx states.
Log which acceptor we use in shmlog

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

varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_acceptor.h
varnish-cache/bin/varnishd/cache_acceptor_epoll.c
varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
varnish-cache/bin/varnishd/cache_acceptor_poll.c
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_httpconn.c

index 4ef5a3db2e1c71af4bb17fe95522d17186830425..bfb62e9a09e62db5a0f9f45e6d4d241a5e2746ba 100644 (file)
@@ -53,7 +53,6 @@
 #include "cache.h"
 #include "cache_acceptor.h"
 
-
 static struct acceptor *vca_acceptors[] = {
 #if defined(HAVE_KQUEUE)
        &acceptor_kqueue,
@@ -204,34 +203,25 @@ vca_acct(void *arg)
 /*--------------------------------------------------------------------*/
 
 void
-vca_handover(struct sess *sp, int bad)
+vca_handover(struct sess *sp, int status)
 {
 
-       if (bad) {
-               vca_close_session(sp,
-                   bad == 1 ? "overflow" : "no request");
+       switch (status) {
+       case -2:
+               vca_close_session(sp, "blast");
+               SES_Delete(sp);
+               break;
+       case -1:
+               vca_close_session(sp, "no request");
                SES_Delete(sp);
-               return;
+               break;
+       case 1:
+               sp->step = STP_RECV;
+               WRK_QueueSession(sp);
+               break;
+       default:
+               INCOMPL();
        }
-       sp->step = STP_RECV;
-       WRK_QueueSession(sp);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-vca_pollsession(struct sess *sp)
-{
-       int i;
-
-       i = HTC_Rx(sp->htc);
-       /* XXX: fix retval */
-       if (i == 0)     /* more needed */
-               return (-1);
-       if (i == 1)     /* Yes, done */
-               return (0);
-       vca_close_session(sp, "err/poll");
-       return (1);
 }
 
 /*--------------------------------------------------------------------*/
@@ -280,4 +270,5 @@ VCA_Init(void)
        AZ(pipe(vca_pipes));
        vca_act->init();
        AZ(pthread_create(&vca_thread_acct, NULL, vca_acct, NULL));
+       VSL(SLT_Debug, 0, "Acceptor is %s", vca_act->name);
 }
index ce62bc5c60d9703e85bff4c775bf0d2f22897dff..155347b7965370cb0045b5d20459fd55f71695a8 100644 (file)
@@ -52,5 +52,3 @@ extern struct acceptor acceptor_poll;
 
 /* vca_acceptor.c */
 void vca_handover(struct sess *sp, int bad);
-int vca_pollsession(struct sess *sp);
-
index 0b9dd32cb99bc805fe000db325959c3d6f88ae55..6ffd9c26317fc3407b7cac761628bfc6cfb87c76 100644 (file)
@@ -90,15 +90,11 @@ vca_main(void *arg)
                                vca_add(sp->fd, sp);
                        } else {
                                CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC);
-                               i = vca_pollsession(sp);
-                               if (i >= 0) {
+                               i = HTC_Rx(sp->htc);
+                               if (i != 0)
                                        VTAILQ_REMOVE(&sesshead, sp, list);
-                                       if (sp->fd != -1)
-                                               vca_del(sp->fd);
-                                       if (i == 0)
-                                               vca_handover(sp, i);
-                                       else
-                                               SES_Delete(sp);
+                                       vca_del(sp->fd);
+                                       vca_handover(sp, i);
                                }
                        }
                }
index b83aaa554e12aea296055dcac74997929982fde8..b98f4b996dc02ba5baaaf6f2fd830e3e05d591da 100644 (file)
@@ -102,13 +102,8 @@ vca_kev(const struct kevent *kp)
                if (i == 0)
                        return; /* more needed */
                VTAILQ_REMOVE(&sesshead, sp, list);
-               if (i > 0) {
-                       vca_kq_sess(sp, EV_DELETE);
-                       vca_handover(sp, i);
-               } else {
-                       vca_close_session(sp, "err/poll");
-                       SES_Delete(sp);
-               }
+               vca_kq_sess(sp, EV_DELETE);
+               vca_handover(sp, i);
                return;
        } else if (kp->flags == EV_EOF) {
                VTAILQ_REMOVE(&sesshead, sp, list);
index 2853f70d7e93afed2ee178c68171d02542501bd9..8a2587c88169b221214fb84b0ddf2a7cd809ef8a 100644 (file)
@@ -131,15 +131,12 @@ vca_main(void *arg)
                        fd = sp->fd;
                        if (pollfd[fd].revents) {
                                v--;
-                               i = vca_pollsession(sp);
-                               if (i < 0)
+                               i = HTC_Rx(sp->htc);
+                               if (i == 0)
                                        continue;
                                VTAILQ_REMOVE(&sesshead, sp, list);
                                vca_unpoll(fd);
-                               if (i == 0)
-                                       vca_handover(sp, i);
-                               else
-                                       SES_Delete(sp);
+                               vca_handover(sp, i);
                                continue;
                        }
                        if (sp->t_open > deadline)
index 8f307b15005fa7eab04ee343c6ef30c7e27104fc..3462555a14730b0b35a506940939377546be1f22 100644 (file)
@@ -370,17 +370,21 @@ cnt_first(struct sess *sp)
        do
                i = HTC_Rx(sp->htc);
        while (i == 0);
-       if (i == 1) {
+       switch (i) {
+       case 1:
                sp->step = STP_RECV;
-               return (0);
-       }
-       if (i == -1)
+               break;
+       case -1:
+               vca_close_session(sp, "error");
+               sp->step = STP_DONE;
+               break;
+       case -2:
                vca_close_session(sp, "blast");
-       else if (i == 2)
-               vca_close_session(sp, "silent");
-       else
+               sp->step = STP_DONE;
+               break;
+       default:
                INCOMPL();
-       sp->step = STP_DONE;
+       }
        return (0);
 }
 
index c0fd04cf8cf70ee3bff29f6ed78ad7644aa018f7..2129e59d98171b05c30d8e853c23567a9bd8599f 100644 (file)
@@ -126,6 +126,7 @@ HTC_Reinit(struct http_conn *htc)
 /*--------------------------------------------------------------------
  * Receive more HTTP protocol bytes
  * Returns:
+ *     -2 overflow
  *     -1 error
  *      0 more needed
  *      1 got complete HTTP header
@@ -138,9 +139,12 @@ HTC_Rx(struct http_conn *htc)
 
        CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
        i = (htc->ws->r - htc->rxbuf.e) - 1;    /* space for NUL */
-       if (i > 0)
-               i = read(htc->fd, htc->rxbuf.e, i);
        if (i <= 0) {
+               WS_ReleaseP(htc->ws, htc->rxbuf.b);
+               return (-2);
+       }
+       i = read(htc->fd, htc->rxbuf.e, i);
+       if (i < 0) {
                WS_ReleaseP(htc->ws, htc->rxbuf.b);
                return (-1);
        }