First changes for lazy session creation.

This commit is contained in:
Martin Brampton
2015-08-23 16:39:08 +01:00
parent 087c2fca46
commit 1baf693b02
2 changed files with 17 additions and 47 deletions

View File

@ -299,23 +299,6 @@ poll_add_dcb(DCB *dcb)
STRDCBSTATE(dcb->state))));
raise(SIGABRT);
}
/*
* This test could be wrong. On the face of it, we don't want to add a
* DCB to the poll list if it is not linked to a session because the code
* that handles events will expect to find a session. Test added by
* Martin as an experiment on 23 August 2015
*/
if (false && NULL == dcb->session)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"%lu [%s] Error : Attempt to add dcb %p "
"to poll list but it is not linked to a session, crashing.",
__func__,
pthread_self(),
dcb)));
raise(SIGABRT);
}
if (DCB_STATE_POLLING == dcb->state
|| DCB_STATE_LISTENING == dcb->state)
{
@ -925,6 +908,10 @@ unsigned long qtime;
{
if (dcb->state == DCB_STATE_LISTENING)
{
if (NULL == dcb->session)
{
dcb->session = session_alloc(dcb->service, dcb);
}
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [poll_waitevents] "

View File

@ -363,38 +363,21 @@ GWPROTOCOL *funcs;
if (port->listener->func.listen(port->listener, config_bind))
{
port->listener->session = session_alloc(service, port->listener);
if (port->listener->session != NULL)
{
port->listener->session->state = SESSION_STATE_LISTENER;
listeners += 1;
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Failed to create session to service %s.",
service->name)));
users_free(service->users);
dcb_close(port->listener);
port->listener = NULL;
goto retblock;
}
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
listeners += 1;
/* If lazy session creation fails, how does listeners get decremented? */
}
else
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to start to listen port %d for %s %s.",
port->port,
port->protocol,
service->name)));
users_free(service->users);
dcb_close(port->listener);
port->listener = NULL;
}
port->protocol,
service->name)));
users_free(service->users);
dcb_close(port->listener);
port->listener = NULL;
}
retblock:
return listeners;