Commit 5a28588f authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Delay the accept task until all initialization has been completed.

This resolves the race where the pools might accept connections and
start processing them before a lot of the initialization routines has
finished.
parent bf16286c
......@@ -940,6 +940,7 @@ void PipeRequest(struct req *req);
/* cache_pool.c */
void Pool_Init(void);
void Pool_Accept(void);
void Pool_Work_Thread(void *priv, struct worker *w);
int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how);
......
......@@ -228,6 +228,8 @@ child_main(void)
if (FEATURE(FEATURE_WAIT_SILO))
SMP_Ready();
Pool_Accept();
CLI_Run();
STV_close();
......
......@@ -76,6 +76,7 @@ struct pool {
static struct lock pool_mtx;
static pthread_t thr_pool_herder;
static unsigned pool_accepting = 0;
/*--------------------------------------------------------------------
*/
......@@ -128,6 +129,12 @@ pool_accept(struct worker *wrk, void *arg)
CHECK_OBJ_NOTNULL(ps->lsock, LISTEN_SOCK_MAGIC);
assert(sizeof *wa == WS_Reserve(wrk->aws, sizeof *wa));
wa = (void*)wrk->aws->f;
/* Delay until we are ready (flag is set when all
* initialization has finished) */
while (!pool_accepting)
VTIM_sleep(.1);
while (1) {
memset(wa, 0, sizeof *wa);
wa->magic = WRK_ACCEPT_MAGIC;
......@@ -483,6 +490,14 @@ pool_poolherder(void *priv)
/*--------------------------------------------------------------------*/
void
Pool_Accept(void)
{
ASSERT_CLI();
pool_accepting = 1;
}
void
Pool_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