Fix crash on failure to listen on port

If a listener was created at runtime and at some point it fails (e.g. the
port is already taken), the listener would be removed from the service. In
2.2, the removal of the listeners simply marked the listener as
inactive. In 2.3, the functions were combined so that the listener is
marked as inactive and removed from the workers. The fact that the
listener had a NULL DCB at that point caused the crash.

The correct thing to do is to not remove the listener from the service and
to mark the listener as inactive in the close_port helper function. The
listener will be freed once the service is destroyed.
This commit is contained in:
Markus Mäkelä 2018-08-08 21:02:33 +03:00
parent 679ab6a0e9
commit 38219556b6
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -322,6 +322,8 @@ static inline void close_port(SERV_LISTENER *port)
dcb_close(port->listener);
port->listener = NULL;
}
listener_set_active(port, false);
}
/**
@ -555,7 +557,6 @@ bool serviceLaunchListener(Service *service, SERV_LISTENER *port)
if (serviceStartPort(service, port) == 0)
{
/** Failed to start the listener */
service_remove_listener(service, port->name);
rval = false;
}