Move sending of the OK on client side authentication to the EPOLLIN event processing routine
Addition of a compile switch to make epoll block rather than timeout, useful only for debugging
This commit is contained in:
parent
3b8ebfd215
commit
99465dd6b7
@ -104,6 +104,9 @@ struct epoll_event ev;
|
||||
return epoll_ctl(epoll_fd, EPOLL_CTL_DEL, dcb->fd, &ev);
|
||||
}
|
||||
|
||||
#define BLOCKINGPOLL 1 /* Set BLOCKING POLL to 1 if using a single thread and to make
|
||||
* debugging easier.
|
||||
*/
|
||||
/**
|
||||
* The main polling loop
|
||||
*
|
||||
@ -118,6 +121,11 @@ int i, nfds;
|
||||
|
||||
while (1)
|
||||
{
|
||||
#if BLOCKINGPOLL
|
||||
if ((nfds = epoll_wait(epoll_fd, events, MAX_EVENTS, -1)) == -1)
|
||||
{
|
||||
}
|
||||
#else
|
||||
if ((nfds = epoll_wait(epoll_fd, events, MAX_EVENTS, 0)) == -1)
|
||||
{
|
||||
}
|
||||
@ -127,6 +135,7 @@ int i, nfds;
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (nfds > 0)
|
||||
{
|
||||
atomic_add(&pollStats.n_polls, 1);
|
||||
|
@ -823,11 +823,33 @@ int gw_read_client_event(DCB* dcb) {
|
||||
queue = gwbuf_consume(queue, len);
|
||||
|
||||
if (auth_val == 0)
|
||||
{
|
||||
SESSION *session = NULL;
|
||||
|
||||
protocol->state = MYSQL_AUTH_RECV;
|
||||
|
||||
//write to client mysql AUTH_OK packet, packet n. is 2
|
||||
mysql_send_ok(dcb, 2, 0, NULL);
|
||||
|
||||
// start a new session, and connect to backends
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
protocol->state = MYSQL_IDLE;
|
||||
|
||||
session->data = (MYSQL_session *)dcb->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
protocol->state = MYSQL_AUTH_FAILED;
|
||||
|
||||
// still to implement
|
||||
mysql_send_auth_error(dcb, 2, 0, "Authorization failed");
|
||||
|
||||
dcb->func.close(dcb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case MYSQL_IDLE:
|
||||
@ -952,31 +974,6 @@ int gw_write_client_event(DCB *dcb) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(protocol->state == MYSQL_AUTH_RECV) {
|
||||
SESSION *session = NULL;
|
||||
|
||||
//write to client mysql AUTH_OK packet, packet n. is 2
|
||||
mysql_send_ok(dcb, 2, 0, NULL);
|
||||
|
||||
// start a new session, and connect to backends
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
protocol->state = MYSQL_IDLE;
|
||||
|
||||
session->data = (MYSQL_session *)dcb->data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (protocol->state == MYSQL_AUTH_FAILED) {
|
||||
// still to implement
|
||||
mysql_send_auth_error(dcb, 2, 0, "Authorization failed");
|
||||
|
||||
dcb->func.close(dcb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((protocol->state == MYSQL_IDLE) || (protocol->state == MYSQL_WAITING_RESULT)) {
|
||||
int w;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user