Fix monitor repurposing
The monitor active state is now modified under the same lock. This should make creation and destruction of monitors deterministic.
This commit is contained in:
parent
1743f4c1b7
commit
05d185fc02
@ -841,11 +841,11 @@ bool runtime_create_monitor(const char *name, const char *module)
|
||||
if (monitor_find(name) == NULL)
|
||||
{
|
||||
|
||||
MXS_MONITOR *monitor = monitor_find_destroyed(name, module);
|
||||
MXS_MONITOR *monitor = monitor_repurpose_destroyed(name, module);
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
monitor->active = true;
|
||||
MXS_DEBUG("Repurposed monitor '%s'", name);
|
||||
}
|
||||
else if ((monitor = monitor_alloc(name, module)) == NULL)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ void monitorStopAll();
|
||||
void monitorStartAll();
|
||||
|
||||
MXS_MONITOR *monitor_find(const char *);
|
||||
MXS_MONITOR* monitor_find_destroyed(const char* name, const char* module);
|
||||
MXS_MONITOR* monitor_repurpose_destroyed(const char* name, const char* module);
|
||||
|
||||
void monitorShow(DCB *, MXS_MONITOR *);
|
||||
void monitorShowAll(DCB *);
|
||||
|
@ -236,9 +236,9 @@ monitorStop(MXS_MONITOR *monitor)
|
||||
|
||||
void monitorDestroy(MXS_MONITOR* monitor)
|
||||
{
|
||||
spinlock_acquire(&monitor->lock);
|
||||
spinlock_acquire(&monLock);
|
||||
monitor->active = false;
|
||||
spinlock_release(&monitor->lock);
|
||||
spinlock_release(&monLock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,7 +574,7 @@ monitor_find(const char *name)
|
||||
* @param name The name of the monitor
|
||||
* @return Pointer to the destroyed monitor or NULL if monitor is not found
|
||||
*/
|
||||
MXS_MONITOR* monitor_find_destroyed(const char* name, const char* module)
|
||||
MXS_MONITOR* monitor_repurpose_destroyed(const char* name, const char* module)
|
||||
{
|
||||
MXS_MONITOR* rval = NULL;
|
||||
|
||||
@ -584,6 +584,8 @@ MXS_MONITOR* monitor_find_destroyed(const char* name, const char* module)
|
||||
{
|
||||
if (strcmp(ptr->name, name) == 0 && strcmp(ptr->module_name, module) == 0)
|
||||
{
|
||||
ss_dassert(!ptr->active);
|
||||
ptr->active = true;
|
||||
rval = ptr;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user