[experimental-ims] ac78724 Move the freshly acceptted session code from cache_pool.c to cache_session.c

Geoff Simmons geoff at varnish-cache.org
Tue Jan 24 18:30:28 CET 2012


commit ac7872447397c2d9a2ff2f74c781a1ad6853aefa
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 23 12:33:27 2012 +0000

    Move the freshly acceptted session code from cache_pool.c to
    cache_session.c

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 8bf15ef..fffb777 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -928,7 +928,6 @@ void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
 #endif  /* SENDFILE_WORKS */
 
 /* cache_session.c [SES] */
-struct sess *SES_New(struct sesspool *pp);
 struct sess *SES_Alloc(void);
 void SES_Close(struct sess *sp, const char *reason);
 void SES_Delete(struct sess *sp, const char *reason, double now);
@@ -940,7 +939,7 @@ void SES_Handle(struct sess *sp, double now);
 void SES_GetReq(struct sess *sp);
 void SES_ReleaseReq(struct sess *sp);
 pool_func_t SES_pool_task;
-
+pool_func_t SES_pool_accept_task;
 
 /* cache_shmlog.c */
 extern struct VSC_C_main *VSC_C_main;
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 656fbc8..28ae2b1 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -190,7 +190,8 @@ pool_accept(struct pool *pp, struct worker *wrk, const struct poolsock *ps)
 		assert(sizeof *wa2 == WS_Reserve(wrk2->ws, sizeof *wa2));
 		wa2 = (void*)wrk2->ws->f;
 		memcpy(wa2, wa, sizeof *wa);
-		wrk2->do_what = pool_do_accept;
+		wrk2->task.func = SES_pool_accept_task;
+		wrk2->task.priv = pp->sesspool;
 		AZ(pthread_cond_signal(&wrk2->cond));
 	}
 }
@@ -342,19 +343,11 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
 		Lck_Unlock(&pp->mtx);
 
 		if (wrk->do_what == pool_do_accept) {
-			/* Turn accepted socket into a session */
-			AZ(wrk->sp);
-			AN(wrk->ws->r);
-			wrk->sp = SES_New(pp->sesspool);
-			if (wrk->sp == NULL) {
-				VCA_FailSess(wrk);
+			SES_pool_accept_task(wrk, pp->sesspool);
+			if (wrk->sp == NULL)
 				wrk->do_what = pool_do_nothing;
-			} else {
-				VCA_SetupSess(wrk);
-				wrk->sp->step = STP_FIRST;
+			else
 				wrk->do_what = pool_do_sess;
-			}
-			WS_Release(wrk->ws, 0);
 		}
 
 		if (wrk->do_what == pool_do_sess) {
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 871ed8f..1079bb9 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -97,8 +97,8 @@ ses_setup(struct sess *sp)
  * Get a new session, preferably by recycling an already ready one
  */
 
-struct sess *
-SES_New(struct sesspool *pp)
+static struct sess *
+ses_new(struct sesspool *pp)
 {
 	struct sess *sp;
 
@@ -127,6 +127,33 @@ SES_Alloc(void)
 	return (sp);
 }
 
+ /*--------------------------------------------------------------------
+ * The pool-task for a newly accepted session
+ */
+
+void
+SES_pool_accept_task(struct worker *wrk, void *arg)
+{
+	struct sesspool *pp;
+
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	CAST_OBJ_NOTNULL(pp, arg, SESSPOOL_MAGIC);
+
+	/* Turn accepted socket into a session */
+	AZ(wrk->sp);
+	AN(wrk->ws->r);
+	wrk->sp = ses_new(pp);
+	if (wrk->sp == NULL) {
+		VCA_FailSess(wrk);
+		return;
+	}
+	VCA_SetupSess(wrk);
+	wrk->sp->step = STP_FIRST;
+	WS_Release(wrk->ws, 0);
+	SES_pool_task(wrk, wrk->sp);
+}
+
+
 
 /*--------------------------------------------------------------------
  * The pool-task function for sessions



More information about the varnish-commit mailing list