MXS-1848 Destroy all monitors at system shutdown
This commit is contained in:
@ -2240,15 +2240,15 @@ int main(int argc, char **argv)
|
|||||||
ss_dassert(worker);
|
ss_dassert(worker);
|
||||||
worker->run();
|
worker->run();
|
||||||
|
|
||||||
/*< Stop all the monitors */
|
|
||||||
monitor_stop_all();
|
|
||||||
|
|
||||||
/** Stop administrative interface */
|
/** Stop administrative interface */
|
||||||
mxs_admin_shutdown();
|
mxs_admin_shutdown();
|
||||||
|
|
||||||
/*< Stop all the monitors */
|
/*< Stop all monitors */
|
||||||
monitor_stop_all();
|
monitor_stop_all();
|
||||||
|
|
||||||
|
/*< Destroy all monitors */
|
||||||
|
monitor_destroy_all();
|
||||||
|
|
||||||
/*<
|
/*<
|
||||||
* Wait for the housekeeper to finish.
|
* Wait for the housekeeper to finish.
|
||||||
*/
|
*/
|
||||||
|
@ -66,6 +66,14 @@ void monitor_deactivate(MXS_MONITOR* monitor);
|
|||||||
void monitor_stop_all();
|
void monitor_stop_all();
|
||||||
void monitor_start_all();
|
void monitor_start_all();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroys all monitors. At this point all monitors should
|
||||||
|
* have been stopped.
|
||||||
|
*
|
||||||
|
* @attn Must only be called in single-thread context at system shutdown.
|
||||||
|
*/
|
||||||
|
void monitor_destroy_all();
|
||||||
|
|
||||||
MXS_MONITOR *monitor_find(const char *);
|
MXS_MONITOR *monitor_find(const char *);
|
||||||
MXS_MONITOR* monitor_repurpose_destroyed(const char* name, const char* module);
|
MXS_MONITOR* monitor_repurpose_destroyed(const char* name, const char* module);
|
||||||
|
|
||||||
|
@ -169,8 +169,6 @@ monitor_destroy(MXS_MONITOR *mon)
|
|||||||
{
|
{
|
||||||
MXS_MONITOR *ptr;
|
MXS_MONITOR *ptr;
|
||||||
|
|
||||||
mon->api->stopMonitor(mon->instance);
|
|
||||||
mon->state = MONITOR_STATE_FREED;
|
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
if (allMonitors == mon)
|
if (allMonitors == mon)
|
||||||
{
|
{
|
||||||
@ -189,6 +187,8 @@ monitor_destroy(MXS_MONITOR *mon)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
spinlock_release(&monLock);
|
spinlock_release(&monLock);
|
||||||
|
mon->api->destroyInstance(mon->instance);
|
||||||
|
mon->state = MONITOR_STATE_FREED;
|
||||||
config_parameter_free(mon->parameters);
|
config_parameter_free(mon->parameters);
|
||||||
monitor_server_free_all(mon->monitored_servers);
|
monitor_server_free_all(mon->monitored_servers);
|
||||||
MXS_FREE(mon->name);
|
MXS_FREE(mon->name);
|
||||||
@ -196,6 +196,18 @@ monitor_destroy(MXS_MONITOR *mon)
|
|||||||
MXS_FREE(mon);
|
MXS_FREE(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void monitor_destroy_all()
|
||||||
|
{
|
||||||
|
// monitor_destroy() grabs 'monLock', so it cannot be grabbed here
|
||||||
|
// without additional changes. But this function should only be
|
||||||
|
// called at system shutdown in single-thread context.
|
||||||
|
|
||||||
|
while (allMonitors)
|
||||||
|
{
|
||||||
|
MXS_MONITOR *monitor = allMonitors;
|
||||||
|
monitor_destroy(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an individual monitor that has previously been stopped.
|
* Start an individual monitor that has previously been stopped.
|
||||||
@ -294,18 +306,18 @@ void monitor_deactivate(MXS_MONITOR* monitor)
|
|||||||
void
|
void
|
||||||
monitor_stop_all()
|
monitor_stop_all()
|
||||||
{
|
{
|
||||||
MXS_MONITOR *ptr;
|
|
||||||
|
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
ptr = allMonitors;
|
|
||||||
while (ptr)
|
MXS_MONITOR* monitor = allMonitors;
|
||||||
|
while (monitor)
|
||||||
{
|
{
|
||||||
if (ptr->active)
|
if (monitor->active)
|
||||||
{
|
{
|
||||||
monitor_stop(ptr);
|
monitor_stop(monitor);
|
||||||
}
|
}
|
||||||
ptr = ptr->next;
|
monitor = monitor->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_release(&monLock);
|
spinlock_release(&monLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user