Commit ae3733fb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move Pool_Wait() to WAIT_Enter() where it belongs

parent 55d8e88d
......@@ -868,7 +868,6 @@ void PipeSession(struct sess *sp);
/* cache_pool.c */
void Pool_Init(void);
void Pool_Work_Thread(void *priv, struct worker *w);
void Pool_Wait(struct sess *sp);
int Pool_Schedule(struct pool *pp, struct sess *sp);
#define WRW_IsReleased(w) ((w)->wrw.wfd == NULL)
......@@ -893,6 +892,7 @@ void SES_Charge(struct sess *sp);
struct sesspool *SES_NewPool(struct pool *pp);
void SES_DeletePool(struct sesspool *sp, struct worker *wrk);
int SES_Schedule(struct sess *sp);
void SES_Handle(struct sess *sp, int status);
/* cache_shmlog.c */
......@@ -964,6 +964,11 @@ void ESI_DeliverChild(const struct sess *);
/* cache_vrt_vmod.c */
void VMOD_Init(void);
/* cache_waiter.c */
void WAIT_Enter(struct sess *sp);
void WAIT_Init(void);
const char *WAIT_GetName(void);
/* cache_wrk.c */
void WRK_Init(void);
......
......@@ -121,7 +121,7 @@ cnt_wait(struct sess *sp)
WSP(sp, SLT_Debug, "herding");
wrk->stats.sess_herd++;
SES_Charge(sp);
Pool_Wait(sp);
WAIT_Enter(sp);
return (1);
}
if (i == 1) {
......@@ -432,7 +432,7 @@ WSP(sp, SLT_Debug, "PHK req %.9f resp %.9f end %.9f open %.9f",
return (0);
}
wrk->stats.sess_herd++;
Pool_Wait(sp);
WAIT_Enter(sp);
return (1);
}
......
......@@ -48,8 +48,6 @@
#include "cache.h"
#include "common/heritage.h"
#include "waiter/waiter.h"
#include "vtcp.h"
#include "vtim.h"
/*--------------------------------------------------------------------
......@@ -82,8 +80,6 @@ pthread_condattr_setclock(pthread_condattr_t *attr, int foo)
}
#endif /* !CLOCK_MONOTONIC */
static void *waiter_priv;
VTAILQ_HEAD(workerhead, worker);
struct poolsock {
......@@ -349,29 +345,6 @@ Pool_Schedule(struct pool *pp, struct sess *sp)
return (1);
}
/*--------------------------------------------------------------------
* Wait for another request
*/
void
Pool_Wait(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
AZ(sp->vcl);
assert(sp->fd >= 0);
sp->wrk = NULL;
/*
* 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);
}
/*--------------------------------------------------------------------
* Create another thread, if necessary & possible
*/
......@@ -588,7 +561,6 @@ void
Pool_Init(void)
{
waiter_priv = waiter->init();
Lck_New(&pool_mtx, lck_wq);
AZ(pthread_create(&thr_pool_herder, NULL, pool_poolherder, NULL));
}
......@@ -33,10 +33,14 @@
#include <unistd.h>
#include <string.h>
#include "common/common.h"
#include "cache/cache.h"
#include "waiter/waiter.h"
#include "vtcp.h"
static void *waiter_priv;
const char *
WAIT_GetName(void)
{
......@@ -55,4 +59,24 @@ WAIT_Init(void)
AN(waiter->name);
AN(waiter->init);
AN(waiter->pass);
waiter_priv = waiter->init();
}
void
WAIT_Enter(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
AZ(sp->vcl);
assert(sp->fd >= 0);
sp->wrk = NULL;
/*
* 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);
}
......@@ -56,10 +56,3 @@ 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 */
const char *WAIT_GetName(void);
void WAIT_Init(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment