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:
@ -24,6 +24,7 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/log.h>
|
||||
#include <maxscale/maxscale.h>
|
||||
#include <maxscale/mysql_utils.h>
|
||||
#include <maxscale/paths.h>
|
||||
#include <maxscale/protocol/mysql.h>
|
||||
@ -923,7 +924,7 @@ static int get_users(SERV_LISTENER *listener, bool skip_local)
|
||||
int total_users = -1;
|
||||
bool no_active_servers = true;
|
||||
|
||||
for (server = service->dbref; !service_should_stop && server; server = server->next)
|
||||
for (server = service->dbref; !maxscale_is_shutting_down() && server; server = server->next)
|
||||
{
|
||||
if (!SERVER_REF_IS_ACTIVE(server) || !server_is_active(server->server) ||
|
||||
(skip_local && server_is_mxs_service(server->server)))
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/log.h>
|
||||
#include <maxscale/maxscale.h>
|
||||
#include <maxscale/pcre2.h>
|
||||
#include <maxscale/utils.h>
|
||||
|
||||
@ -493,7 +494,7 @@ avro_binlog_end_t avro_read_all_events(Avro *router)
|
||||
std::string next_binlog;
|
||||
bool rotate_seen = false;
|
||||
|
||||
while (!service_should_stop)
|
||||
while (!maxscale_is_shutting_down())
|
||||
{
|
||||
avro_binlog_end_t rc;
|
||||
REP_HEADER hdr;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <ini.h>
|
||||
#include <sys/stat.h>
|
||||
#include <maxbase/atomic.h>
|
||||
#include <maxscale/maxscale.h>
|
||||
#include <maxbase/worker.hh>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/dcb.h>
|
||||
@ -328,7 +329,7 @@ static bool conversion_task_ctl(Avro *inst, bool start)
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
if (!service_should_stop)
|
||||
if (!maxscale_is_shutting_down())
|
||||
{
|
||||
Worker* worker = static_cast<Worker*>(mxs_rworker_get(MXS_RWORKER_MAIN));
|
||||
std::unique_ptr<ConversionCtlTask> task(new (std::nothrow) ConversionCtlTask(inst, start));
|
||||
|
Reference in New Issue
Block a user