MXS-2547: Do shutdown on main worker

By stopping the REST API before the workers and moving the shutdown to the
same worker that handles REST API requests, we prevent the hang on
shutdown. This also makes the signal handler signal-safe.
This commit is contained in:
Markus Mäkelä 2019-06-18 11:23:14 +03:00
parent 69b3879357
commit 27fb397041
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 16 additions and 7 deletions

View File

@ -410,6 +410,7 @@ bool mxs_admin_init()
void mxs_admin_shutdown()
{
MHD_stop_daemon(http_daemon);
MXS_NOTICE("Stopped MaxScale REST API");
}
bool mxs_admin_https_enabled()

View File

@ -2293,9 +2293,6 @@ int main(int argc, char **argv)
/*< Stop all the monitors */
monitorStopAll();
/** Stop administrative interface */
mxs_admin_shutdown();
/*< Stop all the monitors */
monitorStopAll();
@ -2380,6 +2377,19 @@ return_main:
return rc;
} /*< End of main */
class ShutdownTask: public Worker::DisposableTask
{
public:
void execute(mxs::Worker& w)
{
mxs_admin_shutdown();
service_shutdown();
Worker::shutdown_all();
hkshutdown();
log_flush_shutdown();
}
};
/*<
* Shutdown MaxScale server
*/
@ -2391,10 +2401,8 @@ int maxscale_shutdown()
if (n == 0)
{
service_shutdown();
Worker::shutdown_all();
hkshutdown();
log_flush_shutdown();
mxs::Worker* worker = Worker::get(0);
worker->post(std::auto_ptr<ShutdownTask>(new ShutdownTask), mxs::Worker::EXECUTE_QUEUED);
}
return n + 1;