build_gateway.inc

Removed MARIADB_SRC_PATH
	Added MYSQL_ROOT - root directory where MariaDB headers are installed
	Added MYSQL_HEADERS - -I notation for three header directories
	Added EMBEDDED_LIB - for embedded library directory
	Added ERRMSG - for errmsg.sys file

log_manager.cc
	Little fixes

log_manager/makefile
	Updated header include directive

makefile.inc
	Removed DEBUGGER and BACKGR as unnecessary
	Added LIB for embedded library file name

query_classifier/makefile
	Updated header include directives and embedded library directory

query_classifier/query_classifier.cc
	clean up

server/core/Makefile
	Updated header include directives and embedded library directory
	Added libaio and install of errmsg.sys

server/core/dcb.c
	clean up

server/core/gateway.c
	Added --language and --skip-innodb to mysql_library_init command-line arguments list
	clean up

server/core/load_utils.c
	clean up

server/modules/monitor/Makefile
server/modules/routing/readwritesplit/Makefile
	Updated header include directives and embedded library directory

utils/skygw_debug.h
	http://bugs.skysql.com/show_bug.cgi?id=369

utils/skygw_types.h
utils/skygw_utils.cc
	clean up
This commit is contained in:
vraatikka 2013-12-06 00:12:41 +02:00
parent 258bcb27da
commit f50de7a084
15 changed files with 110 additions and 107 deletions

View File

@ -9,24 +9,41 @@
#
# Set debug flags
#
DEBUG :=
DEBUGGER :=
DEBUGGER_PATH :=
DEBUGGER_BIN :=
DEBUG :=
#
# Set build env
#
UNIX :=
UNIX := Y
#
# Set path for root directory, that is, path to directory where
# makefile.inc and build_gateway.inc are located.
# ROOT_PATH is used in makefile.
# Set MaxScale branch directory
#
ROOT_PATH := /home/jdoe/maxscale
ROOT_PATH := $(HOME)/src/bazaar/tmp/maxscale
# MARIADB_SRC_PATH may be defined either as an environment variable or
# specifically here
ifndef $(MARIADB_SRC_PATH)
MARIADB_SRC_PATH := /packages/mariadb/5.5
#
# Set prefix to MySQL Resources
#
MYSQL_ROOT := $(HOME)/usr/include/mysql
#
# Set prefix of the path to development headers
#
MYSQL_HEADERS := -I$(MYSQL_ROOT)/ -I$(MYSQL_ROOT)/private/ -I$(MYSQL_ROOT)/extra/
#
# Set DYNLIB=Y if you want to link MaxScale with dynamic embedded lib
#
DYNLIB :=
#
# Set path to Embedded MySQL Server
#
EMBEDDED_LIB := $(HOME)/usr/lib64
ifdef DYNLIB
EMBEDDED_LIB := $(HOME)/usr/lib64/dynlib
endif
#
# Set path to MySQL errors file
#
ERRMSG := $(HOME)/usr/share/mysql

View File

