Removed client_fd and server_fd from MySQL_Session

pull/95/merge
René Cannaò 11 years ago
parent a8ac2749b3
commit cc9eb4d807

@ -68,8 +68,8 @@ class MySQL_Session
bool admin;
bool stats;
void (*admin_func) (MySQL_Session *arg, ProxySQL_Admin *, PtrSize_t *pkt);
int client_fd;
int server_fd;
// int client_fd;
// int server_fd;
enum session_status status;
int current_hostgroup;
int default_hostgroup;
@ -97,7 +97,7 @@ class MySQL_Session
PtrArray *mybes;
MySQL_Session();
MySQL_Session(int);
// MySQL_Session(int);
~MySQL_Session();

@ -104,8 +104,8 @@ MySQL_Session::MySQL_Session() {
admin=false;
stats=false;
admin_func=NULL;
client_fd=0;
server_fd=0;
//client_fd=0;
//server_fd=0;
client_myds=NULL;
server_myds=NULL;
to_process=0;
@ -122,10 +122,12 @@ MySQL_Session::MySQL_Session() {
//myprot_server.init(&server_myds, NULL, this);
}
/*
MySQL_Session::MySQL_Session(int _fd) {
MySQL_Session();
client_fd=_fd;
}
*/
MySQL_Session::~MySQL_Session() {
if (client_myds) {
@ -218,7 +220,8 @@ int MySQL_Session::handler() {
unsigned int j;
unsigned char c;
/*
* FIXME: this code is obscure and needs improvements . Commenting for now
if (pause>0 || (status==CONNECTING_SERVER && server_myds && ( server_myds->myds_type==MYDS_BACKEND_FAILED_CONNECT || server_myds->myds_type==MYDS_BACKEND_PAUSE_CONNECT ))) {
server_myds->connect_tries++;
if (server_myds->connect_tries<10) {
@ -260,6 +263,7 @@ int MySQL_Session::handler() {
//assert(0);
}
}
*/
for (j=0; j<client_myds->PSarrayIN->len;) {
client_myds->PSarrayIN->remove_index(0,&pkt);
@ -387,7 +391,7 @@ __get_a_backend:
// FIXME : handle missing connection from connection pool
// FIXME : perhaps is a goto __exit_DSS__STATE_NOT_INITIALIZED after setting time wait
thread->mypolls.add(POLLIN|POLLOUT, server_fd, server_myds, curtime);
thread->mypolls.add(POLLIN|POLLOUT, server_myds->fd, server_myds, curtime);
if (server_myds->DSS!=STATE_READY) {
server_myds->move_from_OUT_to_OUTpending();
@ -513,12 +517,12 @@ __exit_DSS__STATE_NOT_INITIALIZED:
MyHGM->destroy_MyConn_from_pool(mybe->myconn);
mybe->myconn=NULL;
}
if (server_fd) {
if (server_myds->fd) {
shutdown(server_myds->fd,SHUT_RDWR);
close(server_myds->fd);
server_myds->fd=0;
thread->mypolls.remove_index_fast(server_myds->poll_fds_idx);
server_fd=0;
//server_fd=0;
}
server_myds->net_failure=false;
server_myds->active=1;
@ -967,8 +971,9 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
// we didn't get a valid connection, we need to create one
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Sess=%p -- MySQL Connection has no FD\n", this);
server_myds->myconn=mybe->myconn;
server_fd=server_myds->myds_connect(mybe->myconn->parent->address, mybe->myconn->parent->port, &pending_connect);
server_myds->init((pending_connect==1 ? MYDS_BACKEND_NOT_CONNECTED : MYDS_BACKEND), this, server_fd);
int __fd;
__fd=server_myds->myds_connect(mybe->myconn->parent->address, mybe->myconn->parent->port, &pending_connect);
server_myds->init((pending_connect==1 ? MYDS_BACKEND_NOT_CONNECTED : MYDS_BACKEND), this, __fd);
mybe->myconn=server_myds->myconn;
mybe->myconn->reusable=true;
server_myds->myconn->fd=server_myds->fd;
@ -978,7 +983,7 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Sess=%p -- MySQL Connection found = %p\n", this, mybe->myconn);
server_myds->myconn=mybe->myconn;
server_myds->assign_fd_from_mysql_conn();
server_fd=server_myds->fd;
//server_fd=server_myds->fd;
server_myds->myds_type=MYDS_BACKEND;
server_myds->DSS=STATE_READY;
}

@ -604,10 +604,11 @@ virtual MySQL_Session * create_new_session_and_client_data_stream(int _fd) {
int arg_on=1;
MySQL_Session *sess=new MySQL_Session;
register_session(sess); // register session
sess->client_fd=_fd;
setsockopt(sess->client_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(int));
//sess->client_fd=_fd;
sess->client_myds = new MySQL_Data_Stream();
sess->client_myds->init(MYDS_FRONTEND, sess, sess->client_fd);
sess->client_myds->fd=_fd;
setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(int));
sess->client_myds->init(MYDS_FRONTEND, sess, sess->client_myds->fd);
proxy_debug(PROXY_DEBUG_NET,1,"Thread=%p, Session=%p, DataStream=%p -- Created new client Data Stream\n", sess->thread, sess, sess->client_myds);
//sess->prot.generate_server_handshake(sess->client_myds);
#ifdef DEBUG
@ -875,9 +876,9 @@ void Standard_MySQL_Thread::listener_handle_new_connection(MySQL_Data_Stream *my
//sess->myprot_client.generate_pkt_initial_handshake(sess->client_myds,true,NULL,NULL);
//sess->myprot_client.generate_pkt_initial_handshake(true,NULL,NULL);
sess->client_myds->myprot.generate_pkt_initial_handshake(true,NULL,NULL);
ioctl_FIONBIO(sess->client_fd, 1);
mypolls.add(POLLIN|POLLOUT, sess->client_fd, sess->client_myds, curtime);
proxy_debug(PROXY_DEBUG_NET,1,"Session=%p -- Adding client FD %d\n", sess, sess->client_fd);
ioctl_FIONBIO(sess->client_myds->fd, 1);
mypolls.add(POLLIN|POLLOUT, sess->client_myds->fd, sess->client_myds, curtime);
proxy_debug(PROXY_DEBUG_NET,1,"Session=%p -- Adding client FD %d\n", sess, sess->client_myds->fd);
} else {
// if we arrive here, accept() failed
// because multiple threads try to handle the same incoming connection, this is OK

Loading…
Cancel
Save