diff --git a/core/Makefile b/core/Makefile index 71517c582..b8b9de7ba 100644 --- a/core/Makefile +++ b/core/Makefile @@ -19,28 +19,40 @@ # 13/06/13 Mark Riddoch Addition of -rdynamic to allow libraries # to resolve symbols in the main executable # 17/06/13 Mark Riddoch Addition of dependency generation -# 24/06/13 Massimiliano Pinto Addition of libmysqlclient and its includes -# do this for launching the gateway: -# export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH:/packages/mariadb-5.5.25/libmysql +# 24/06/13 Massimiliano Pinto Addition of libmysqlclient and its +# includes do this for launching the +# gateway: export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH:/packages/mariadb-5.5.25/libmysql +# 27/06/13 Vilho Raatikka Added logmanager-related libs and +# headers so that liblog_manager.so can +# be linked in. +include ../../build_gateway.inc + +LOGPATH := $(ROOT_PATH)/log_manager +UTILSPATH := $(ROOT_PATH)/utils CC=cc -CFLAGS=-c -I/usr/include -I../include -I../inih -I/usr/include/mysql -Wall -g -LDFLAGS=-rdynamic -SRCS= atomic.c buffer.c spinlock.c gateway.c gateway_mysql_protocol.c gw_utils.c \ - utils.c dcb.c load_utils.c session.c service.c server.c poll.c config.c \ - users.c hashtable.c dbusers.c thread.c +CFLAGS=-c -I/usr/include -I../include -I../inih -I/usr/include/mysql \ + -I$(LOGPATH) -I$(UTILSPATH) -Wall -g + +LDFLAGS=-rdynamic -L$(LOGPATH) -Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) + +SRCS= atomic.c buffer.c spinlock.c gateway.c gateway_mysql_protocol.c \ + gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c \ + poll.c config.c users.c hashtable.c dbusers.c thread.c + HDRS= ../include/atomic.h ../include/buffer.h ../include/dcb.h \ ../include/gateway_mysql.h ../include/gw.h ../include/mysql_protocol.h \ ../include/session.h ../include/spinlock.h ../include/thread.h \ - ../include/modules.h ../include/poll.h ../include/config.h ../include/users.h \ - ../include/hashtable.h + ../include/modules.h ../include/poll.h ../include/config.h \ + ../include/users.h ../include/hashtable.h OBJ=$(SRCS:.c=.o) + LIBS=-L../inih/extra -linih -lssl -lstdc++ \ -L/packages/mariadb-5.5.25/libmysql -lmysqlclient \ - -lz -lm -lcrypto -ldl -pthread + -lz -lm -lcrypto -ldl -pthread -llog_manager gateway: $(OBJ) - $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o $@ + $(CC) $(LDFLAGS) $(OBJ) $(UTILSPATH)/skygw_utils.o $(LIBS) -o $@ .c.o: $(CC) $(CFLAGS) $< -o $@ diff --git a/core/gateway.c b/core/gateway.c index 55218f76b..c9e70fe3e 100644 --- a/core/gateway.c +++ b/core/gateway.c @@ -44,6 +44,10 @@ #include #include +#include +#include +#include + /* basic signal handling */ static void sighup_handler (int i) { fprintf(stderr, "Signal SIGHUP %i received ...\n", i); @@ -170,11 +174,16 @@ int main(int argc, char **argv) { int daemon_mode = 1; -sigset_t sigset; +sigset_t sigset; int n, n_threads; -void **threads; -char buf[1024], *home, *cnf_file = NULL; +void **threads; +char buf[1024], *home, *cnf_file = NULL; +int i; + i = atexit(skygw_logmanager_done); + if (i != 0) { + fprintf(stderr, "Couldn't register exit function.\n"); + } if ((home = getenv("GATEWAY_HOME")) != NULL) { sprintf(buf, "%s/etc/gateway.cnf", home); @@ -201,6 +210,14 @@ char buf[1024], *home, *cnf_file = NULL; if (cnf_file == NULL) { + skygw_log_write( + NULL, + LOGFILE_ERROR, + strdup("Unable to find a gateway configuration file, either " + "install one in /etc/gateway.cnf, " + "$GATEWAY_HOME/etc/gateway.cnf or use the -c " + "option.\n")); + fprintf(stderr, "Unable to find a gateway configuration file, either install one in\n"); fprintf(stderr, "/etc/gateway.cnf, $GATEWAY_HOME/etc/gateway.cnf or use the -c option.\n"); exit(1); @@ -208,6 +225,9 @@ char buf[1024], *home, *cnf_file = NULL; if (!config_load(cnf_file)) { + skygw_log_write(NULL, + LOGFILE_ERROR, + "Failed to load gateway configuration file %s\n"); fprintf(stderr, "Failed to load gateway configuration file %s\n", cnf_file); exit(1); } diff --git a/modules/protocol/Makefile b/modules/protocol/Makefile index ac6567489..160d9ef39 100644 --- a/modules/protocol/Makefile +++ b/modules/protocol/Makefile @@ -18,10 +18,17 @@ # Date Who Description # 13/06/2013 Mark Riddoch Initial protocol module development # 17/06/2013 Massimiliano Pinto Added mysql_common top both libraries +# 27/06/13 Vilho Raatikka Added logmanager-related libs and +# headers so that liblog_manager.so can +# be linked in. +include ../../../build_gateway.inc +LOGPATH := $(ROOT_PATH)/log_manager +UTILSPATH := $(ROOT_PATH)/utils CC=cc -CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include -Wall -g -LDFLAGS=-shared +CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include -I$(LOGPATH) \ + -I$(UTILSPATH) -Wall -g +LDFLAGS=-shared -L$(LOGPATH) -Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) MYSQLCLIENTSRCS=mysql_client.c mysql_common.c MYSQLCLIENTOBJ=$(MYSQLCLIENTSRCS:.c=.o) MYSQLBACKENDSRCS=mysql_backend.c mysql_common.c @@ -30,7 +37,7 @@ TELNETDSRCS=telnetd.c TELNETDOBJ=$(TELNETDSRCS:.c=.o) SRCS=$(MYSQLCLIENTSRCS) $(MYSQLBACKENDSRCS) $(TELNETDSRCS) OBJ=$(SRCS:.c=.o) -LIBS= +LIBS=$(UTILSPATH)/skygw_utils.o MODULES=libMySQLClient.so libMySQLBackend.so libtelnetd.so all: $(MODULES) diff --git a/modules/protocol/mysql_backend.c b/modules/protocol/mysql_backend.c index 3e96f701e..4a8fcca03 100644 --- a/modules/protocol/mysql_backend.c +++ b/modules/protocol/mysql_backend.c @@ -17,7 +17,10 @@ */ #include "mysql_client_server_protocol.h" +#include +#include +#include /* * MySQL Protocol module for handling the protocol between the gateway * and the backend MySQL database. @@ -26,6 +29,8 @@ * Date Who Description * 14/06/2013 Mark Riddoch Initial version * 17/06/2013 Massimiliano Pinto Added Gateway To Backends routines + * 27/06/13 Vilho Raatikka Added skygw_log_write command as an example + * and necessary headers. */ static char *version_str = "V1.0.0"; @@ -68,6 +73,9 @@ version() void ModuleInit() { + skygw_log_write(NULL, + LOGFILE_MESSAGE, + "Initial MySQL Client Protcol module."); fprintf(stderr, "Initial MySQL Client Protcol module.\n"); } diff --git a/modules/routing/Makefile b/modules/routing/Makefile index b015d4794..38c8e3b28 100644 --- a/modules/routing/Makefile +++ b/modules/routing/Makefile @@ -17,10 +17,17 @@ # Revision History # Date Who Description # 13/06/13 Mark Riddoch Initial routing module development +# 27/06/13 Vilho Raatikka Added logmanager-related libs and +# headers so that liblog_manager.so can +# be linked in. +include ../../../build_gateway.inc +LOGPATH := $(ROOT_PATH)/log_manager +UTILSPATH := $(ROOT_PATH)/utils CC=cc -CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include -Wall -g -LDFLAGS=-shared +CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include -I$(LOGPATH) \ + -I$(UTILSPATH) -Wall -g +LDFLAGS=-shared -L$(LOGPATH) -Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) TESTSRCS=testroute.c TESTOBJ=$(TESTSRCS:.c=.o) READCONSRCS=readconnroute.c @@ -29,7 +36,7 @@ DEBUGCLISRCS=debugcli.c debugcmd.c DEBUGCLIOBJ=$(DEBUGCLISRCS:.c=.o) SRCS=$(TESTSRCS) $(READCONSRCS) $(DEBUGCLISRCS) OBJ=$(SRCS:.c=.o) -LIBS=-lssl +LIBS=$(UTILSPATH)/skygw_utils.o -lssl -llog_manager MODULES=libtestroute.so libreadconnroute.so libdebugcli.so all: $(MODULES) diff --git a/modules/routing/readconnroute.c b/modules/routing/readconnroute.c index 86f35ef76..979262b60 100644 --- a/modules/routing/readconnroute.c +++ b/modules/routing/readconnroute.c @@ -48,6 +48,8 @@ * startup if the number of current * connections is the same for two servers * Addition of master and slave options + * 27/06/13 Vilho Raatikka Added skygw_log_write command as an example + * and necessary headers. * * @endverbatim */ @@ -63,6 +65,10 @@ #include #include +#include +#include +#include + static char *version_str = "V1.0.1"; /* The router entry points */ @@ -96,6 +102,7 @@ version() void ModuleInit() { + skygw_log_write(NULL, LOGFILE_MESSAGE, "Initial test router module.\n"); fprintf(stderr, "Initial test router module.\n"); spinlock_init(&instlock); instances = NULL;