Converted QP_out_t into a class Query_Processor_Output

pull/433/head
René Cannaò 11 years ago
parent 66e148c10b
commit e6bc5cc8b8

@ -86,7 +86,7 @@ class MySQL_Session
MySQL_Thread *thread;
uint32_t thread_session_id;
// enum session_states sess_states;
QP_out_t *qpo;
Query_Processor_Output *qpo;
StatCounters *command_counters;
int healthy;
bool killed;

@ -1,48 +0,0 @@
#ifndef __CLASS_SESSION_H
#define __CLASS_SESSION_H
#include "proxysql.h"
#include "cpp.h"
class ProxySQL_Session
{
public:
// virtual void * operator new(size_t) {return NULL;}
// virtual void operator delete(void *) {};
MySQL_Thread *thread;
// enum session_states sess_states;
QP_out_t *qpo;
int healthy;
int admin;
int client_fd;
int server_fd;
enum session_status status;
int to_process;
unsigned long long pause;
char *username;
char *password;
char *schema_name;
// char *schema_cur;
// char *schema_new;
int net_failure;
MySQL_Data_Stream *client_myds;
MySQL_Data_Stream *server_myds;
//GPtrArray *mybes;
PtrArray *mybes;
ProxySQL_Session();
ProxySQL_Session(int) {};
virtual ~ProxySQL_Session() {};
MySQL_Protocol prot;
virtual int handler() {return 0;};
virtual int find_backend(int) {return 0;};
virtual void reset_all_backends() {};
virtual void writeout() {};
};
#endif /* __CLASS_SESSION_H */

@ -77,7 +77,22 @@ struct _Query_Processor_rule_t {
};
struct _Query_Processor_output_t {
//struct _Query_Processor_output_t {
// void *ptr;
// unsigned int size;
// int destination_hostgroup;
// int cache_ttl;
// int reconnect;
// int timeout;
// int delay;
// std::string *new_query;
//};
typedef struct _Query_Processor_rule_t QP_rule_t;
//typedef struct _Query_Processor_output_t QP_out_t;
class Query_Processor_Output {
public:
void *ptr;
unsigned int size;
int destination_hostgroup;
@ -86,11 +101,14 @@ struct _Query_Processor_output_t {
int timeout;
int delay;
std::string *new_query;
void * operator new(size_t size) {
return l_alloc(size);
}
void operator delete(void *ptr) {
l_free(sizeof(Query_Processor_Output),ptr);
}
};
typedef struct _Query_Processor_rule_t QP_rule_t;
typedef struct _Query_Processor_output_t QP_out_t;
static char *commands_counters_desc[MYSQL_COM_QUERY___NONE];
class Command_Counter {
@ -171,8 +189,8 @@ class Query_Processor {
void delete_query_rule(QP_rule_t *qr); // destructor
//virtual bool remove(int rule_id, bool lock=true) {return false;}; // FIXME: not implemented yet, should be implemented at all ?
// virtual bool remove_locked(int rule_id) {return false;}; // call this instead of remove() in case lock was already acquired via wrlock()
QP_out_t * process_mysql_query(MySQL_Session *sess, void *ptr, unsigned int size, bool delete_original);
void delete_QP_out(QP_out_t *o);
Query_Processor_Output * process_mysql_query(MySQL_Session *sess, void *ptr, unsigned int size, bool delete_original);
void delete_QP_out(Query_Processor_Output *o);
void sort(bool lock=true);

@ -590,8 +590,8 @@ SQLite3_result * Query_Processor::get_query_digests_reset() {
QP_out_t * Query_Processor::process_mysql_query(MySQL_Session *sess, void *ptr, unsigned int size, bool delete_original) {
QP_out_t *ret=NULL;
Query_Processor_Output * Query_Processor::process_mysql_query(MySQL_Session *sess, void *ptr, unsigned int size, bool delete_original) {
Query_Processor_Output *ret=NULL;
unsigned int len=size-sizeof(mysql_hdr)-1;
char *query=(char *)l_alloc(len+1);
memcpy(query,(char *)ptr+sizeof(mysql_hdr)+1,len);
@ -661,7 +661,8 @@ QP_out_t * Query_Processor::process_mysql_query(MySQL_Session *sess, void *ptr,
if (ret==NULL) {
proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 5, "this is the first time we find a match\n");
// create struct
ret=(QP_out_t *)l_alloc(sizeof(QP_out_t));
//ret=(QP_out_t *)l_alloc(sizeof(QP_out_t));
ret=new Query_Processor_Output();
// initalized all values
ret->ptr=NULL;
ret->size=0;
@ -748,8 +749,9 @@ __exit_process_mysql_query:
};
// this function is called by mysql_session to free the result generated by process_mysql_query()
void Query_Processor::delete_QP_out(QP_out_t *o) {
l_free(sizeof(QP_out_t),o);
void Query_Processor::delete_QP_out(Query_Processor_Output *o) {
//l_free(sizeof(QP_out_t),o);
delete o;
};
void Query_Processor::update_query_processor_stats() {

Loading…
Cancel
Save