Modified Makefiles so that liblog_manager.so can be linked in in compilation of core/gateway.c modules/protocol/mysql_backend.c and in modules/routing readconnroute.c.

Modified source files by adding a few logging commands (skygw_log_write) to them, and by adding includes of necessary header files.
This commit is contained in:
vraatikka 2013-06-27 23:14:33 +03:00
parent 7bf99e48e7
commit 3af4089c87
6 changed files with 82 additions and 21 deletions

View File

@ -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 $@

View File

@ -44,6 +44,10 @@
#include <config.h>
#include <poll.h>
#include <stdlib.h>
#include <skygw_utils.h>
#include <log_manager.h>
/* 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);
}

View File

@ -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)

View File

@ -17,7 +17,10 @@
*/
#include "mysql_client_server_protocol.h"
#include <skygw_types.h>
#include <skygw_utils.h>
#include <log_manager.h>
/*
* 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");
}

View File

@ -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)

View File

@ -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 <dcb.h>
#include <spinlock.h>
#include <skygw_types.h>
#include <skygw_utils.h>
#include <log_manager.h>
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;