Skip to content

Commit

Permalink
2nd commit to support Darwin #930
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Feb 24, 2017
1 parent c89beb3 commit 6130cf6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/proxy_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions lib/MySQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion lib/MySQL_Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ MySQL_Session * MySQL_Thread::create_new_session_and_client_data_stream(int _fd)
sess->client_myds->fd=_fd;
setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(int));
#ifdef __APPLE__
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
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);
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ void MySQL_Connection::close_mysql() {
int fd=mysql->net.fd;
#ifdef __APPLE__
int arg_on=1;
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (char *) &arg_on, sizeof(int));
send(fd, buff, 5, 0);
#else
send(fd, buff, 5, MSG_NOSIGNAL);
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,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

Expand Down

0 comments on commit 6130cf6

Please sign in to comment.