The listener DCB is now properly closed instead of just being removed from the poll set.
This commit is contained in:
Markus Makela
2015-06-21 12:51:54 +03:00
parent 79c20bfae8
commit e14b29baf9
5 changed files with 23 additions and 14 deletions

View File

@ -1949,13 +1949,15 @@ dcb_close(DCB *dcb)
} }
ss_dassert(dcb->state == DCB_STATE_POLLING || ss_dassert(dcb->state == DCB_STATE_POLLING ||
dcb->state == DCB_STATE_LISTENING ||
dcb->state == DCB_STATE_NOPOLLING || dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE); dcb->state == DCB_STATE_ZOMBIE);
/*< /*<
* Stop dcb's listening and modify state accordingly. * Stop dcb's listening and modify state accordingly.
*/ */
if (dcb->state == DCB_STATE_POLLING) if (dcb->state == DCB_STATE_POLLING ||
dcb->state == DCB_STATE_LISTENING)
{ {
rc = poll_remove_dcb(dcb); rc = poll_remove_dcb(dcb);
@ -2428,6 +2430,10 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_POLLING: /*< ok to try but state can't change */ case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true; succp = true;
break; break;
case DCB_STATE_LISTENING:
dcb->state = new_state;
succp = true;
break;
default: default:
ss_dassert(old_state != NULL); ss_dassert(old_state != NULL);
break; break;

View File

@ -330,7 +330,8 @@ poll_remove_dcb(DCB *dcb)
CHK_DCB(dcb); CHK_DCB(dcb);
/*< It is possible that dcb has already been removed from the set */ /*< It is possible that dcb has already been removed from the set */
if (dcb->state != DCB_STATE_POLLING) if (dcb->state != DCB_STATE_POLLING &&
dcb->state != DCB_STATE_LISTENING)
{ {
if (dcb->state == DCB_STATE_NOPOLLING || if (dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE) dcb->state == DCB_STATE_ZOMBIE)

View File

@ -534,10 +534,12 @@ int listeners = 0;
port = service->ports; port = service->ports;
while (port) while (port)
{ {
poll_remove_dcb(port->listener); if(port->listener)
port->listener->session->state = SESSION_STATE_LISTENER_STOPPED; {
dcb_close(port->listener);
port->listener = NULL;
listeners++; listeners++;
}
port = port->next; port = port->next;
} }
service->state = SERVICE_STATE_STOPPED; service->state = SERVICE_STATE_STOPPED;
@ -562,13 +564,10 @@ int listeners = 0;
port = service->ports; port = service->ports;
while (port) while (port)
{ {
if (poll_add_dcb(port->listener) == 0) { listeners += serviceStartPort(service,port);
port->listener->session->state = SESSION_STATE_LISTENER;
listeners++;
}
port = port->next; port = port->next;
} }
service->state = SERVICE_STATE_STARTED;
return listeners; return listeners;
} }

View File

@ -1771,7 +1771,7 @@ gw_client_close(DCB *dcb)
dcb->state == DCB_STATE_NOPOLLING || dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE) dcb->state == DCB_STATE_ZOMBIE)
{ {
if (!DCB_IS_CLONE(dcb)) CHK_PROTOCOL(protocol); if (!DCB_IS_CLONE(dcb) && protocol) CHK_PROTOCOL(protocol);
} }
#endif #endif
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,

View File

@ -129,6 +129,9 @@ void mysql_protocol_done (
server_command_t* scmd; server_command_t* scmd;
server_command_t* scmd2; server_command_t* scmd2;
if(dcb->protocol == NULL)
return;
p = (MySQLProtocol *)dcb->protocol; p = (MySQLProtocol *)dcb->protocol;
spinlock_acquire(&p->protocol_lock); spinlock_acquire(&p->protocol_lock);