Merge branch 'v1.4.0' of https://github.com/sysown/proxysql into v1.4.0

v1.4.0-955
René Cannaò 9 years ago
commit d40374bcaa

@ -182,13 +182,15 @@ class PtrSizeArray {
#ifndef mach_time_h
#define mach_time_h
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC SYSTEM_CLOCK
#endif // CLOCK_MONOTONIC
void clock_gettime(int clk_id, struct timespec *tp) {
static void clock_gettime(int clk_id, struct timespec *tp) {
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
retval = clock_get_time(cclock, &mts);
//retval = clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
tp->tv_sec = mts.tv_sec;
tp->tv_nsec = mts.tv_nsec;

@ -2,7 +2,7 @@
// If defined then active pthread mutex in ProxySQL_Admin else use the wrlock
#define PA_PTHREAD_MUTEX
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__APPLE__)
// If enabled, it adds support for auxiliary threads
#define IDLE_THREADS
#endif

@ -48,7 +48,7 @@
#include <sys/ioctl.h>
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#define HAVE_BOOL
#include "my_global.h"
//#include "my_pthread.h"

@ -26,7 +26,7 @@ SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3
IDIR=../include
IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(RE2_IDIR) -I$(SQLITE3_DIR) -I$(PCRE_PATH)
IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(RE2_IDIR) -I$(SQLITE3_DIR) -I$(PCRE_PATH) -I/usr/local/include
LDIRS=-L$(JEMALLOC_PATH)/lib -L$(RE2_PATH)/obj -L$(INJECTION_PATH)
@ -47,6 +47,12 @@ NOJEM=-DNOJEM
else
NOJEM=
endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
NOJEM=-DNOJEM
endif
MYCFLAGS=$(IDIRS) $(OPTZ) $(DEBUG) -Wall -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM)
MYCPPFLAGS=-std=c++11 $(MYCFLAGS)

@ -110,7 +110,13 @@ static void close_mysql(MYSQL *my) {
memcpy(buff, &myhdr, sizeof(mysql_hdr));
buff[4]=0x01;
int fd=my->net.fd;
#ifdef __APPLE__
int arg_on=1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
int wb=send(fd, buff, 5, 0);
#else
int wb=send(fd, buff, 5, MSG_NOSIGNAL);
#endif
fd+=wb; // dummy, to make compiler happy
fd-=wb; // dummy, to make compiler happy
}

@ -10,7 +10,7 @@ extern MySQL_Threads_Handler *GloMTH;
#undef max_allowed_packet
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__APPLE__)
typedef uint8_t uint8;
typedef uint8_t uchar;
#endif

@ -1927,6 +1927,9 @@ MySQL_Session * MySQL_Thread::create_new_session_and_client_data_stream(int _fd)
sess->client_myds = new MySQL_Data_Stream();
sess->client_myds->fd=_fd;
setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(int));
#ifdef __APPLE__
setsockopt(sess->client_myds->fd, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
#endif
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);
#ifdef DEBUG
@ -3800,7 +3803,7 @@ 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__
#if !defined(__FreeBSD__) && !defined(__APPLE__)
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 );

