Issue #123 and more

Issue #123:
- in case of backend authentication failure the client is disconnected and MySQL_Connection on backend marked not reausable

Bug fixes:
- fixed a bug in MySQL_Protocol::process_pkt_OK()
- increased DEBUG_MSG_MAXSIZE : long debugging messages were causing crash

Added few more debugging entries

Issue #114 : marked with perror() + assert()

Marked with assert another not handled scenario
pull/190/head
René Cannaò 11 years ago
parent b98c1d3e6d
commit 454aa00f0f

@ -1277,6 +1277,7 @@ bool MySQL_Protocol::process_pkt_OK(unsigned char *pkt, unsigned int len) {
memcpy(&hdr,pkt,sizeof(mysql_hdr));
pkt += sizeof(mysql_hdr);
if (*pkt) return false;
if (len!=hdr.pkt_length+sizeof(mysql_hdr)) return false;
//MYSQL &myc=(*myds)->myconn->myconn;

@ -254,6 +254,7 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
* This function can modify the original query
*/
bool admin_handler_command_load_or_save(char *query_no_space, unsigned int query_no_space_length, MySQL_Session *sess, ProxySQL_Admin *pa, char **q, unsigned int *ql) {
proxy_debug(PROXY_DEBUG_ADMIN, 5, "Received command %s\n", query_no_space);
#ifdef DEBUG
if ((query_no_space_length>11) && ( (!strncasecmp("SAVE DEBUG ", query_no_space, 11)) || (!strncasecmp("LOAD DEBUG ", query_no_space, 11))) ) {

@ -39,7 +39,7 @@ void proxy_debug_func(enum debug_module module, int verbosity, const char *fmt,
};
*/
#define DEBUG_MSG_MAXSIZE 256
#define DEBUG_MSG_MAXSIZE 1024
#ifdef DEBUG
void proxy_debug_func(enum debug_module module, int verbosity, int thr, const char *__file, int __line, const char *__func, const char *fmt, ...) {

@ -157,6 +157,7 @@ MySQL_Data_Stream::~MySQL_Data_Stream() {
if (mypolls) mypolls->remove_index_fast(poll_fds_idx);
if (fd>0) {
if (myconn==NULL || myconn->reusable==false) {
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "MySQL_Connection %p %s: shutdown socket\n", myconn, (myconn ? "not reusable" : "is empty"));
shut_hard();
// shutdown(fd,SHUT_RDWR);
// close(fd);

@ -293,6 +293,7 @@ int MySQL_Session::handler() {
}
} else {
l_free(pkt.size,pkt.ptr);
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Wrong credentials for frontend: disconnecting\n");
wrong_pass=true;
// FIXME: this should become close connection
client_myds->DSS=STATE_QUERY_SENT;
@ -314,6 +315,8 @@ int MySQL_Session::handler() {
} else {
l_free(pkt.size,pkt.ptr);
// FIXME: this should become close connection
perror("Hitting a not implemented feature: https://github.com/sysown/proxysql-0.2/issues/124");
assert(0);
}
break;
default:
@ -651,7 +654,9 @@ __exit_DSS__STATE_NOT_INITIALIZED:
////status=WAITING_CLIENT_DATA;
server_myds->DSS=STATE_CLIENT_HANDSHAKE;
} else {
l_free(pkt.size,pkt.ptr);
// FIXME: what to do here?
l_free(pkt.size,pkt.ptr);
assert(0);
}
break;
case STATE_CLIENT_HANDSHAKE:
@ -669,7 +674,17 @@ __exit_DSS__STATE_NOT_INITIALIZED:
server_myds->DSS=STATE_QUERY_SENT;
}
} else {
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Wrong credentials for backend: disconnecting\n");
l_free(pkt.size,pkt.ptr);
wrong_pass=true;
client_myds->DSS=STATE_QUERY_SENT;
char *_s=(char *)malloc(strlen(userinfo_client.username)+100);
sprintf(_s,"Access denied for user '%s' (using password: %s)", userinfo_client.username, (userinfo_client.password ? "YES" : "NO"));
myprot_client.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000", _s);
free(_s);
client_myds->DSS=STATE_SLEEP;
status=WAITING_CLIENT_DATA;
server_myds->myconn->reusable=false;
}
break;
default:

Loading…
Cancel
Save