{
struct per_thread_init_fct *ptif;
struct per_thread_deinit_fct *ptdf;
- __decl_hathreads(static HA_SPINLOCK_T start_lock);
ha_set_tid((unsigned long)data);
tv_update_date(-1,-1);
}
}
- if ((global.mode & MODE_MWORKER) && master == 0) {
- HA_SPIN_LOCK(START_LOCK, &start_lock);
- mworker_pipe_register();
- HA_SPIN_UNLOCK(START_LOCK, &start_lock);
- }
-
/* broadcast that we are ready and wait for other threads to finish
* their initialization.
*/
}
/*
- * This function register the accept wrapper for the sockpair of the master worker
+ * This function registers the accept wrapper for the sockpair of the master
+ * worker. It's only handled by worker thread #0. Other threads and master do
+ * nothing here. It always returns 1 (success).
*/
-void mworker_pipe_register()
+static int mworker_pipe_register_per_thread()
{
- /* The iocb should be already initialized with listener_accept */
- if (fdtab[proc_self->ipc_fd[1]].iocb == mworker_accept_wrapper)
- return;
+ if (!(global.mode & MODE_MWORKER) || master)
+ return 1;
+
+ if (tid != 0)
+ return 1;
fcntl(proc_self->ipc_fd[1], F_SETFL, O_NONBLOCK);
/* In multi-tread, we need only one thread to process
* events on the pipe with master
*/
- fd_insert(proc_self->ipc_fd[1], fdtab[proc_self->ipc_fd[1]].owner, mworker_accept_wrapper, 1);
+ fd_insert(proc_self->ipc_fd[1], fdtab[proc_self->ipc_fd[1]].owner, mworker_accept_wrapper, tid_bit);
fd_want_recv(proc_self->ipc_fd[1]);
+ return 1;
}
+REGISTER_PER_THREAD_INIT(mworker_pipe_register_per_thread);
+
/* ----- proxies ----- */
/*
* Upon a reload, the master worker needs to close all listeners FDs but the mworker_pipe