Some fprintf removed.
Fixed an if statement without brackets
This commit is contained in:
@ -236,15 +236,15 @@ int main(int argc, char **argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef GW_EVENT_DEBUG
|
#ifdef GW_EVENT_DEBUG
|
||||||
fprintf(stderr, "wake from epoll_wait, n. %i events\n", nfds);
|
fprintf(stderr, "wake from epoll_wait, n. %i events\n", nfds);
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
for (n = 0; n < nfds; ++n) {
|
for (n = 0; n < nfds; ++n) {
|
||||||
DCB *dcb = (DCB *) (events[n].data.ptr);
|
DCB *dcb = (DCB *) (events[n].data.ptr);
|
||||||
|
|
||||||
|
|
||||||
//#ifdef GW_EVENT_DEBUG
|
#ifdef GW_EVENT_DEBUG
|
||||||
fprintf(stderr, "New event %i for socket %i is %i\n", n, dcb->fd, events[n].events);
|
fprintf(stderr, "New event %i for socket %i is %i\n", n, dcb->fd, events[n].events);
|
||||||
if (events[n].events & EPOLLIN)
|
if (events[n].events & EPOLLIN)
|
||||||
fprintf(stderr, "New event %i for socket %i is EPOLLIN\n", n, dcb->fd);
|
fprintf(stderr, "New event %i for socket %i is EPOLLIN\n", n, dcb->fd);
|
||||||
@ -253,10 +253,11 @@ int main(int argc, char **argv) {
|
|||||||
if (events[n].events & EPOLLPRI)
|
if (events[n].events & EPOLLPRI)
|
||||||
fprintf(stderr, "New event %i for socket %i is EPOLLPRI\n", n, dcb->fd);
|
fprintf(stderr, "New event %i for socket %i is EPOLLPRI\n", n, dcb->fd);
|
||||||
|
|
||||||
//#endif
|
#endif
|
||||||
if (events[n].events & (EPOLLERR | EPOLLHUP)) {
|
if (events[n].events & (EPOLLERR | EPOLLHUP)) {
|
||||||
fprintf(stderr, "CALL the ERROR pointer\n");
|
//fprintf(stderr, "CALL the ERROR pointer\n");
|
||||||
(dcb->func).error(dcb, events[n].events);
|
(dcb->func).error(dcb, events[n].events);
|
||||||
|
//fprintf(stderr, "CALLED the ERROR pointer\n");
|
||||||
|
|
||||||
// go to next event
|
// go to next event
|
||||||
continue;
|
continue;
|
||||||
@ -268,18 +269,18 @@ int main(int argc, char **argv) {
|
|||||||
(dcb->func).accept(dcb, epollfd);
|
(dcb->func).accept(dcb, epollfd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "CALL the READ pointer\n");
|
//fprintf(stderr, "CALL the READ pointer\n");
|
||||||
(dcb->func).read(dcb, epollfd);
|
(dcb->func).read(dcb, epollfd);
|
||||||
fprintf(stderr, "CALLED the READ pointer\n");
|
//fprintf(stderr, "CALLED the READ pointer\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (events[n].events & EPOLLOUT) {
|
if (events[n].events & EPOLLOUT) {
|
||||||
if (dcb->state != DCB_STATE_LISTENING) {
|
if (dcb->state != DCB_STATE_LISTENING) {
|
||||||
fprintf(stderr, "CALL the WRITE pointer\n");
|
//fprintf(stderr, "CALL the WRITE pointer\n");
|
||||||
(dcb->func).write_ready(dcb, epollfd);
|
(dcb->func).write_ready(dcb, epollfd);
|
||||||
fprintf(stderr, ">>> CALLED the WRITE pointer\n");
|
//fprintf(stderr, ">>> CALLED the WRITE pointer\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
|
|
||||||
#define MYSQL_CONN_DEBUG
|
#define MYSQL_CONN_DEBUG
|
||||||
//#undef MYSQL_CONN_DEBUG
|
#undef MYSQL_CONN_DEBUG
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mysql_send_ok
|
* mysql_send_ok
|
||||||
@ -382,25 +382,25 @@ int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
|||||||
memcpy(auth_token, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1, auth_token_len);
|
memcpy(auth_token, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1, auth_token_len);
|
||||||
|
|
||||||
if (connect_with_db) {
|
if (connect_with_db) {
|
||||||
fprintf(stderr, "<<< Client is connected with db\n");
|
//fprintf(stderr, "<<< Client is connected with db\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "<<< Client is NOT connected with db\n");
|
//fprintf(stderr, "<<< Client is NOT connected with db\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect_with_db) {
|
if (connect_with_db) {
|
||||||
strncpy(database, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len, 128);
|
strncpy(database, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len, 128);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "<<< Client selected db is [%s]\n", database);
|
//fprintf(stderr, "<<< Client selected db is [%s]\n", database);
|
||||||
|
|
||||||
fprintf(stderr, "<<< Client username is [%s]\n", username);
|
//fprintf(stderr, "<<< Client username is [%s]\n", username);
|
||||||
|
|
||||||
// decode the token and check the password
|
// decode the token and check the password
|
||||||
auth_ret = gw_check_mysql_scramble_data(auth_token, auth_token_len, protocol->scramble, sizeof(protocol->scramble), username, stage1_hash);
|
auth_ret = gw_check_mysql_scramble_data(auth_token, auth_token_len, protocol->scramble, sizeof(protocol->scramble), username, stage1_hash);
|
||||||
|
|
||||||
if (auth_ret == 0) {
|
if (auth_ret == 0) {
|
||||||
fprintf(stderr, "<<< CLIENT AUTH is OK\n");
|
//fprintf(stderr, "<<< CLIENT AUTH is OK\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "<<< CLIENT AUTH FAILED\n");
|
//fprintf(stderr, "<<< CLIENT AUTH FAILED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return auth_ret;
|
return auth_ret;
|
||||||
@ -418,8 +418,6 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "<<< User %s has the password\n", username);
|
|
||||||
|
|
||||||
gw_sha1_str(username, strlen(username), hash1);
|
gw_sha1_str(username, strlen(username), hash1);
|
||||||
gw_sha1_str(hash1, SHA_DIGEST_LENGTH, gateway_password);
|
gw_sha1_str(hash1, SHA_DIGEST_LENGTH, gateway_password);
|
||||||
|
|
||||||
@ -443,11 +441,10 @@ int gw_check_mysql_scramble_data(uint8_t *token, unsigned int token_len, uint8_t
|
|||||||
ret_val = gw_find_mysql_user_password_sha1(username, password, NULL);
|
ret_val = gw_find_mysql_user_password_sha1(username, password, NULL);
|
||||||
|
|
||||||
if (ret_val) {
|
if (ret_val) {
|
||||||
fprintf(stderr, "<<<< User [%s] not found\n", username);
|
//fprintf(stderr, "<<<< User [%s] not found\n", username);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
//fprintf(stderr, "<<<< User [%s] OK\n", username);
|
||||||
fprintf(stderr, "<<<< User [%s] OK\n", username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert in hex format: this is the content of mysql.user table, field password without the '*' prefix
|
// convert in hex format: this is the content of mysql.user table, field password without the '*' prefix
|
||||||
@ -495,7 +492,7 @@ int gw_check_mysql_scramble_data(uint8_t *token, unsigned int token_len, uint8_t
|
|||||||
char inpass[128]="";
|
char inpass[128]="";
|
||||||
gw_bin2hex(inpass, check_hash, SHA_DIGEST_LENGTH);
|
gw_bin2hex(inpass, check_hash, SHA_DIGEST_LENGTH);
|
||||||
|
|
||||||
fprintf(stderr, "The CLIENT hex(SHA1(SHA1(password))) for \"%s\" is [%s]", username, inpass);
|
//fprintf(stderr, "The CLIENT hex(SHA1(SHA1(password))) for \"%s\" is [%s]", username, inpass);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -524,8 +521,6 @@ int gw_mysql_read_command(DCB *dcb) {
|
|||||||
|
|
||||||
packet_no = do_read_dcb(dcb);
|
packet_no = do_read_dcb(dcb);
|
||||||
|
|
||||||
fprintf(stderr, "DCB [%i], EPOLLIN Protocol entering into MYSQL_IDLE [%i], Packet #%i for socket %i, scramble [%s]\n", dcb->state, protocol->state, packet_no, dcb->fd, protocol->scramble);
|
|
||||||
|
|
||||||
if (packet_no == -2)
|
if (packet_no == -2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -201,8 +201,14 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
|
|||||||
GWBUF *buffer = NULL;
|
GWBUF *buffer = NULL;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
|
|
||||||
if (b <= 0)
|
if (b <= 0) {
|
||||||
|
fprintf(stderr, "||| read_gwbuff called with 0 bytes, closing\n");
|
||||||
|
if (dcb->session->backends) {
|
||||||
|
(dcb->session->backends->func).error(dcb->session->backends, -1);
|
||||||
|
}
|
||||||
|
dcb->func.error(dcb, -1);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (b > 0) {
|
while (b > 0) {
|
||||||
int bufsize = b < MAX_BUFFER_SIZE ? b : MAX_BUFFER_SIZE;
|
int bufsize = b < MAX_BUFFER_SIZE ? b : MAX_BUFFER_SIZE;
|
||||||
|
17
core/utils.c
17
core/utils.c
@ -73,7 +73,7 @@ int gw_read_backend_event(DCB *dcb, int epfd) {
|
|||||||
if (ioctl(dcb->fd, FIONREAD, &b)) {
|
if (ioctl(dcb->fd, FIONREAD, &b)) {
|
||||||
fprintf(stderr, "Backend Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
|
fprintf(stderr, "Backend Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Backend IOCTL FIONREAD bytes to read = %i\n", b);
|
//fprintf(stderr, "Backend IOCTL FIONREAD bytes to read = %i\n", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -191,7 +191,7 @@ int w, saved_errno = 0;
|
|||||||
|
|
||||||
int gw_write_backend_event(DCB *dcb, int epfd) {
|
int gw_write_backend_event(DCB *dcb, int epfd) {
|
||||||
|
|
||||||
fprintf(stderr, ">>> gw_write_backend_event for %i\n", dcb->fd);
|
//fprintf(stderr, ">>> gw_write_backend_event for %i\n", dcb->fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ int gw_route_read_event(DCB* dcb, int epfd) {
|
|||||||
if (ioctl(dcb->fd, FIONREAD, &b)) {
|
if (ioctl(dcb->fd, FIONREAD, &b)) {
|
||||||
fprintf(stderr, "Client Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
|
fprintf(stderr, "Client Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b);
|
//fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (protocol->state) {
|
switch (protocol->state) {
|
||||||
@ -243,7 +243,7 @@ int gw_route_read_event(DCB* dcb, int epfd) {
|
|||||||
queue = gw_buffer;
|
queue = gw_buffer;
|
||||||
len = GWBUF_LENGTH(queue);
|
len = GWBUF_LENGTH(queue);
|
||||||
|
|
||||||
fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, GWBUF_DATA(queue));
|
//fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, GWBUF_DATA(queue));
|
||||||
|
|
||||||
auth_val = gw_mysql_do_authentication(dcb, queue);
|
auth_val = gw_mysql_do_authentication(dcb, queue);
|
||||||
|
|
||||||
@ -291,11 +291,12 @@ int gw_route_read_event(DCB* dcb, int epfd) {
|
|||||||
if (ptr_buff)
|
if (ptr_buff)
|
||||||
mysql_command = ptr_buff[4];
|
mysql_command = ptr_buff[4];
|
||||||
|
|
||||||
if (mysql_command == '\x03')
|
if (mysql_command == '\x03') {
|
||||||
/// this is a query !!!!
|
/// this is a query !!!!
|
||||||
fprintf(stderr, "<<< MySQL Query from Client %i bytes: [%s]\n", len, ptr_buff+5);
|
//fprintf(stderr, "<<< MySQL Query from Client %i bytes: [%s]\n", len, ptr_buff+5);
|
||||||
else
|
//else
|
||||||
fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, ptr_buff);
|
//fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, ptr_buff);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Handling the COM_QUIT
|
// Handling the COM_QUIT
|
||||||
|
Reference in New Issue
Block a user