Fix bug in persistent connections; add code to check for DCB session pointer in poll loop before invoking processing.

This commit is contained in:
counterpoint
2015-08-25 12:19:02 +01:00
parent 8425deab18
commit e7c74c39cf
2 changed files with 49 additions and 8 deletions

View File

@ -1852,7 +1852,7 @@ dcb_close(DCB *dcb)
{
char *user;
user = session_getUser(dcb->session);
dcb->user = strdup(user);
if (NULL != user) dcb->user = strdup(user);
/*<
* Add closing dcb to the top of the list, setting zombie marker
*/

View File

@ -96,7 +96,7 @@ static simple_mutex_t epoll_wait_mutex; /*< serializes calls to epoll_wait */
static int n_waiting = 0; /*< No. of threads in epoll_wait */
static int process_pollq(int thread_id);
static void poll_add_event_to_dcb(DCB* dcb, GWBUF* buf, __uint32_t ev);
static bool poll_dcb_session_check(DCB *dcb);
DCB *eventq = NULL;
SPINLOCK pollqlock = SPINLOCK_INIT;
@ -885,7 +885,10 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.write_ready(dcb);
}
} else {
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
@ -915,8 +918,11 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.accept(dcb);
}
}
else
{
LOGIF(LD, (skygw_log_write(
@ -932,9 +938,12 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.read(dcb);
}
}
}
if (ev & EPOLLERR)
{
int eno = gw_getsockerrno(dcb->fd);
@ -967,8 +976,11 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.error(dcb);
}
}
if (ev & EPOLLHUP)
{
@ -996,8 +1008,11 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.hangup(dcb);
}
}
else
spinlock_release(&dcb->dcb_initlock);
}
@ -1029,8 +1044,11 @@ unsigned long qtime;
dcb,
&tls_log_info.li_sesid,
&tls_log_info.li_enabled_logs)));
if (poll_dcb_session_check(dcb))
{
dcb->func.hangup(dcb);
}
}
else
spinlock_release(&dcb->dcb_initlock);
}
@ -1098,6 +1116,29 @@ unsigned long qtime;
}
/**
*
* Check that the DCB has a session link before processing.
* If not, log an error. Processing will be bypassed
*
* @param dcb The DCB to check
* @return bool Does the DCB have a non-null session link
*/
static bool
poll_dcb_session_check(DCB *dcb)
{
if (dcb->session)
{
return true;
}
else
{
LOGIF;
return false;
}
}
/**
*
* Shutdown the polling loop
*/
void