[experimental-ims] 09c459c Eliminate the cnt_start state by folding it into cnt_recv

Poul-Henning Kamp phk at FreeBSD.org
Thu Dec 18 10:27:53 CET 2014


commit 09c459cb263f2551213d52fb4c56b27e7757cf71
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Aug 13 06:48:12 2012 +0000

    Eliminate the cnt_start state by folding it into cnt_recv

diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 0cee630..31e0a46 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -50,7 +50,7 @@
  *DOT	hash -> CNT_Request [label="Busy object\nS_STP_WORKING\nR_STP_LOOKUP"
  *DOT		color=blue]
  *DOT	disembark -> hash [style=dotted, color=blue]
- *DOT	http1_wait -> CNT_Request [label="S_STP_WORKING\nR_STP_START"]
+ *DOT	http1_wait -> CNT_Request [label="S_STP_WORKING\nR_STP_RECV"]
  *DOT	http1_wait -> disembark [label="Session close"]
  *DOT	http1_wait -> disembark [label="Timeout" color=green]
  *DOT	disembark -> waiter [style=dotted, color=green]
@@ -59,7 +59,7 @@
  *DOT		[label="Busy object\nS_STP_WORKING\nR_STP_LOOKUP" color=blue]
  *DOT	CNT_Request -> http1_cleanup
  *DOT	http1_cleanup -> disembark [label="Session close"]
- *DOT	http1_cleanup -> CNT_Request [label="S_STP_WORKING\nR_STP_START"]
+ *DOT	http1_cleanup -> CNT_Request [label="S_STP_WORKING\nR_STP_RECV"]
  *DOT	http1_cleanup -> http1_wait [label="S_STP_NEWREQ"]
  *DOT
  *DOT	}
@@ -331,10 +331,10 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 		assert(
 		    sp->sess_step == S_STP_NEWREQ ||
 		    req->req_step == R_STP_LOOKUP ||
-		    req->req_step == R_STP_START);
+		    req->req_step == R_STP_RECV);
 
 		if (sp->sess_step == S_STP_WORKING) {
-			if (req->req_step == R_STP_START)
+			if (req->req_step == R_STP_RECV)
 				done = http1_dissect(wrk, req);
 			if (done == 0)
 				done = CNT_Request(wrk, req);
@@ -350,7 +350,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 				break;
 			case SESS_DONE_RET_START:
 				sp->sess_step = S_STP_WORKING;
-				req->req_step = R_STP_START;
+				req->req_step = R_STP_RECV;
 				break;
 			default:
 				WRONG("Illegal enum http1_cleanup_ret");
@@ -362,7 +362,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 			if (done)
 				return;
 			sp->sess_step = S_STP_WORKING;
-			req->req_step = R_STP_START;
+			req->req_step = R_STP_RECV;
 		}
 	}
 }
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index b809c6d..0fbca29 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -1105,6 +1105,16 @@ cnt_recv(const struct worker *wrk, struct req *req)
 	AZ(req->obj);
 	AZ(req->busyobj);
 
+	/* Assign XID and log */
+	req->xid = ++xids;				/* XXX not locked */
+	VSLb(req->vsl, SLT_ReqStart, "%s %s %u",
+	    req->sp->addr, req->sp->port, req->xid);
+
+	if (req->err_code) {
+		req->req_step = R_STP_ERROR;
+		return (0);
+	}
+
 	/* By default we use the first backend */
 	AZ(req->director);
 	req->director = req->vcl->director[0];
@@ -1169,42 +1179,6 @@ cnt_recv(const struct worker *wrk, struct req *req)
 }
 
 /*--------------------------------------------------------------------
- * START
- * First time we see a request
- *
-DOT start [
-DOT	shape=box
-DOT	label="cnt_start:\nDissect request\nHandle expect"
-DOT ]
-DOT start -> recv [style=bold,color=green]
-DOT start -> DONE [label=errors]
- */
-
-static int
-cnt_start(struct worker *wrk, struct req *req)
-{
-
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	AZ(req->restarts);
-	AZ(req->obj);
-	AN(req->vcl);
-	AZ(req->esi_level);
-	assert(!isnan(req->t_req));
-
-	/* Assign XID and log */
-	req->xid = ++xids;				/* XXX not locked */
-	VSLb(req->vsl, SLT_ReqStart, "%s %s %u",
-	    req->sp->addr, req->sp->port, req->xid);
-
-	if (req->err_code)
-		req->req_step = R_STP_ERROR;
-	else
-		req->req_step = R_STP_RECV;
-	return (0);
-}
-
-/*--------------------------------------------------------------------
  * Central state engine dispatcher.
  *
  * Kick the session around until it has had enough.
@@ -1235,8 +1209,7 @@ CNT_Request(struct worker *wrk, struct req *req)
 	 */
 	assert(
 	    req->req_step == R_STP_LOOKUP ||
-	    req->req_step == R_STP_START ||
-	    req->req_step == R_STP_RECV);	// from ESI
+	    req->req_step == R_STP_RECV);
 
 	req->wrk = wrk;
 
diff --git a/include/tbl/steps.h b/include/tbl/steps.h
index cef939b..3ceaa5e 100644
--- a/include/tbl/steps.h
+++ b/include/tbl/steps.h
@@ -38,7 +38,6 @@ SESS_STEP(working,	WORKING)
 #ifdef REQ_STEP
 REQ_STEP(restart,	RESTART,	(wrk, req))
 REQ_STEP(recv,		RECV,		(wrk, req))
-REQ_STEP(start,		START,		(wrk, req))
 REQ_STEP(pipe,		PIPE,		(wrk, req))
 REQ_STEP(pass,		PASS,		(wrk, req))
 REQ_STEP(lookup,	LOOKUP,		(wrk, req))



More information about the varnish-commit mailing list