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:
@ -1015,24 +1015,23 @@ bool runtime_create_listener(Service* service,
|
||||
else
|
||||
{
|
||||
const char* print_addr = addr ? addr : "::";
|
||||
SListener listener = listener_alloc(service,
|
||||
name,
|
||||
proto,
|
||||
addr,
|
||||
u_port,
|
||||
auth,
|
||||
auth_opt,
|
||||
ssl);
|
||||
SListener listener = Listener::create(service,
|
||||
name,
|
||||
proto,
|
||||
addr,
|
||||
u_port,
|
||||
auth,
|
||||
auth_opt,
|
||||
ssl);
|
||||
|
||||
if (listener && listener_serialize(listener))
|
||||
{
|
||||
MXS_NOTICE("Created %slistener '%s' at %s:%s for service '%s'",
|
||||
ssl ? "TLS encrypted " : "",
|
||||
name,
|
||||
print_addr,
|
||||
port,
|
||||
service->name);
|
||||
if (serviceLaunchListener(service, listener))
|
||||
ssl ? "TLS encrypted " : "", name, print_addr, port, service->name);
|
||||
|
||||
service->add_listener(listener);
|
||||
|
||||
if (listener->listen())
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user