Destroy monitor only if it's not used

If a service uses a monitor as the source of its servers, it must not be
destroyed before the monitor is removed from all services that use it.
This commit is contained in:
Markus Mäkelä
2019-04-01 10:46:33 +03:00
parent 84bf241dd1
commit 1417292f0d
3 changed files with 43 additions and 10 deletions

View File

@ -840,6 +840,21 @@ Service* service_internal_find(const char* name)
return nullptr;
}
Service* service_uses_monitor(mxs::Monitor* monitor)
{
LockGuard guard(this_unit.lock);
for (Service* s : this_unit.services)
{
if (s->m_monitor == monitor)
{
return s;
}
}
return nullptr;
}
/**
* Return a named service
*