From 4d4f9b0da6f5e02ae5ec92807b19a5bed35bf644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 10 Oct 2016 15:54:58 +0000 Subject: [PATCH] Bug fixes for REUSEPORT --- include/MySQL_Thread.h | 2 +- lib/MySQL_Thread.cpp | 9 +++++---- lib/ProxySQL_GloVars.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/MySQL_Thread.h b/include/MySQL_Thread.h index d90622b83..3f25fca11 100644 --- a/include/MySQL_Thread.h +++ b/include/MySQL_Thread.h @@ -241,7 +241,7 @@ class MySQL_Listeners_Manager { public: MySQL_Listeners_Manager(); ~MySQL_Listeners_Manager(); - int add(const char *iface, unsigned int num_threads, int *perthrsocks); + int add(const char *iface, unsigned int num_threads, int **perthrsocks); //int add(const char *address, int port); int find_idx(const char *iface); int find_idx(const char *address, int port); diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 825dee8c3..bd4714dfc 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -86,7 +86,7 @@ MySQL_Listeners_Manager::~MySQL_Listeners_Manager() { ifaces=NULL; } -int MySQL_Listeners_Manager::add(const char *iface, unsigned int num_threads, int *perthrsocks) { +int MySQL_Listeners_Manager::add(const char *iface, unsigned int num_threads, int **perthrsocks) { for (unsigned int i=0; ilen; i++) { iface_info *ifi=(iface_info *)ifaces->index(i); if (strcmp(ifi->iface,iface)==0) { @@ -104,15 +104,16 @@ int MySQL_Listeners_Manager::add(const char *iface, unsigned int num_threads, in s = listen_on_unix(address, PROXYSQL_LISTEN_LEN); } else { // for TCP we will use SO_REUSEPORT - perthrsocks=(int *)malloc(sizeof(int)*num_threads); + int *l_perthrsocks=(int *)malloc(sizeof(int)*num_threads); int i; for (i=0;iadd(ifi); - perthrsocks[i]=s; + l_perthrsocks[i]=s; } + *perthrsocks=l_perthrsocks; s=0; } } @@ -361,7 +362,7 @@ int MySQL_Threads_Handler::listener_add(const char *address, int port) { int MySQL_Threads_Handler::listener_add(const char *iface) { int rc; int *perthrsocks=NULL;; - rc=MLM->add(iface, num_threads, perthrsocks); + rc=MLM->add(iface, num_threads, &perthrsocks); if (rc>-1) { unsigned int i; if (perthrsocks==NULL) { diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index b9fb32fa0..16206dec9 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -59,7 +59,7 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() { global.foreground=false; global.monitor=true; #ifdef SO_REUSEPORT - global.reuseport=true; + global.reuseport=false; #endif /* SO_REUSEPORT */ // global.use_proxysql_mem=false; pthread_mutex_init(&global.start_mutex,NULL);