MXS-1929: Close listener DCBs

When a service is freed, it will free all of its listeners causing their
respective DCBs to be closed. This requires that listeners can be removed
from the worker DCB list.
This commit is contained in:
Markus Mäkelä
2018-07-18 09:41:14 +03:00
parent b93eaf6fb2
commit 23d944b82e
3 changed files with 68 additions and 38 deletions

View File

@ -184,6 +184,33 @@ void service_free(SERVICE* service)
{
ss_dassert(atomic_load_int(&service->client_count) == 0);
spinlock_acquire(&service_spin);
if (service == allServices)
{
allServices = allServices->next;
}
else
{
for (SERVICE* s = allServices; s; s = s->next)
{
if (s->next == service)
{
s->next = service->next;
break;
}
}
}
spinlock_release(&service_spin);
while (service->ports)
{
auto tmp = service->ports;
service->ports = service->ports->next;
listener_free(tmp);
}
if (service->router && service->router_instance)
{
service->router->destroyInstance(service->router_instance);