[master] 0841b65 Move vca_return_session() to Pool_Wait()
Poul-Henning Kamp
phk at varnish-cache.org
Sat Sep 17 16:45:18 CEST 2011
commit 0841b65418d21eed601be56abefb4f56b462d750
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Sep 17 14:44:53 2011 +0000
Move vca_return_session() to Pool_Wait()
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 5d44092..4fd7086 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -645,7 +645,6 @@ struct vbc {
/* Prototypes etc ----------------------------------------------------*/
/* cache_acceptor.c */
-void vca_return_session(struct sess *sp);
void VCA_Prep(struct sess *sp);
void VCA_Init(void);
void VCA_Shutdown(void);
@@ -840,6 +839,7 @@ void PipeSession(struct sess *sp);
void Pool_Init(void);
int Pool_QueueSession(struct sess *sp);
void Pool_Work_Thread(void *priv, struct worker *w);
+void Pool_Wait(struct sess *sp);
#define WRW_IsReleased(w) ((w)->wrw.wfd == NULL)
int WRW_Error(const struct worker *w);
diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index 3781f47..23752f3 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -40,9 +40,6 @@
#include "vcli.h"
#include "cli_priv.h"
#include "cache.h"
-#include "cache_waiter.h"
-
-static void *waiter_priv;
pthread_t VCA_thread;
static struct timeval tv_sndtimeo;
@@ -298,25 +295,6 @@ vca_acct(void *arg)
/*--------------------------------------------------------------------*/
-void
-vca_return_session(struct sess *sp)
-{
-
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- AZ(sp->obj);
- AZ(sp->vcl);
- assert(sp->fd >= 0);
- /*
- * Set nonblocking in the worker-thread, before passing to the
- * acceptor thread, to reduce syscall density of the latter.
- */
- if (VTCP_nonblocking(sp->fd))
- SES_Close(sp, "remote closed");
- waiter->pass(waiter_priv, sp);
-}
-
-/*--------------------------------------------------------------------*/
-
static void
ccf_start(struct cli *cli, const char * const *av, void *priv)
{
@@ -325,14 +303,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
(void)av;
(void)priv;
- AN(waiter);
- AN(waiter->name);
- AN(waiter->init);
- AN(waiter->pass);
-
- waiter_priv = waiter->init();
AZ(pthread_create(&VCA_thread, NULL, vca_acct, NULL));
- VSL(SLT_Debug, 0, "Acceptor is %s", waiter->name);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 24b0ddc..b561c84 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -108,7 +108,7 @@ cnt_wait(struct sess *sp)
sp->wrk->stats.sess_herd++;
SES_Charge(sp);
sp->wrk = NULL;
- vca_return_session(sp);
+ Pool_Wait(sp);
return (1);
}
if (i == 1) {
@@ -398,7 +398,7 @@ cnt_done(struct sess *sp)
}
sp->wrk->stats.sess_herd++;
sp->wrk = NULL;
- vca_return_session(sp);
+ Pool_Wait(sp);
return (1);
}
diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c
index 92e81b1..0bbb76d 100644
--- a/bin/varnishd/cache_pool.c
+++ b/bin/varnishd/cache_pool.c
@@ -54,9 +54,12 @@
#include "vcl.h"
#include "cli_priv.h"
#include "cache.h"
+#include "cache_waiter.h"
#include "stevedore.h"
#include "hash_slinger.h"
+static void *waiter_priv;
+
VTAILQ_HEAD(workerhead, worker);
/* Number of work requests queued in excess of worker threads available */
@@ -454,6 +457,27 @@ wrk_herder_thread(void *priv)
NEEDLESS_RETURN(NULL);
}
+/*--------------------------------------------------------------------
+ * Wait for another request
+ */
+
+void
+Pool_Wait(struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ AZ(sp->obj);
+ AZ(sp->vcl);
+ assert(sp->fd >= 0);
+ /*
+ * Set nonblocking in the worker-thread, before passing to the
+ * acceptor thread, to reduce syscall density of the latter.
+ */
+ if (VTCP_nonblocking(sp->fd))
+ SES_Close(sp, "remote closed");
+ waiter->pass(waiter_priv, sp);
+}
+
/*--------------------------------------------------------------------*/
void
@@ -464,6 +488,8 @@ Pool_Init(void)
AZ(pthread_cond_init(&herder_cond, NULL));
Lck_New(&herder_mtx, lck_herder);
+ waiter_priv = waiter->init();
+
wrk_addpools(params->wthread_pools);
AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL));
AZ(pthread_detach(tp));
diff --git a/bin/varnishd/cache_waiter.h b/bin/varnishd/cache_waiter.h
index 4377f82..28bc39d 100644
--- a/bin/varnishd/cache_waiter.h
+++ b/bin/varnishd/cache_waiter.h
@@ -53,11 +53,12 @@ extern const struct waiter waiter_kqueue;
extern const struct waiter waiter_ports;
#endif
-extern const struct waiter waiter_poll;
/* cache_session.c */
void SES_Handle(struct sess *sp, int status);
+/* cache_waiter.c */
+extern const struct waiter waiter_poll;
const char *WAIT_GetName(void);
void WAIT_tweak_waiter(struct cli *cli, const char *arg);
void WAIT_Init(void);
More information about the varnish-commit
mailing list