Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop
This commit is contained in:
commit
a3675e9098
@ -145,6 +145,7 @@ SERVICE *service;
|
||||
service->filters = NULL;
|
||||
service->n_filters = 0;
|
||||
service->weightby = 0;
|
||||
service->users = NULL;
|
||||
service->resources = NULL;
|
||||
spinlock_init(&service->spin);
|
||||
spinlock_init(&service->users_table_spin);
|
||||
@ -213,42 +214,46 @@ GWPROTOCOL *funcs;
|
||||
if (strcmp(port->protocol, "MySQLClient") == 0) {
|
||||
int loaded;
|
||||
|
||||
/*
|
||||
* Allocate specific data for MySQL users
|
||||
* including hosts and db names
|
||||
*/
|
||||
service->users = mysql_users_alloc();
|
||||
|
||||
if ((loaded = load_mysql_users(service)) < 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to load users from %s:%d for "
|
||||
"service %s.",
|
||||
port->address,
|
||||
port->port,
|
||||
service->name)));
|
||||
hashtable_free(service->users->data);
|
||||
free(service->users);
|
||||
dcb_free(port->listener);
|
||||
port->listener = NULL;
|
||||
goto retblock;
|
||||
}
|
||||
/* At service start last update is set to USERS_REFRESH_TIME seconds earlier.
|
||||
* This way MaxScale could try reloading users' just after startup
|
||||
*/
|
||||
service->rate_limit.last=time(NULL) - USERS_REFRESH_TIME;
|
||||
service->rate_limit.nloads=1;
|
||||
if (service->users == NULL) {
|
||||
/*
|
||||
* Allocate specific data for MySQL users
|
||||
* including hosts and db names
|
||||
*/
|
||||
service->users = mysql_users_alloc();
|
||||
|
||||
if ((loaded = load_mysql_users(service)) < 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to load users from %s:%d for "
|
||||
"service %s.",
|
||||
port->address,
|
||||
port->port,
|
||||
service->name)));
|
||||
hashtable_free(service->users->data);
|
||||
free(service->users);
|
||||
dcb_free(port->listener);
|
||||
port->listener = NULL;
|
||||
goto retblock;
|
||||
}
|
||||
/* At service start last update is set to USERS_REFRESH_TIME seconds earlier.
|
||||
* This way MaxScale could try reloading users' just after startup
|
||||
*/
|
||||
service->rate_limit.last=time(NULL) - USERS_REFRESH_TIME;
|
||||
service->rate_limit.nloads=1;
|
||||
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Loaded %d MySQL Users for service [%s].",
|
||||
loaded, service->name)));
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Loaded %d MySQL Users for service [%s].",
|
||||
loaded, service->name)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Generic users table */
|
||||
service->users = users_alloc();
|
||||
if (service->users == NULL) {
|
||||
/* Generic users table */
|
||||
service->users = users_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
if ((funcs=(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL))
|
||||
|
@ -550,7 +550,7 @@ HINT_TOKEN *tok;
|
||||
else if (!inword && inquote == '\0' && **ptr == '=')
|
||||
{
|
||||
*dest = **ptr;
|
||||
*dest++;
|
||||
dest++;
|
||||
(*ptr)++;
|
||||
break;
|
||||
}
|
||||
|
@ -748,9 +748,12 @@ int load_filter(FILTERCHAIN* fc, CONFIG* cnf)
|
||||
}
|
||||
|
||||
int x;
|
||||
for(x = 0;x<paramc;x++){
|
||||
free(fparams[x]->name);
|
||||
free(fparams[x]->value);
|
||||
|
||||
if(fparams){
|
||||
for(x = 0;x<paramc;x++){
|
||||
free(fparams[x]->name);
|
||||
free(fparams[x]->value);
|
||||
}
|
||||
}
|
||||
|
||||
free(fparams);
|
||||
@ -769,15 +772,18 @@ FILTERCHAIN* load_filter_module(char* str)
|
||||
flt_ptr->next = instance.head;
|
||||
}
|
||||
|
||||
if((flt_ptr->instance = (FILTER_OBJECT*)load_module(str, MODULE_FILTER)) == NULL)
|
||||
{
|
||||
printf("Error: Module loading failed: %s\n",str);
|
||||
skygw_log_write(LOGFILE_ERROR,"Error: Module loading failed: %s\n",str);
|
||||
free(flt_ptr->down);
|
||||
free(flt_ptr);
|
||||
return NULL;
|
||||
}
|
||||
flt_ptr->name = strdup(str);
|
||||
if(flt_ptr){
|
||||
if( (flt_ptr->instance = (FILTER_OBJECT*)load_module(str, MODULE_FILTER)) == NULL)
|
||||
{
|
||||
printf("Error: Module loading failed: %s\n",str);
|
||||
skygw_log_write(LOGFILE_ERROR,"Error: Module loading failed: %s\n",str);
|
||||
free(flt_ptr->down);
|
||||
free(flt_ptr);
|
||||
return NULL;
|
||||
}
|
||||
flt_ptr->name = strdup(str);
|
||||
}
|
||||
|
||||
return flt_ptr;
|
||||
}
|
||||
|
||||
@ -925,14 +931,35 @@ GWBUF* gen_packet(PACKET pkt)
|
||||
|
||||
int process_opts(int argc, char** argv)
|
||||
{
|
||||
unsigned int fd = open_file("harness.cnf",1), buffsize = 1024;
|
||||
int rd,rdsz;
|
||||
unsigned int fsize;
|
||||
int fd, buffsize = 1024;
|
||||
int rd,rdsz, rval;
|
||||
size_t fsize;
|
||||
char *buff = calloc(buffsize,sizeof(char)), *tok = NULL;
|
||||
|
||||
/**Parse 'harness.cnf' file*/
|
||||
fsize = lseek(fd,0,SEEK_END);
|
||||
lseek(fd,0,SEEK_SET);
|
||||
|
||||
if(buff == NULL){
|
||||
printf("Error: Call to malloc() failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((fd = open_file("harness.cnf",1)) < 0){
|
||||
printf("Failed to open configuration file.\n");
|
||||
free(buff);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if( (rval = lseek(fd,0,SEEK_END)) < 0 ||
|
||||
lseek(fd,0,SEEK_SET) < 0){
|
||||
printf("Error: Cannot seek file.\n");
|
||||
close(fd);
|
||||
free(buff);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fsize = (size_t)rval;
|
||||
|
||||
instance.thrcount = 1;
|
||||
instance.session_count = 1;
|
||||
rdsz = read(fd,buff,fsize);
|
||||
|
@ -768,9 +768,43 @@ int gw_do_connect_to_backend(
|
||||
setipaddress(&serv_addr.sin_addr, host);
|
||||
serv_addr.sin_port = htons(port);
|
||||
bufsize = GW_BACKEND_SO_SNDBUF;
|
||||
setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize));
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
"%s:%d failed.\n\t\t Socket configuration failed "
|
||||
"due %d, %s.",
|
||||
host,
|
||||
port,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
rv = -1;
|
||||
goto return_rv;
|
||||
}
|
||||
|
||||
bufsize = GW_BACKEND_SO_RCVBUF;
|
||||
setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize));
|
||||
|
||||
if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
"%s:%d failed.\n\t\t Socket configuration failed "
|
||||
"due %d, %s.",
|
||||
host,
|
||||
port,
|
||||
eno,
|
||||
strerror(eno))));
|
||||
rv = -1;
|
||||
goto return_rv;
|
||||
}
|
||||
|
||||
/* set socket to as non-blocking here */
|
||||
setnonblocking(so);
|
||||
rv = connect(so, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||
|
@ -830,8 +830,16 @@ static void* newSession(
|
||||
* Find a backend servers to connect to.
|
||||
* This command requires that rsession's lock is held.
|
||||
*/
|
||||
rses_begin_locked_router_action(client_rses);
|
||||
|
||||
succp = rses_begin_locked_router_action(client_rses);
|
||||
|
||||
if(!succp){
|
||||
free(client_rses->rses_backend_ref);
|
||||
free(client_rses);
|
||||
client_rses = NULL;
|
||||
goto return_rses;
|
||||
}
|
||||
|
||||
succp = select_connect_backend_servers(&master_ref,
|
||||
backend_ref,
|
||||
router_nservers,
|
||||
@ -1613,8 +1621,12 @@ void check_create_tmp_table(
|
||||
rses_prop_tmp->rses_prop_type = RSES_PROP_TYPE_TMPTABLES;
|
||||
router_cli_ses->rses_properties[RSES_PROP_TYPE_TMPTABLES] = rses_prop_tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error : Call to malloc() failed.")));
|
||||
}
|
||||
}
|
||||
|
||||
if(rses_prop_tmp){
|
||||
if (rses_prop_tmp->rses_prop_data.temp_tables == NULL)
|
||||
{
|
||||
h = hashtable_alloc(7, hashkeyfun, hashcmpfun);
|
||||
@ -1650,6 +1662,8 @@ void check_create_tmp_table(
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
free(hkey);
|
||||
free(tblname);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
if(MYSQLCLIENT_FOUND)
|
||||
add_executable(testconnect testconnect.c)
|
||||
message(STATUS "Linking against: ${MYSQLCLIENT_LIBRARIES}")
|
||||
target_link_libraries(testconnect ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m)
|
||||
target_link_libraries(testconnect ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt)
|
||||
add_test(NAME ReadConnRouterLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT} 1.10)
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user