@ -38,7 +38,9 @@
#define MAXNBLOCKBUFS 10
/** for procname */
#define _GNU_SOURCE
#if !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
extern char *program_invocation_name;
extern char *program_invocation_short_name;
@ -264,7 +266,7 @@ static void blockbuf_register(blockbuf_t* bb);
static void blockbuf_unregister(blockbuf_t* bb);
static bool logfile_set_enabled(logfile_id_t id, bool val);
static char* add_slash(char* str);
static bool file_exists_and_is_writable(char* filename);
static bool file_exists_and_is_writable(char* filename, bool* writable);
static bool file_is_symlink(char* filename);
@ -609,7 +611,6 @@ static int logmanager_write_log(
blockbuf_t* bb_c;
int timestamp_len;
int i;
bool write_syslog;
CHK_LOGMANAGER(lm);
@ -1612,7 +1613,6 @@ static bool logfiles_init(
int i = 0;
bool store_shmem;
bool write_syslog;
char* syslog_ident;
if (syslog_id_str != NULL)
{

View File

@ -28,7 +28,7 @@ lib: libcomp liblink
libcomp:
$(CPP) -c $(CFLAGS) \
-I$(MARIADB_SRC_PATH)/include/ \
$(MYSQL_HEADERS) \
-I../utils/ -I./ \
-fPIC ./log_manager.cc -o log_manager.o $(LDLIBS)
@ -46,7 +46,7 @@ install: liblink
depend:
@rm -f depend
$(CPP) -M $(CFLAGS) \
-I$(MARIADB_SRC_PATH)/include/ \
$(MYSQL_HEADERS) \
-I../utils/ -I./ \
$(SRCS) > depend

View File

@ -16,11 +16,12 @@
NOHUP := nohup
#endif
#ifdef DEBUGGER
BACKGR := >> /dev/null &
#else
BACKGR :=
#endif
LIB := libmysqld.a
ifdef DYNLIB
LIB := libmysqld.so.18
endif
CFLAGS := $(CFLAGS) -Wall
LDLIBS := $(LDLIBS) -pthread
@ -35,14 +36,7 @@ ifdef DEBUG
CFLAGS := $(CFLAGS) -ggdb -O0 -pthread $(DEBUG_FLAGS)
endif
ifdef PROF
CFLAGS := $(CFLAGS) -DSS_PROF
endif
ifdef DEBUGGER
DEBUG := Y
LAUNCH_DEBUGGER := $(NOHUP) $(DEBUGGER_PATH)/$(DEBUGGER_BIN) \
$(DEBUGGER_PARAMS)
else
LAUNCH_DEBUGGER :=
endif
endif

View File

@ -29,20 +29,17 @@ lib: libcomp liblink
libcomp:
$(CPP) -c $(CFLAGS) \
-I$(MARIADB_SRC_PATH)/libmysqld/ \
-I$(MARIADB_SRC_PATH)/include/ \
-I$(MARIADB_SRC_PATH)/sql \
-I$(MARIADB_SRC_PATH)/regex/ \
$(MYSQL_HEADERS) \
-I$(ROOT_PATH)/log_manager/ \
-I./ \
-fPIC ./query_classifier.cc -o query_classifier.o
liblink:
$(CPP) -shared \
-L$(MARIADB_SRC_PATH)/libmysqld \
-L$(EMBEDDED_LIB) \
-Wl,-soname,libquery_classifier.so \
-Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(MARIADB_SRC_PATH)/libmysqld \
-Wl,-rpath,$(EMBEDDED_LIB) \
-o libquery_classifier.so.1.0.1 ./query_classifier.o \
$(LDLIBS) $(LDMYSQL) $(CPP_LDLIBS)
$(DEL) ./libquery_classifier.so
@ -55,10 +52,7 @@ install: liblink
depend:
@rm -f depend
$(CPP) -M $(CFLAGS) \
-I$(MARIADB_SRC_PATH)/libmysqld/ \
-I$(MARIADB_SRC_PATH)/include/ \
-I$(MARIADB_SRC_PATH)/sql \
-I$(MARIADB_SRC_PATH)/regex/ \
$(MYSQL_HEADERS) \
-I$(ROOT_PATH)/log_manager/ \
-I./ \
$(SRCS) > depend

View File

@ -371,7 +371,6 @@ static skygw_query_type_t resolve_query_type(
skygw_query_type_t qtype = QUERY_TYPE_UNKNOWN;
LEX* lex;
Item* item;
int ftype;
/**
* By default, if sql_log_bin, that is, recording data modifications
* to binary log, is disabled, gateway treats operations normally.

View File

@ -42,7 +42,7 @@ UTILSPATH := $(ROOT_PATH)/utils
CC=cc
CFLAGS=-c -I/usr/include -I../include -I../inih \
-I$(MARIADB_SRC_PATH)/include/ \
$(MYSQL_HEADERS) \
-I$(LOGPATH) -I$(UTILSPATH) \
-Wall -g
@ -51,7 +51,7 @@ include ../../makefile.inc
LDFLAGS=-rdynamic -L$(LOGPATH) \
-Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) \
-Wl,-rpath,$(MARIADB_SRC_PATH)/libmysqld
-Wl,-rpath,$(EMBEDDED_LIB)
SRCS= atomic.c buffer.c spinlock.c gateway.c \
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c \
@ -71,8 +71,8 @@ KOBJS=maxkeys.o secrets.o utils.o
POBJS=maxpasswd.o secrets.o utils.o
LIBS=-L../inih/extra -linih -lssl -lstdc++ \
-L$(MARIADB_SRC_PATH)/libmysqld \
-lz -lm -lcrypt -lcrypto -ldl -pthread -llog_manager \
-L$(EMBEDDED_LIB) \
-lz -lm -lcrypt -lcrypto -ldl -laio -pthread -llog_manager \
-lmysqld
all: maxscale maxkeys maxpasswd
@ -103,6 +103,7 @@ depend:
install: maxscale maxkeys maxpasswd
@mkdir -p $(DEST)/bin
install -D maxscale maxkeys maxpasswd $(DEST)/bin
install -D $(MARIADB_SRC_PATH)/libmysqld/libmysqld.so.18 $(DEST)/lib
install -D $(EMBEDDED_LIB)/$(LIB) $(DEST)/lib
install -D $(ERRMSG)/errmsg.sys $(DEST)/MaxScale/mysql
include depend.mk

View File

@ -893,7 +893,6 @@ int saved_errno = 0;
void
dcb_close(DCB *dcb)
{
bool succp;
int rc;
CHK_DCB(dcb);

View File

@ -37,7 +37,7 @@
*
* @endverbatim
*/
#define _XOPEN_SOURCE 500
#define _XOPEN_SOURCE 700
#include <ftw.h>
#include <string.h>
#include <gw.h>
@ -81,6 +81,8 @@ extern int lm_enabled_logfiles_bitmask;
static char* server_options[] = {
"SkySQL Gateway",
"--datadir=",
"--language=",
"--skip-innodb",
"--default-storage-engine=myisam",
NULL
};
@ -90,6 +92,8 @@ const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
const char* default_cnf_fname = "etc/MaxScale.cnf";
static char* server_groups[] = {
"embedded",
"server",
"embedded",
"server",
"server",
@ -97,7 +101,7 @@ static char* server_groups[] = {
};
/* The data directory we created for this gateway instance */
static char datadir[1024] = "";
static char datadir[PATH_MAX+1] = "";
/**
* exit flag for log flusher.
@ -695,32 +699,6 @@ static bool file_is_writable(
return succp;
}
static char* create_and_test_filename(
char* path,
char* fname)
{
char* fname_path;
fname_path = (char*) malloc(strlen(path)+
strlen("/etc/")+
strlen(fname)+
1);
if (fname_path == NULL)
{
goto return_fname_path;
}
sprintf(fname_path, "%s/etc/%s", path, fname);
if (!file_is_readable(fname_path))
{
free(fname_path);
fname_path = NULL;
}
return_fname_path:
return fname_path;
}
/**
* @node Expand path expression and if fname is provided, concatenate
@ -899,12 +877,12 @@ int main(int argc, char **argv)
int eno = 0; /**<! local variable for errno */
int opt;
void** threads; /**<! thread list */
char mysql_home[1024];
char ddopt[1024];
char mysql_home[PATH_MAX+1];
char datadir_arg[10+PATH_MAX+1]; /**<! '--datadir=' + PATH_MAX */
char language_arg[11+PATH_MAX+1]; /**<! '--language=' + PATH_MAX */
char* home_dir = NULL; /**<! home dir, to be freed */
char* cnf_file_path = NULL; /**<! conf file, to be freed */
char* cnf_file_arg = NULL; /**<! conf filename from cmd-line arg */
char* lib_dir = NULL; /**<! directory for dyn libs */
void* log_flush_thr = NULL;
ssize_t log_flush_timeout_ms = 0;
sigset_t sigset;
@ -1043,7 +1021,7 @@ int main(int argc, char **argv)
"the log from the following log files : \n\n");
r = sigfillset(&sigset);
/*r=1;/**/
if (r != 0)
{
eno = errno;
@ -1053,7 +1031,7 @@ int main(int argc, char **argv)
goto return_main;
}
r = sigdelset(&sigset, SIGHUP);
/*r=1;/**/
if (r != 0)
{
char* logerr = "Failed to delete signal SIGHUP from the "
@ -1065,7 +1043,7 @@ int main(int argc, char **argv)
goto return_main;
}
r = sigdelset(&sigset, SIGTERM);
/*r=1;/**/
if (r != 0)
{
char* logerr = "Failed to delete signal SIGTERM from the "
@ -1077,7 +1055,7 @@ int main(int argc, char **argv)
goto return_main;
}
r = sigprocmask(SIG_SETMASK, &sigset, NULL);
/*r=1;/**/
if (r != 0) {
char* logerr = "Failed to set the signal set for MaxScale."
" Exiting.";
@ -1096,7 +1074,7 @@ int main(int argc, char **argv)
char* fprerr = "Failed to initialize signal handlers. Exiting.";
char* logerr = NULL;
l = signal_set(SIGHUP, sighup_handler);
/*l=1;/**/
if (l != 0)
{
logerr = strdup("Failed to set signal handler for "
@ -1104,7 +1082,7 @@ int main(int argc, char **argv)
goto sigset_err;
}
l = signal_set(SIGTERM, sigterm_handler);
/*l=1;/**/
if (l != 0)
{
logerr = strdup("Failed to set signal handler for "
@ -1112,7 +1090,7 @@ int main(int argc, char **argv)
goto sigset_err;
}
l = signal_set(SIGINT, sigint_handler);
/*l=1; /**/
if (l != 0)
{
logerr = strdup("Failed to set signal handler for "
@ -1131,7 +1109,7 @@ int main(int argc, char **argv)
}
}
eno = pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask);
/*eno=EINTR; /**/
if (eno != 0)
{
char* logerr = "Failed to initialise signal mask for MaxScale. "
@ -1166,7 +1144,6 @@ int main(int argc, char **argv)
}
sprintf(mysql_home, "%s/mysql", home_dir);
setenv("MYSQL_HOME", mysql_home, 1);
}
/**
@ -1234,8 +1211,16 @@ int main(int argc, char **argv)
{
if (!strcmp(server_options[i], "--datadir="))
{
sprintf(ddopt, "--datadir=%s", datadir);
server_options[i] = ddopt;
snprintf(datadir_arg, 10+PATH_MAX+1, "--datadir=%s", datadir);
server_options[i] = datadir_arg;
}
else if (!strcmp(server_options[i], "--language="))
{
snprintf(language_arg,
11+PATH_MAX+1,
"--language=%s/mysql",
home_dir);
server_options[i] = language_arg;
}
}
@ -1246,12 +1231,23 @@ int main(int argc, char **argv)
char* fprerr = "Failed to initialise the MySQL library. "
"Exiting.";
print_log_n_stderr(false, true, fprerr, fprerr, 0);
if (mysql_errno(NULL) == 2000)
{
fprintf(stderr,
"*\n* Error : %s\n* Ensure that you have "
"MySQL error messages file, errmsg.sys in "
"\n* %s\n*\n",
mysql_error(NULL),
language_arg);
}
}
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : mysql_library_init failed. It is a "
"mandatory component, required by router services and "
"the MaxScale core. Error %s, %s : %d. Exiting.",
"the MaxScale core. Error %d, %s, %s : %d. Exiting.",
mysql_errno(NULL),
mysql_error(NULL),
__FILE__,
__LINE__);

View File

@ -70,9 +70,9 @@ char *(*ver)();
void *(*ep)(), *modobj;
MODULES *mod;
if ((mod = find_module(module)) == NULL)
if ((mod = find_module(module)) == NULL)
{
/*
/**
* The module is not already loaded
*
* Search of the shared object.

View File

@ -24,11 +24,11 @@ UTILSPATH := $(ROOT_PATH)/utils
CC=cc
CFLAGS=-c -fPIC -I. -I/usr/include -I../include -I../../include -I$(LOGPATH) \
-I$(UTILSPATH) -I$(MARIADB_SRC_PATH)/include/ -Wall -g
-I$(UTILSPATH) $(MYSQL_HEADERS) -Wall -g
LDFLAGS=-shared -L$(LOGPATH) -Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) \
-Wl,-rpath,$(MARIADB_SRC_PATH)/libmysqld
-Wl,-rpath,$(EMBEDDED_LIB)
@ -39,7 +39,7 @@ GALERAOBJ=$(GALERASRCS:.c=.o)
SRCS=$(MYSQLSRCS)
OBJ=$(SRCS:.c=.o)
LIBS=$(UTILSPATH)/skygw_utils.o -llog_manager \
-L$(MARIADB_SRC_PATH)/libmysqld -lmysqld
-L$(EMBEDDED_LIB) -lmysqld
MODULES=libmysqlmon.so libgaleramon.so

View File

@ -27,14 +27,14 @@ QCLASSPATH := $(ROOT_PATH)/query_classifier
CC=cc
CFLAGS=-c -fPIC -I/usr/include -I../../include -I../../../include \
-I$(LOGPATH) -I$(UTILSPATH) -I$(QCLASSPATH) \
-I$(MARIADB_SRC_PATH)/include -Wall -g
$(MYSQL_HEADERS) -Wall -g
include ../../../../makefile.inc
LDFLAGS=-shared -L$(LOGPATH) -L$(QCLASSPATH) -L$(MARIADB_SRC_PATH)/libmysqld \
LDFLAGS=-shared -L$(LOGPATH) -L$(QCLASSPATH) -L$(EMBEDDED_LIB) \
-Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) -Wl,-rpath,$(QCLASSPATH) \
-Wl,-rpath,$(MARIADB_SRC_PATH)/libmysqld
-Wl,-rpath,$(EMBEDDED_LIB)
SRCS=readwritesplit.c
OBJ=$(SRCS:.c=.o)

View File

@ -125,7 +125,7 @@ typedef enum skygw_chk_t {
# define STRQTYPE(t) ((t) == QUERY_TYPE_WRITE ? "QUERY_TYPE_WRITE" : \
((t) == QUERY_TYPE_READ ? "QUERY_TYPE_READ" : \
((t) == QUERY_TYPE_SESSION_WRITE ? "QUERY_TYPE_SESSION_WRITE" : \
((t) == QUERY_TYPE_UNKNOWN ? "QUERY_TYPE_UNKNWON" : \
((t) == QUERY_TYPE_UNKNOWN ? "QUERY_TYPE_UNKNOWN" : \
((t) == QUERY_TYPE_LOCAL_READ ? "QUERY_TYPE_LOCAL_READ" : \
"Unknown query type")))))

View File

@ -36,9 +36,12 @@
#define UINTLEN(i) (i<10 ? 1 : (i<100 ? 2 : (i<1000 ? 3 : CALCLEN(i))))
#if defined(__USE_POSIX)
# define PATH_MAX _POSIX_PATH_MAX
#else
# define PATH_MAX 256
#if !defined(PATH_MAX)
# if defined(__USE_POSIX)
# define PATH_MAX _POSIX_PATH_MAX
# else
# define PATH_MAX 256
# endif
#endif
#endif /* SKYGW_TYPES_H */

View File

@ -1713,8 +1713,8 @@ bool skygw_file_write(
bool flush)
{
bool succp = false;
int err = 0;
#if !defined(LAPTOP_TEST)
int err = 0;
size_t nwritten;
int fd;
static int writecount;