r2084 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Oct 8 10:14:10 CEST 2007


Author: phk
Date: 2007-10-08 10:14:09 +0200 (Mon, 08 Oct 2007)
New Revision: 2084

Modified:
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor.h
   trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_httpconn.c
Log:
More acceptor work:

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



Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -53,7 +53,6 @@
 #include "cache.h"
 #include "cache_acceptor.h"
 
-
 static struct acceptor *vca_acceptors[] = {
 #if defined(HAVE_KQUEUE)
 	&acceptor_kqueue,
@@ -204,38 +203,29 @@
 /*--------------------------------------------------------------------*/
 
 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);
-		return;
+		break;
+	case -1:
+		vca_close_session(sp, "no request");
+		SES_Delete(sp);
+		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);
-}
-
-/*--------------------------------------------------------------------*/
-
 void
 vca_close_session(struct sess *sp, const char *why)
 {
@@ -280,4 +270,5 @@
 	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);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.h	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.h	2007-10-08 08:14:09 UTC (rev 2084)
@@ -52,5 +52,3 @@
 
 /* vca_acceptor.c */
 void vca_handover(struct sess *sp, int bad);
-int vca_pollsession(struct sess *sp);
-

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -90,15 +90,11 @@
 				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);
 				}
 			}
 		}

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -102,13 +102,8 @@
 		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);

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -131,15 +131,12 @@
 			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)

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -370,17 +370,21 @@
 	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);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpconn.c	2007-10-08 07:51:31 UTC (rev 2083)
+++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c	2007-10-08 08:14:09 UTC (rev 2084)
@@ -126,6 +126,7 @@
 /*--------------------------------------------------------------------
  * Receive more HTTP protocol bytes
  * Returns:
+ *	-2 overflow
  *	-1 error
  *	 0 more needed
  *	 1 got complete HTTP header
@@ -138,10 +139,13 @@
 
 	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);
 	}
 	htc->rxbuf.e += i;




More information about the varnish-commit mailing list