From abd83ff1a316297d5e85e011ff9d9c24c6901fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 17 Feb 2017 11:52:29 +0000 Subject: [PATCH] Compile 1.4.0 on on FreeBSD #898 --- include/MySQL_Logger.hpp | 2 +- include/proxy_defines.h | 2 ++ include/proxysql.h | 4 +++- lib/MySQL_Monitor.cpp | 2 ++ lib/MySQL_Protocol.cpp | 5 +++++ lib/MySQL_Thread.cpp | 6 +++++- lib/ProxySQL_Admin.cpp | 7 +++++-- lib/mysql_connection.cpp | 1 + lib/mysql_data_stream.cpp | 8 ++++---- src/main.cpp | 2 ++ 10 files changed, 30 insertions(+), 9 deletions(-) diff --git a/include/MySQL_Logger.hpp b/include/MySQL_Logger.hpp index fcf4ef575..a00e52dd4 100644 --- a/include/MySQL_Logger.hpp +++ b/include/MySQL_Logger.hpp @@ -20,7 +20,7 @@ class MySQL_Event { char *client; size_t server_len; size_t client_len; - uint64_t total_length; + //uint64_t total_length; unsigned char buf[10]; enum log_event_type et; uint64_t hid; diff --git a/include/proxy_defines.h b/include/proxy_defines.h index 39f1c38f3..428d132f3 100644 --- a/include/proxy_defines.h +++ b/include/proxy_defines.h @@ -2,5 +2,7 @@ // If defined then active pthread mutex in ProxySQL_Admin else use the wrlock #define PA_PTHREAD_MUTEX +#ifndef __FreeBSD__ // If enabled, it adds support for auxiliary threads #define IDLE_THREADS +#endif diff --git a/include/proxysql.h b/include/proxysql.h index c65f588fe..93ed715fb 100644 --- a/include/proxysql.h +++ b/include/proxysql.h @@ -48,9 +48,11 @@ #include +#ifndef __FreeBSD__ #define HAVE_BOOL #include "my_global.h" -#include "my_pthread.h" +//#include "my_pthread.h" +#endif #include "mysql.h" #include "proxysql_mem.h" diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 1c239edd3..3b172b559 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -17,6 +17,8 @@ #include "thread.h" #include "wqueue.h" +#include + #ifdef DEBUG #define DEB "_DEBUG" #else diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index e03383051..893993112 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -10,6 +10,11 @@ extern MySQL_Threads_Handler *GloMTH; #undef max_allowed_packet #endif +#ifdef __FreeBSD__ +typedef uint8_t uint8; +typedef uint8_t uchar; +#endif + //#define RESULTSET_BUFLEN 16300 #ifdef DEBUG diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index bd8e91007..c89f549b1 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2594,7 +2594,7 @@ bool MySQL_Thread::process_data_on_data_stream(MySQL_Data_Stream *myds, unsigned } - if (myds->active==FALSE) { + if (myds->active==0) { if (myds->sess->client_myds==myds) { proxy_debug(PROXY_DEBUG_NET,1, "Session=%p, DataStream=%p -- Deleting FD %d\n", myds->sess, myds, myds->fd); myds->sess->set_unhealthy(); @@ -3800,7 +3800,11 @@ void MySQL_Thread::Get_Memory_Stats() { } else { status_variables.mysql_frontend_buffers_bytes+=(mysql_sessions->len * QUEUE_T_DEFAULT_SIZE * 2); status_variables.mysql_session_internal_bytes+=(mysql_sessions->len * sizeof(MySQL_Connection)); +#ifndef __FreeBSD__ status_variables.mysql_session_internal_bytes+=((sizeof(int) + sizeof(int) + sizeof(std::_Rb_tree_node_base)) * mysql_sessions->len ); +#else + status_variables.mysql_session_internal_bytes+=((sizeof(int) + sizeof(int) + 32) * mysql_sessions->len ); +#endif } } } diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 27d6db4c0..625b07269 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -19,6 +19,9 @@ #include #include #include "SpookyV2.h" + +#include + //#define MYSQL_THREAD_IMPLEMENTATION #define SELECT_VERSION_COMMENT "select @@version_comment limit 1" @@ -2197,7 +2200,7 @@ static void * admin_main_loop(void *arg) pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize (&attr, mystacksize); + //pthread_attr_setstacksize (&attr, mystacksize); if(GloVars.global.nostart) { nostart_=true; @@ -2418,7 +2421,7 @@ bool ProxySQL_Admin::init() { pthread_attr_t attr; pthread_attr_init(&attr); - pthread_attr_setstacksize (&attr, mystacksize); + //pthread_attr_setstacksize (&attr, mystacksize); admindb=new SQLite3DB(); admindb->open((char *)"file:mem_admindb?mode=memory&cache=shared", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX); diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index f631925ff..46f0dfc7c 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1,6 +1,7 @@ #include "proxysql.h" #include "cpp.h" #include "SpookyV2.h" +#include extern const CHARSET_INFO * proxysql_find_charset_nr(unsigned int nr); diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index 9fd4c9254..b030b1426 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -113,7 +113,7 @@ MySQL_Data_Stream::MySQL_Data_Stream() { queue_init(queueIN,QUEUE_T_DEFAULT_SIZE); queue_init(queueOUT,QUEUE_T_DEFAULT_SIZE); mybe=NULL; - active=TRUE; + active=1; mypolls=NULL; myconn=NULL; // 20141011 DSS=STATE_NOT_CONNECTED; @@ -245,7 +245,7 @@ void MySQL_Data_Stream::init(enum MySQL_DS_type _type, MySQL_Session *_sess, int // TODO: should check the status of the data stream, and identify if it is safe to reconnect or if the session should be destroyed void MySQL_Data_Stream::shut_soft() { proxy_debug(PROXY_DEBUG_NET, 4, "Shutdown soft fd=%d. Session=%p, DataStream=%p\n", fd, sess, this); - active=FALSE; + active=0; set_net_failure(); //if (sess) sess->net_failure=1; } @@ -363,10 +363,10 @@ void MySQL_Data_Stream::set_pollout() { int MySQL_Data_Stream::write_to_net_poll() { int rc=0; - if (active==FALSE) return rc; + if (active==0) return rc; proxy_debug(PROXY_DEBUG_NET,1,"Session=%p, DataStream=%p --\n", sess, this); if (queue_data(queueOUT)) { - if ((sess->admin==false)) { + if (sess->admin==false) { if (poll_fds_idx>-1) { // NOTE: attempt to force writes if (net_failure==false) rc=write_to_net(); diff --git a/src/main.cpp b/src/main.cpp index 4fd7ceffb..1a601319e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -132,7 +132,9 @@ static volatile int load_; //const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay,junk:true,tcache:false"; //#else //const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay"; +#ifndef __FreeBSD__ const char *malloc_conf = "xmalloc:true,lg_tcache_max:16,purge:decay,prof:true,prof_leak:true,lg_prof_sample:20,lg_prof_interval:30,prof_active:false"; +#endif //#endif /* DEBUG */ //const char *malloc_conf = "prof_leak:true,lg_prof_sample:0,prof_final:true,xmalloc:true,lg_tcache_max:16";