Added missing NULL checks.

This commit is contained in:
Markus Makela
2015-06-23 17:05:31 +03:00
parent 039cbff181
commit c42d3d9f7a
2 changed files with 15 additions and 4 deletions

View File

@ -2423,6 +2423,9 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_NOPOLLING: case DCB_STATE_NOPOLLING:
switch (new_state) { switch (new_state) {
/** Stopped services which are restarting will go from
* DCB_STATE_NOPOLLING to DCB_STATE_LISTENING.*/
case DCB_STATE_LISTENING:
case DCB_STATE_ZOMBIE: /*< fall through */ case DCB_STATE_ZOMBIE: /*< fall through */
dcb->state = new_state; dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */ case DCB_STATE_POLLING: /*< ok to try but state can't change */

View File

@ -534,11 +534,15 @@ int listeners = 0;
port = service->ports; port = service->ports;
while (port) while (port)
{ {
if(port->listener && poll_remove_dcb(port->listener) == 0) if(port->listener &&
port->listener->session->state == SESSION_STATE_LISTENER)
{
if(poll_remove_dcb(port->listener) == 0)
{ {
port->listener->session->state = SESSION_STATE_LISTENER_STOPPED; port->listener->session->state = SESSION_STATE_LISTENER_STOPPED;
listeners++; listeners++;
} }
}
port = port->next; port = port->next;
} }
service->state = SERVICE_STATE_STOPPED; service->state = SERVICE_STATE_STOPPED;
@ -563,11 +567,15 @@ int listeners = 0;
port = service->ports; port = service->ports;
while (port) while (port)
{ {
if(port->listener && poll_add_dcb(port->listener) == 0) if(port->listener &&
port->listener->session->state == SESSION_STATE_LISTENER_STOPPED)
{
if(poll_add_dcb(port->listener) == 0)
{ {
port->listener->session->state = SESSION_STATE_LISTENER; port->listener->session->state = SESSION_STATE_LISTENER;
listeners++; listeners++;
} }
}
port = port->next; port = port->next;
} }
service->state = SERVICE_STATE_STARTED; service->state = SERVICE_STATE_STARTED;