MXS-2196: Store listener references in Service

By storing a shared pointer to the listeners in the services, they will be
available as long as the service using them exists. This enables clean
destruction of listeners that still have open sessions.

The listener creation code now separately creates the listener and links
it to the service. Also replaced relevant parts of the related code with
the listener implemented versions of it.
This commit is contained in:
Markus Mäkelä
2018-11-30 11:35:09 +02:00
parent a6063b5e85
commit 330719c8f9
5 changed files with 90 additions and 206 deletions

View File

@ -3887,28 +3887,18 @@ int create_new_listener(CONFIG_CONTEXT* obj)
// authenticators that are specific to each protocol module
char* authenticator = config_get_value(obj->parameters, CN_AUTHENTICATOR);
char* authenticator_options = config_get_value(obj->parameters, CN_AUTHENTICATOR_OPTIONS);
int net_port = socket ? 0 : atoi(port);
if (socket)
auto listener = Listener::create(service, obj->object, protocol, socket ? socket : address,
net_port, authenticator, authenticator_options, ssl_info);
if (listener)
{
listener_alloc(service,
obj->object,
protocol,
socket,
0,
authenticator,
authenticator_options,
ssl_info);
service->add_listener(listener);
}
else if (port)
else
{
listener_alloc(service,
obj->object,
protocol,
address,
atoi(port),
authenticator,
authenticator_options,
ssl_info);
++error_count;
}
}