Add shutdown detection
The maxscale_is_shutting_down function is used to detect when MaxScale should stop. This fixes a race condition in the code where the workers has not yet been initialized but a termination signal has been received. It also replaces the misuse of the service_should_stop variable with a proper function.
This commit is contained in:
@ -36,15 +36,19 @@ int maxscale_uptime()
|
||||
return time(0) - started;
|
||||
}
|
||||
|
||||
static sig_atomic_t n_shutdowns = 0;
|
||||
|
||||
bool maxscale_is_shutting_down()
|
||||
{
|
||||
return n_shutdowns != 0;
|
||||
}
|
||||
|
||||
int maxscale_shutdown()
|
||||
{
|
||||
static int n_shutdowns = 0;
|
||||
|
||||
int n = atomic_add(&n_shutdowns, 1);
|
||||
int n = n_shutdowns++;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
service_shutdown();
|
||||
mxs::RoutingWorker::shutdown_all();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user