From 3a9fe080eedb0fa7c3eaf11f6b2c5947a63fd18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesmar=20Canna=C3=B2?= Date: Sun, 8 Feb 2015 12:04:24 +0100 Subject: [PATCH 1/3] FIX ISSUE #174:: Print "DEBUG" in print_version() if compiled with DEBUG option : all modules --- lib/Standard_MySQL_Authentication.cpp | 7 ++++++- lib/Standard_MySQL_Thread.cpp | 7 ++++++- lib/Standard_ProxySQL_Admin.cpp | 8 ++++++-- lib/Standard_Query_Cache.cpp | 7 ++++++- lib/Standard_Query_Processor.cpp | 7 ++++++- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/Standard_MySQL_Authentication.cpp b/lib/Standard_MySQL_Authentication.cpp index 532652065..f066979ad 100644 --- a/lib/Standard_MySQL_Authentication.cpp +++ b/lib/Standard_MySQL_Authentication.cpp @@ -14,7 +14,12 @@ typedef struct _account_details_t { bool transaction_persistent; } account_details_t; -#define MYSQL_AUTHENTICATION_VERSION "0.1.0706" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define MYSQL_AUTHENTICATION_VERSION "0.1.0706" DEB //#define MY_SEPERATOR_HASH "__uy1gf2doi3ujh4ge5__" diff --git a/lib/Standard_MySQL_Thread.cpp b/lib/Standard_MySQL_Thread.cpp index 62a8d8925..a9fffcdde 100644 --- a/lib/Standard_MySQL_Thread.cpp +++ b/lib/Standard_MySQL_Thread.cpp @@ -16,7 +16,12 @@ extern "C" { #endif /* __cplusplus */ -#define MYSQL_THREAD_VERSION "0.1.1114" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define MYSQL_THREAD_VERSION "0.1.1114" DEB #define DEFAULT_NUM_THREADS 4 diff --git a/lib/Standard_ProxySQL_Admin.cpp b/lib/Standard_ProxySQL_Admin.cpp index d8c7e9f3a..f87145542 100644 --- a/lib/Standard_ProxySQL_Admin.cpp +++ b/lib/Standard_ProxySQL_Admin.cpp @@ -1293,8 +1293,12 @@ __end_while_pool: return NULL; } - -#define PROXYSQL_ADMIN_VERSION "0.1.0815" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define PROXYSQL_ADMIN_VERSION "0.1.0815" DEB //class Standard_ProxySQL_Admin: public ProxySQL_Admin { /* diff --git a/lib/Standard_Query_Cache.cpp b/lib/Standard_Query_Cache.cpp index 124093e07..3f1d3025d 100644 --- a/lib/Standard_Query_Cache.cpp +++ b/lib/Standard_Query_Cache.cpp @@ -29,7 +29,12 @@ } while(0) -#define QUERY_CACHE_VERSION "0.1.0629" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define QUERY_CACHE_VERSION "0.1.0629" DEB __thread uint64_t __thr_cntSet=0; __thread uint64_t __thr_cntGet=0; diff --git a/lib/Standard_Query_Processor.cpp b/lib/Standard_Query_Processor.cpp index ce8718f38..feb085719 100644 --- a/lib/Standard_Query_Processor.cpp +++ b/lib/Standard_Query_Processor.cpp @@ -9,7 +9,12 @@ #include "../deps/libinjection/libinjection_sqli.h" -#define QUERY_PROCESSOR_VERSION "0.1.728" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define QUERY_PROCESSOR_VERSION "0.1.728" DEB #define strdup_null(__c) ( __c ? strdup(__c) : __c ) From 0717312c50bf083a9d6c40279861f5ed63c024e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesmar=20Canna=C3=B2?= Date: Sun, 8 Feb 2015 12:51:22 +0100 Subject: [PATCH 2/3] Fix Issue #175 Print "DEBUG" in version if compiled with DEBUG option : main process --- include/proxysql.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/proxysql.h b/include/proxysql.h index f27761dc0..3863c856e 100644 --- a/include/proxysql.h +++ b/include/proxysql.h @@ -78,8 +78,12 @@ //#include "cpp.h" - -#define PROXYSQL_VERSION "20140617" +#ifdef DEBUG +#define DEB "_DEBUG" +#else +#define DEB "" +#endif /* DEBUG */ +#define PROXYSQL_VERSION "20140617" DEB #define PROXYSQL_CODENAME "Hebe" #ifndef PROXYSQL_FUNC_DEFS From d4f9c49e1b01e4d8ae04bb654adab2a7f1ea9c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesmar=20Canna=C3=B2?= Date: Sun, 8 Feb 2015 16:37:05 +0100 Subject: [PATCH 3/3] Fix Issue #182 Prevent loading modules compiled for a different version --- include/proxysql_structs.h | 2 ++ lib/Standard_MySQL_Authentication.cpp | 8 ++++++++ lib/Standard_MySQL_Thread.cpp | 8 ++++++++ lib/Standard_ProxySQL_Admin.cpp | 8 ++++++++ lib/Standard_Query_Cache.cpp | 8 ++++++++ lib/Standard_Query_Processor.cpp | 8 ++++++++ src/main.cpp | 6 ++++++ src/proxysql_global.cpp | 1 - 8 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index 5ed96807e..b91c14304 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -361,6 +361,8 @@ struct _global_variables_t { //pthread_rwlock_t rwlock_global; pthread_rwlock_t rwlock_usernames; + bool has_debug; + volatile int shutdown; bool nostart; int reload; diff --git a/lib/Standard_MySQL_Authentication.cpp b/lib/Standard_MySQL_Authentication.cpp index f066979ad..c29493dea 100644 --- a/lib/Standard_MySQL_Authentication.cpp +++ b/lib/Standard_MySQL_Authentication.cpp @@ -40,6 +40,14 @@ class Standard_MySQL_Authentication: public MySQL_Authentication { // PtrArray cred_array; public: Standard_MySQL_Authentication() { +#ifdef DEBUG + if (glovars.has_debug==false) { +#else + if (glovars.has_debug==true) { +#endif /* DEBUG */ + perror("Incompatible debagging version"); + exit(EXIT_FAILURE); + } spinlock_rwlock_init(&creds_backends.lock); spinlock_rwlock_init(&creds_frontends.lock); }; diff --git a/lib/Standard_MySQL_Thread.cpp b/lib/Standard_MySQL_Thread.cpp index a9fffcdde..2bc72e5d1 100644 --- a/lib/Standard_MySQL_Thread.cpp +++ b/lib/Standard_MySQL_Thread.cpp @@ -205,6 +205,14 @@ class Standard_MySQL_Threads_Handler: public MySQL_Threads_Handler } variables; public: Standard_MySQL_Threads_Handler() { +#ifdef DEBUG + if (glovars.has_debug==false) { +#else + if (glovars.has_debug==true) { +#endif /* DEBUG */ + perror("Incompatible debagging version"); + exit(EXIT_FAILURE); + } num_threads=0; mysql_threads=NULL; stacksize=0; diff --git a/lib/Standard_ProxySQL_Admin.cpp b/lib/Standard_ProxySQL_Admin.cpp index f87145542..b3686e591 100644 --- a/lib/Standard_ProxySQL_Admin.cpp +++ b/lib/Standard_ProxySQL_Admin.cpp @@ -1319,6 +1319,14 @@ public: */ Standard_ProxySQL_Admin::Standard_ProxySQL_Admin() { // int i; +#ifdef DEBUG + if (glovars.has_debug==false) { +#else + if (glovars.has_debug==true) { +#endif /* DEBUG */ + perror("Incompatible debagging version"); + exit(EXIT_FAILURE); + } SPA=this; spinlock_rwlock_init(&rwlock); diff --git a/lib/Standard_Query_Cache.cpp b/lib/Standard_Query_Cache.cpp index 3f1d3025d..f3df25be8 100644 --- a/lib/Standard_Query_Cache.cpp +++ b/lib/Standard_Query_Cache.cpp @@ -321,6 +321,14 @@ virtual double area() const { }; Standard_Query_Cache() { +#ifdef DEBUG + if (glovars.has_debug==false) { +#else + if (glovars.has_debug==true) { +#endif /* DEBUG */ + perror("Incompatible debagging version"); + exit(EXIT_FAILURE); + } QCnow=time(NULL); //test=0; size=SHARED_QUERY_CACHE_HASH_TABLES; diff --git a/lib/Standard_Query_Processor.cpp b/lib/Standard_Query_Processor.cpp index feb085719..a8fc206d0 100644 --- a/lib/Standard_Query_Processor.cpp +++ b/lib/Standard_Query_Processor.cpp @@ -243,6 +243,14 @@ protected: public: Standard_Query_Processor() { +#ifdef DEBUG + if (glovars.has_debug==false) { +#else + if (glovars.has_debug==true) { +#endif /* DEBUG */ + perror("Incompatible debagging version"); + exit(EXIT_FAILURE); + } proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 4, "Initializing Query Processor with version=0\n"); spinlock_rwlock_init(&rwlock); version=0; diff --git a/src/main.cpp b/src/main.cpp index 81bbe32cf..fdd2d5450 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -190,6 +190,12 @@ int main(int argc, const char * argv[]) { { +#ifdef DEBUG + glovars.has_debug=true; +#else + glovars.has_debug=false; +#endif /* DEBUG */ + __thr_sfp=l_mem_init(); { diff --git a/src/proxysql_global.cpp b/src/proxysql_global.cpp index 5d253ac54..12e868696 100644 --- a/src/proxysql_global.cpp +++ b/src/proxysql_global.cpp @@ -3,4 +3,3 @@ //#include "proxysql_glovars.hpp" #include "cpp.h" //ProxySQL_GlobalVariables GloVars; -