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
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 68 additions and 38 deletions

View File

@ -2803,8 +2803,6 @@ static void dcb_add_to_list(DCB *dcb)
* @param dcb DCB to remove * @param dcb DCB to remove
*/ */
static void dcb_remove_from_list(DCB *dcb) static void dcb_remove_from_list(DCB *dcb)
{
if (dcb->dcb_role != DCB_ROLE_SERVICE_LISTENER)
{ {
int id = static_cast<RoutingWorker*>(dcb->poll.owner)->id(); int id = static_cast<RoutingWorker*>(dcb->poll.owner)->id();
@ -2847,7 +2845,6 @@ static void dcb_remove_from_list(DCB *dcb)
dcb->thread.next = NULL; dcb->thread.next = NULL;
dcb->thread.tail = NULL; dcb->thread.tail = NULL;
} }
}
/** /**
* Enable the timing out of idle connections. * Enable the timing out of idle connections.

View File

@ -154,6 +154,12 @@ void listener_free(SERV_LISTENER* listener)
users_free(listener->users); users_free(listener->users);
} }
if (listener->listener)
{
dcb_close(listener->listener);
}
SSL_LISTENER_free(listener->ssl);
MXS_FREE(listener->address); MXS_FREE(listener->address);
MXS_FREE(listener->authenticator); MXS_FREE(listener->authenticator);
MXS_FREE(listener->auth_options); MXS_FREE(listener->auth_options);

View File

@ -184,6 +184,33 @@ void service_free(SERVICE* service)
{ {
ss_dassert(atomic_load_int(&service->client_count) == 0); 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) if (service->router && service->router_instance)
{ {
service->router->destroyInstance(service->router_instance); service->router->destroyInstance(service->router_instance);