@ -35,6 +35,12 @@
#define READ_ONLY_ON "\x01\x00\x00\x01\x02\x23\x00\x00\x02\x03\x64\x65\x66\x00\x00\x00\x0d\x56\x61\x72\x69\x61\x62\x6c\x65\x5f\x6e\x61\x6d\x65\x00\x0c\x21\x00\x0f\x00\x00\x00\xfd\x01\x00\x1f\x00\x00\x1b\x00\x00\x03\x03\x64\x65\x66\x00\x00\x00\x05\x56\x61\x6c\x75\x65\x00\x0c\x21\x00\x0f\x00\x00\x00\xfd\x01\x00\x1f\x00\x00\x05\x00\x00\x04\xfe\x00\x00\x02\x00\x0d\x00\x00\x05\x09\x72\x65\x61\x64\x5f\x6f\x6e\x6c\x79\x02\x4f\x4e\x05\x00\x00\x06\xfe\x00\x00\x02\x00"
#ifdef __APPLE__
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif // MSG_NOSIGNAL
#endif // __APPLE__
#define SAFE_SQLITE3_STEP(_stmt) do {\
do {\
rc=sqlite3_step(_stmt);\

@ -187,6 +187,11 @@ void ProxySQL_GlobalVariables::process_opts_post() {
if (opt->isSet("-f")) {
global.foreground=true;
#ifdef __APPLE__
} else {
proxy_warning("ProxySQL does not support daemonize in Darwin: running in foreground\n");
global.foreground=true;
#endif
}
if (opt->isSet("-M")) {

@ -1528,7 +1528,13 @@ void MySQL_Connection::close_mysql() {
memcpy(buff, &myhdr, sizeof(mysql_hdr));
buff[4]=0x01;
int fd=mysql->net.fd;
#ifdef __APPLE__
int arg_on=1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
send(fd, buff, 5, 0);
#else
send(fd, buff, 5, MSG_NOSIGNAL);
#endif
}
// int rc=0;
mysql_close_no_command(mysql);

@ -317,7 +317,11 @@ int MySQL_Data_Stream::write_to_net() {
if (encrypted) {
bytes_io = SSL_write (ssl, queue_r_ptr(queueOUT), s);
} else {
#ifdef __APPLE__
bytes_io = send(fd, queue_r_ptr(queueOUT), s, 0);
#else
bytes_io = send(fd, queue_r_ptr(queueOUT), s, MSG_NOSIGNAL);
#endif
}
VALGRIND_ENABLE_ERROR_REPORTING;
if (bytes_io < 0) {
@ -791,6 +795,9 @@ int MySQL_Data_Stream::myds_connect(char *address, int connect_port, int *pendin
rc=connect(s, (struct sockaddr *) &a, sizeof(a));
int arg_on=1;
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(int));
#ifdef __APPLE__
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
#endif
} else {
rc=connect(s, (struct sockaddr *) &u, len);
}

@ -7,6 +7,7 @@
int listen_on_port(char *ip, uint16_t port, int backlog, bool reuseport) {
int rc, arg_on = 1;
struct addrinfo hints;
memset(&hints,0,sizeof(hints));
hints.ai_flags = AI_PASSIVE;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

@ -34,6 +34,12 @@ LDIR=../lib
IDIRS=-I$(IDIR) -I$(JEMALLOC_IDIR) -I$(MARIADB_IDIR) $(LIBCONFIG_IDIR) -I$(DAEMONPATH_IDIR) -I$(SQLITE3_DIR)
LDIRS=-L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
IDIRS+= -I/usr/local/include
LDIRS+= -L/usr/local/lib
endif
MYCPPFLAGS=-std=c++11 $(IDIRS) $(OPTZ) $(DEBUG)
LDFLAGS+=
@ -44,7 +50,9 @@ else
MYLIBS=-Wl,--export-dynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -ljemalloc -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -Wl,-Bdynamic -lpthread -lm -lz -lrt -lcrypto -lssl $(EXTRALINK)
endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
MYLIBS=-lssl -lre2 -lmariadbclient -lpthread -lm -lz -liconv -lcrypto
endif
ifeq ($(UNAME_S),Linux)
MYLIBS+= -ldl
endif
@ -53,6 +61,9 @@ ifeq ($(UNAME_S),FreeBSD)
endif
LIBPROXYSQLAR=$(LDIR)/libproxysql.a
ifeq ($(UNAME_S),Darwin)
LIBPROXYSQLAR=$(LDIR)/libproxysql.a ../deps/pcre/pcre/.libs/libpcre.a ../deps/pcre/pcre/.libs/libpcrecpp.a ../deps/libdaemon/libdaemon/libdaemon/.libs/libdaemon.a ../deps/libconfig/libconfig/lib/.libs/libconfig++.a ../deps/libconfig/libconfig/lib/.libs/libconfig.a ../deps/sqlite3/sqlite3/sqlite3.o
endif
ODIR= obj

Loading…
Cancel
Save