Some fprintf removed.

Fixed an if statement without brackets
This commit is contained in:
Massimiliano Pinto 2013-06-13 18:38:03 +02:00
parent 269bef8280
commit a5e1441cb8
4 changed files with 36 additions and 33 deletions

View File

@ -236,15 +236,15 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
//#ifdef GW_EVENT_DEBUG
#ifdef GW_EVENT_DEBUG
fprintf(stderr, "wake from epoll_wait, n. %i events\n", nfds);
//#endif
#endif
for (n = 0; n < nfds; ++n) {
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);
if (events[n].events & EPOLLIN)
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)
fprintf(stderr, "New event %i for socket %i is EPOLLPRI\n", n, dcb->fd);
//#endif
#endif
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);
//fprintf(stderr, "CALLED the ERROR pointer\n");
// go to next event
continue;
@ -268,18 +269,18 @@ int main(int argc, char **argv) {
(dcb->func).accept(dcb, epollfd);
} else {
fprintf(stderr, "CALL the READ pointer\n");
//fprintf(stderr, "CALL the READ pointer\n");
(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 (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);
fprintf(stderr, ">>> CALLED the WRITE pointer\n");
//fprintf(stderr, ">>> CALLED the WRITE pointer\n");
}
}

View File

@ -39,7 +39,7 @@
#include <openssl/sha.h>
#define MYSQL_CONN_DEBUG
//#undef MYSQL_CONN_DEBUG
#undef MYSQL_CONN_DEBUG
/*
* 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);
if (connect_with_db) {
fprintf(stderr, "<<< Client is connected with db\n");
//fprintf(stderr, "<<< Client is connected with db\n");
} else {
fprintf(stderr, "<<< Client is NOT connected with db\n");
//fprintf(stderr, "<<< Client is NOT connected with db\n");
}
if (connect_with_db) {
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
auth_ret = gw_check_mysql_scramble_data(auth_token, auth_token_len, protocol->scramble, sizeof(protocol->scramble), username, stage1_hash);
if (auth_ret == 0) {
fprintf(stderr, "<<< CLIENT AUTH is OK\n");
//fprintf(stderr, "<<< CLIENT AUTH is OK\n");
} else {
fprintf(stderr, "<<< CLIENT AUTH FAILED\n");
//fprintf(stderr, "<<< CLIENT AUTH FAILED\n");
}
return auth_ret;
@ -418,8 +418,6 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
return 1;
}
fprintf(stderr, "<<< User %s has the password\n", username);
gw_sha1_str(username, strlen(username), hash1);
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);
if (ret_val) {
fprintf(stderr, "<<<< User [%s] not found\n", username);
//fprintf(stderr, "<<<< User [%s] not found\n", username);
return 1;
} 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
@ -495,7 +492,7 @@ int gw_check_mysql_scramble_data(uint8_t *token, unsigned int token_len, uint8_t
char inpass[128]="";
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
@ -524,8 +521,6 @@ int gw_mysql_read_command(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)
return 1;

View File

@ -201,8 +201,14 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
GWBUF *buffer = NULL;
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;
}
while (b > 0) {
int bufsize = b < MAX_BUFFER_SIZE ? b : MAX_BUFFER_SIZE;

View File

@ -73,7 +73,7 @@ int gw_read_backend_event(DCB *dcb, int epfd) {
if (ioctl(dcb->fd, FIONREAD, &b)) {
fprintf(stderr, "Backend Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
} 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) {
fprintf(stderr, ">>> gw_write_backend_event for %i\n", dcb->fd);
//fprintf(stderr, ">>> gw_write_backend_event for %i\n", dcb->fd);
return 0;
}
@ -215,7 +215,7 @@ int gw_route_read_event(DCB* dcb, int epfd) {
if (ioctl(dcb->fd, FIONREAD, &b)) {
fprintf(stderr, "Client Ioctl FIONREAD error %i, %s\n", errno , strerror(errno));
} 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) {
@ -243,7 +243,7 @@ int gw_route_read_event(DCB* dcb, int epfd) {
queue = gw_buffer;
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);
@ -291,11 +291,12 @@ int gw_route_read_event(DCB* dcb, int epfd) {
if (ptr_buff)
mysql_command = ptr_buff[4];
if (mysql_command == '\x03')
if (mysql_command == '\x03') {
/// this is a query !!!!
fprintf(stderr, "<<< MySQL Query from Client %i bytes: [%s]\n", len, ptr_buff+5);
else
fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, ptr_buff);
//fprintf(stderr, "<<< MySQL Query from Client %i bytes: [%s]\n", len, ptr_buff+5);
//else
//fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, ptr_buff);
}
///////////////////////////
// Handling the COM_QUIT