Check dcb->status and set new state with writeqlock on.

This commit is contained in:
vraatikka
2013-08-19 19:41:47 +03:00
parent c5ed473ab7
commit 2ad0b12d79

View File

@ -491,6 +491,16 @@ int gw_read_client_event(DCB* dcb) {
MySQLProtocol *protocol = NULL; MySQLProtocol *protocol = NULL;
int b = -1; int b = -1;
spinlock_acquire(&dcb->writeqlock);
if (dcb->state == DCB_STATE_DISCONNECTED ||
dcb->state == DCB_STATE_FREED ||
dcb->state == DCB_STATE_ZOMBIE)
{
spinlock_release(&dcb->writeqlock);
return 1;
}
if (dcb) { if (dcb) {
protocol = DCB_PROTOCOL(dcb, MySQLProtocol); protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
} }
@ -500,24 +510,29 @@ int gw_read_client_event(DCB* dcb) {
errno = 0; errno = 0;
skygw_log_write( skygw_log_write(
LOGFILE_ERROR, LOGFILE_ERROR,
"%lu [gw_read_client_event] Setting FIONREAD for %d failed. " "%lu [gw_read_client_event] Setting FIONREAD for fd "
"errno %d, %s", "%d failed. errno %d, %s. dcb->state = %d",
pthread_self(), pthread_self(),
dcb->fd, dcb->fd,
eno , eno,
strerror(eno)); strerror(eno),
dcb->state);
skygw_log_write( skygw_log_write(
LOGFILE_TRACE, LOGFILE_TRACE,
"%lu [gw_read_client_event] Setting FIONREAD for %d failed. " "%lu [gw_read_client_event] Setting FIONREAD for fd %d "
"errno %d, %s", "failed. errno %d, %s. dcb->state = %d",
pthread_self(), pthread_self(),
dcb->fd, dcb->fd,
eno , eno ,
strerror(eno)); strerror(eno),
dcb->state);
spinlock_release(&dcb->writeqlock);
return 1; return 1;
} else { } else {
//fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b); //fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b);
} }
spinlock_release(&dcb->writeqlock);
switch (protocol->state) { switch (protocol->state) {
case MYSQL_AUTH_SENT: case MYSQL_AUTH_SENT: