Modifications to building
This commit is contained in:
		@ -24,4 +24,8 @@ add_library(topfilter SHARED topfilter.c)
 | 
			
		||||
target_link_libraries(topfilter log_manager utils)
 | 
			
		||||
install(TARGETS topfilter DESTINATION modules)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(hint)
 | 
			
		||||
add_subdirectory(hint)
 | 
			
		||||
 | 
			
		||||
if(BUILD_TESTS)
 | 
			
		||||
  add_subdirectory(test)
 | 
			
		||||
endif()
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 | 
			
		||||
add_executable(harness_ui harness_ui.c harness_common.c)
 | 
			
		||||
add_executable(harness harness_util.c harness_common.c)
 | 
			
		||||
target_link_libraries(harness_ui log_manager utils pthread)
 | 
			
		||||
target_link_libraries(harness log_manager utils pthread)
 | 
			
		||||
target_link_libraries(harness_ui log_manager utils pthread fullcore)
 | 
			
		||||
target_link_libraries(harness log_manager utils pthread fullcore)
 | 
			
		||||
add_test(TestHintfilter /bin/sh -c "${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.input -o ${CMAKE_CURRENT_BINARY_DIR}/hint_testig.output -c ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.cnf -t 2 -s 10 && diff ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.expected ${CMAKE_CURRENT_BINARY_DIR}/hint_testig.output;exit $?")
 | 
			
		||||
@ -33,14 +33,14 @@ LDFLAGS=-rdynamic -L$(LOGPATH) -L$(UTILSPATH) -L$(EMBEDDED_LIB) \
 | 
			
		||||
	-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) \
 | 
			
		||||
	-Wl,-rpath,$(EMBEDDED_LIB)
 | 
			
		||||
 | 
			
		||||
SRCS=harness.c 
 | 
			
		||||
SRCS=harness_util.c harness_common.c
 | 
			
		||||
OBJ=$(SRCS:.c=.o)
 | 
			
		||||
COREOBJ=$(COREPATH)/load_utils.o $(COREPATH)/dcb.o $(COREPATH)/utils.o \
 | 
			
		||||
	$(COREPATH)/gw_utils.o $(COREPATH)/buffer.o $(COREPATH)/poll.o \
 | 
			
		||||
	$(COREPATH)/spinlock.o	$(COREPATH)/gwbitmask.o $(COREPATH)/session.o \
 | 
			
		||||
	$(COREPATH)/atomic.o $(COREPATH)/hashtable.o $(COREPATH)/filter.o $(COREPATH)/modutil.o $(ROOT_PATH)/server/inih/ini.o \
 | 
			
		||||
	$(COREPATH)/hint.o
 | 
			
		||||
LIBS= $(UTILSPATH)/skygw_utils.o -lssl -pthread -llog_manager -lmysqld -ldl -lcrypto
 | 
			
		||||
	$(COREPATH)/hint.o $(COREPATH)/config.o $(COREPATH)/service.o $(COREPATH)/server.o $(COREPATH)/monitor.o $(COREPATH)/housekeeper.o $(COREPATH)/adminusers.o $(COREPATH)/dbusers.o $(COREPATH)/thread.o $(COREPATH)/users.o $(COREPATH)/secrets.o
 | 
			
		||||
LIBS= $(UTILSPATH)/skygw_utils.o -lssl -pthread -llog_manager -lmysqld -ldl -lcrypto -lcrypt -lm
 | 
			
		||||
MODULES := $(wildcard ../*.so)
 | 
			
		||||
 | 
			
		||||
all: build
 | 
			
		||||
 | 
			
		||||
@ -75,9 +75,9 @@
 | 
			
		||||
 */
 | 
			
		||||
typedef struct CONFIG_ITEM_T
 | 
			
		||||
{
 | 
			
		||||
  char* name;
 | 
			
		||||
  char* value;
 | 
			
		||||
  struct CONFIG_ITEM_T* next;
 | 
			
		||||
	char* name;
 | 
			
		||||
	char* value;
 | 
			
		||||
	struct CONFIG_ITEM_T* next;
 | 
			
		||||
}CONFIG_ITEM;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -86,9 +86,9 @@ typedef struct CONFIG_ITEM_T
 | 
			
		||||
 */
 | 
			
		||||
typedef struct CONFIG_T
 | 
			
		||||
{
 | 
			
		||||
  char* section;
 | 
			
		||||
  CONFIG_ITEM* item;
 | 
			
		||||
  struct CONFIG_T* next;
 | 
			
		||||
	char* section;
 | 
			
		||||
	CONFIG_ITEM* item;
 | 
			
		||||
	struct CONFIG_T* next;
 | 
			
		||||
  
 | 
			
		||||
}CONFIG;
 | 
			
		||||
 | 
			
		||||
@ -98,13 +98,13 @@ typedef struct CONFIG_T
 | 
			
		||||
 */
 | 
			
		||||
struct FILTERCHAIN_T
 | 
			
		||||
{
 | 
			
		||||
  FILTER* filter; /**An instance of a particular filter*/
 | 
			
		||||
  FILTER_OBJECT* instance; /**Dynamically loaded module*/
 | 
			
		||||
  SESSION** session; /**A list of sessions*/
 | 
			
		||||
  DOWNSTREAM** down; /** A list of next filters downstreams*/
 | 
			
		||||
  UPSTREAM** up; /** A list of next filters upstreams*/
 | 
			
		||||
  char* name; /**Module name*/
 | 
			
		||||
  struct FILTERCHAIN_T* next;
 | 
			
		||||
	FILTER* filter; /**An instance of a particular filter*/
 | 
			
		||||
	FILTER_OBJECT* instance; /**Dynamically loaded module*/
 | 
			
		||||
	SESSION** session; /**A list of sessions*/
 | 
			
		||||
	DOWNSTREAM** down; /** A list of next filters downstreams*/
 | 
			
		||||
	UPSTREAM** up; /** A list of next filters upstreams*/
 | 
			
		||||
	char* name; /**Module name*/
 | 
			
		||||
	struct FILTERCHAIN_T* next;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct FILTERCHAIN_T FILTERCHAIN;
 | 
			
		||||
@ -114,27 +114,29 @@ typedef struct FILTERCHAIN_T FILTERCHAIN;
 | 
			
		||||
 */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  int running;
 | 
			
		||||
  int verbose; /**Whether to print to stdout*/
 | 
			
		||||
  int infile; /**A file where the queries are loaded from*/
 | 
			
		||||
  char* infile_name;
 | 
			
		||||
  int outfile; /**A file where the output of the filters is logged*/
 | 
			
		||||
  char* outfile_name;
 | 
			
		||||
  FILTERCHAIN* head; /**The head of the filter chain*/
 | 
			
		||||
  FILTERCHAIN* tail; /**The tail of the filter chain*/
 | 
			
		||||
  GWBUF** buffer; /**Buffers that are fed to the filter chain*/
 | 
			
		||||
  int buffer_count;
 | 
			
		||||
  int session_count;
 | 
			
		||||
  DOWNSTREAM dummyrouter; /**Dummy downstream router for data extraction*/
 | 
			
		||||
  UPSTREAM dummyclient; /**Dummy downstream router for data extraction*/
 | 
			
		||||
  CONFIG* conf; /**Configurations loaded from a file*/
 | 
			
		||||
  pthread_mutex_t work_mtx; /**Mutex for buffer routing*/
 | 
			
		||||
  int buff_ind; /**Index of first unrouted buffer*/
 | 
			
		||||
  int sess_ind;/**Index of first unused session*/
 | 
			
		||||
  int last_ind; /**Index of last used session*/
 | 
			
		||||
  pthread_t* thrpool;
 | 
			
		||||
  int thrcount; /**Number of active threads*/
 | 
			
		||||
  int rt_delay; /**Delay each thread waits after routing a query, in milliseconds*/
 | 
			
		||||
	int running;
 | 
			
		||||
	int verbose; /**Whether to print to stdout*/
 | 
			
		||||
	int infile; /**A file where the queries are loaded from*/
 | 
			
		||||
	int error;
 | 
			
		||||
	char* mod_dir; /**Module directory absolute path*/
 | 
			
		||||
	char* infile_name;
 | 
			
		||||
	int outfile; /**A file where the output of the filters is logged*/
 | 
			
		||||
	char* outfile_name;
 | 
			
		||||
	FILTERCHAIN* head; /**The head of the filter chain*/
 | 
			
		||||
	FILTERCHAIN* tail; /**The tail of the filter chain*/
 | 
			
		||||
	GWBUF** buffer; /**Buffers that are fed to the filter chain*/
 | 
			
		||||
	int buffer_count;
 | 
			
		||||
	int session_count;
 | 
			
		||||
	DOWNSTREAM dummyrouter; /**Dummy downstream router for data extraction*/
 | 
			
		||||
	UPSTREAM dummyclient; /**Dummy downstream router for data extraction*/
 | 
			
		||||
	CONFIG* conf; /**Configurations loaded from a file*/
 | 
			
		||||
	pthread_mutex_t work_mtx; /**Mutex for buffer routing*/
 | 
			
		||||
	int buff_ind; /**Index of first unrouted buffer*/
 | 
			
		||||
	int sess_ind;/**Index of first unused session*/
 | 
			
		||||
	int last_ind; /**Index of last used session*/
 | 
			
		||||
	pthread_t* thrpool;
 | 
			
		||||
	int thrcount; /**Number of active threads*/
 | 
			
		||||
	int rt_delay; /**Delay each thread waits after routing a query, in milliseconds*/
 | 
			
		||||
}HARNESS_INSTANCE;
 | 
			
		||||
 | 
			
		||||
static HARNESS_INSTANCE instance;
 | 
			
		||||
@ -144,33 +146,33 @@ static HARNESS_INSTANCE instance;
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
typedef enum 
 | 
			
		||||
  {
 | 
			
		||||
    UNDEFINED,
 | 
			
		||||
    RUNFILTERS,
 | 
			
		||||
    LOAD_FILTER,
 | 
			
		||||
    DELETE_FILTER,
 | 
			
		||||
    LOAD_CONFIG,
 | 
			
		||||
    SET_INFILE,
 | 
			
		||||
    SET_OUTFILE,
 | 
			
		||||
    THR_COUNT,
 | 
			
		||||
    SESS_COUNT,
 | 
			
		||||
    OK,
 | 
			
		||||
    QUIT
 | 
			
		||||
  } operation_t;
 | 
			
		||||
	{
 | 
			
		||||
		UNDEFINED,
 | 
			
		||||
		RUNFILTERS,
 | 
			
		||||
		LOAD_FILTER,
 | 
			
		||||
		DELETE_FILTER,
 | 
			
		||||
		LOAD_CONFIG,
 | 
			
		||||
		SET_INFILE,
 | 
			
		||||
		SET_OUTFILE,
 | 
			
		||||
		THR_COUNT,
 | 
			
		||||
		SESS_COUNT,
 | 
			
		||||
		OK,
 | 
			
		||||
		QUIT
 | 
			
		||||
	} operation_t;
 | 
			
		||||
 | 
			
		||||
typedef enum
 | 
			
		||||
  {
 | 
			
		||||
    PACKET_OK,
 | 
			
		||||
    PACKET_ERROR,
 | 
			
		||||
    PACKET_RESULT_SET
 | 
			
		||||
  } packet_t;
 | 
			
		||||
	{
 | 
			
		||||
		PACKET_OK,
 | 
			
		||||
		PACKET_ERROR,
 | 
			
		||||
		PACKET_RESULT_SET
 | 
			
		||||
	} packet_t;
 | 
			
		||||
 | 
			
		||||
typedef packet_t PACKET;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the static instance.
 | 
			
		||||
 */
 | 
			
		||||
int init(int argc,char** argv);
 | 
			
		||||
int harness_init(int argc,char** argv);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Frees all the query buffers
 | 
			
		||||
@ -257,7 +259,7 @@ int load_query();
 | 
			
		||||
 * @return Non-zero on success, zero in case parsing is finished.
 | 
			
		||||
 * @see load_config()
 | 
			
		||||
 */
 | 
			
		||||
static int handler(void* user, const char* section, const char* name,const char* value);
 | 
			
		||||
int handler(void* user, const char* section, const char* name,const char* value);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Removes all non-filter modules from the configuration
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#include <harness.h>
 | 
			
		||||
 | 
			
		||||
int harness_init(int argc, char** argv){
 | 
			
		||||
  
 | 
			
		||||
	int i = 0;  
 | 
			
		||||
	if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){
 | 
			
		||||
		skygw_logmanager_init(0,NULL);
 | 
			
		||||
	}
 | 
			
		||||
@ -36,8 +36,6 @@ int harness_init(int argc, char** argv){
 | 
			
		||||
    pthread_create(&instance.thrpool[i],NULL,(void*)work_buffer,(void*)thr_num++);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -372,7 +370,7 @@ int load_query()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int handler(void* user, const char* section, const char* name,
 | 
			
		||||
int handler(void* user, const char* section, const char* name,
 | 
			
		||||
                   const char* value)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -508,8 +506,19 @@ int load_config( char* fname)
 | 
			
		||||
    while(item){
 | 
			
		||||
      
 | 
			
		||||
      if(!strcmp("module",item->name)){
 | 
			
		||||
	
 | 
			
		||||
	instance.head = load_filter_module(item->value);
 | 
			
		||||
 | 
			
		||||
		  if(instance.mod_dir){
 | 
			
		||||
			  char* modstr = malloc(sizeof(char)*(strlen(instance.mod_dir) + strlen(item->value)));
 | 
			
		||||
			  strcpy(modstr,instance.mod_dir);
 | 
			
		||||
			  strcat(modstr,"/");
 | 
			
		||||
			  strcat(modstr,item->value);
 | 
			
		||||
			  instance.head = load_filter_module(modstr);
 | 
			
		||||
			  free(modstr);
 | 
			
		||||
		  }else{
 | 
			
		||||
			  instance.head = load_filter_module(item->value);
 | 
			
		||||
		  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if(!instance.head || !load_filter(instance.head,instance.conf)){
 | 
			
		||||
 | 
			
		||||
	  printf("Error creating filter instance!\nModule: %s\n",item->value);
 | 
			
		||||
@ -916,7 +925,7 @@ int process_opts(int argc, char** argv)
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
  char* conf_name = NULL;
 | 
			
		||||
  while((rd = getopt(argc,argv,"c:i:o:s:t:d:qh")) > 0){
 | 
			
		||||
  while((rd = getopt(argc,argv,"m:c:i:o:s:t:d:qh")) > 0){
 | 
			
		||||
    switch(rd){
 | 
			
		||||
 | 
			
		||||
    case 'o':
 | 
			
		||||
@ -968,6 +977,11 @@ int process_opts(int argc, char** argv)
 | 
			
		||||
	     "\t-d\tRouting delay\n");
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
	case 'm':
 | 
			
		||||
		instance.mod_dir = strdup(optarg);
 | 
			
		||||
		printf("Module directory: %s",optarg);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
	
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
@ -188,7 +188,7 @@ int main(int argc, char** argv){
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	instance.thrpool = t_thr_pool;
 | 
			
		||||
	thr_num = 1;
 | 
			
		||||
	int thr_num = 1;
 | 
			
		||||
 | 
			
		||||
	for(i = 0;i<instance.thrcount;i++){
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#include <harness.h>
 | 
			
		||||
int main()
 | 
			
		||||
int main(int argc,char** argv)
 | 
			
		||||
{
 | 
			
		||||
	if(harness_init(argc,argv)){
 | 
			
		||||
	if(harness_init(argc,argv) || instance.error){
 | 
			
		||||
		printf("Error: Initialization failed.\n");
 | 
			
		||||
		skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n");
 | 
			
		||||
		skygw_logmanager_done();
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user