server/modules/filter/Makefile: Fixed problem which prevented cleaning and compiling hintfilter library.
server/core/config.c: Removed unused if..else block from config_get_valint. Changed it also to return value which indicates whether the operation succeed. Added config_get_valbool similar to config_get_valint. service.c:Added typelib-like struct and array of valid boolean values. Fixed parameter type test in service_set_param_value. Completed boolean type parameter handling. hintparser.c:Fixed error message for non-maxscale hints. readwritesplit.c:Added loading of configuration parameters from service to instance and from instance to each new session. Fixed routing condition in get_route_target. Modified get_route_target so that it takes also rw_read_sesvars_from_slaves and rw_write_sesvars_to_all as parameters. skygw_types.h: added array size counting macro.
This commit is contained in:
@ -41,6 +41,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <ini.h>
|
||||
#include <config.h>
|
||||
#include <service.h>
|
||||
@ -887,12 +888,15 @@ config_param_type_t config_get_paramtype(
|
||||
return param->qfd_param_type;
|
||||
}
|
||||
|
||||
int config_get_valint(
|
||||
bool config_get_valint(
|
||||
int* val,
|
||||
CONFIG_PARAMETER* param,
|
||||
const char* name, /*< if NULL examine current param only */
|
||||
config_param_type_t ptype)
|
||||
{
|
||||
int val = -1; /*< -1 indicates failure */
|
||||
{
|
||||
bool succp = false;;
|
||||
|
||||
ss_dassert(ptype == COUNT_TYPE || ptype == PERCENT_TYPE);
|
||||
|
||||
while (param)
|
||||
{
|
||||
@ -900,29 +904,57 @@ int config_get_valint(
|
||||
{
|
||||
switch (ptype) {
|
||||
case COUNT_TYPE:
|
||||
val = param->qfd.valcount;
|
||||
goto return_val;
|
||||
*val = param->qfd.valcount;
|
||||
succp = true;
|
||||
goto return_succp;
|
||||
|
||||
case PERCENT_TYPE:
|
||||
val = param->qfd.valpercent;
|
||||
goto return_val;
|
||||
|
||||
case BOOL_TYPE:
|
||||
val = param->qfd.valbool;
|
||||
goto return_val;
|
||||
|
||||
default:
|
||||
goto return_val;
|
||||
*val = param->qfd.valpercent;
|
||||
succp =true;
|
||||
goto return_succp;
|
||||
|
||||
default:
|
||||
goto return_succp;
|
||||
}
|
||||
}
|
||||
else if (name == NULL)
|
||||
{
|
||||
goto return_val;
|
||||
}
|
||||
param = param->next;
|
||||
}
|
||||
return_val:
|
||||
return val;
|
||||
return_succp:
|
||||
return succp;
|
||||
}
|
||||
|
||||
|
||||
bool config_get_valbool(
|
||||
bool* val,
|
||||
CONFIG_PARAMETER* param,
|
||||
const char* name,
|
||||
config_param_type_t ptype)
|
||||
{
|
||||
bool succp;
|
||||
|
||||
ss_dassert(ptype == BOOL_TYPE);
|
||||
|
||||
if (ptype != BOOL_TYPE)
|
||||
{
|
||||
succp = false;
|
||||
goto return_succp;
|
||||
}
|
||||
|
||||
while (param)
|
||||
{
|
||||
if (name == NULL || !strncmp(param->name, name, MAX_PARAM_LEN))
|
||||
{
|
||||
*val = param->qfd.valbool;
|
||||
succp = true;
|
||||
goto return_succp;
|
||||
}
|
||||
param = param->next;
|
||||
}
|
||||
succp = false;
|
||||
|
||||
return_succp:
|
||||
return succp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ typedef struct typelib_st {
|
||||
const char** tl_p_elems;
|
||||
} typelib_t;
|
||||
|
||||
static const char* bool_strings[9]= {"FALSE", "TRUE", "OFF", "ON", "N", "Y", "0", "1", "NO", "YES", 0};
|
||||
typelib_t bool_typelib = {array_nelems(bool_strings)-1, "bool_typelib", bool_strings};
|
||||
static const char* bool_strings[11]= {"FALSE", "TRUE", "OFF", "ON", "N", "Y", "0", "1", "NO", "YES", 0};
|
||||
typelib_t bool_type = {array_nelems(bool_strings)-1, "bool_type", bool_strings};
|
||||
|
||||
static SPINLOCK service_spin = SPINLOCK_INIT;
|
||||
static SERVICE *allServices = NULL;
|
||||
@ -1026,7 +1026,7 @@ bool service_set_param_value (
|
||||
bool valbool;
|
||||
bool succp = true;
|
||||
|
||||
if (type == PERCENT_TYPE || type == COUNT_TYPE)
|
||||
if (PARAM_IS_TYPE(type,PERCENT_TYPE) ||PARAM_IS_TYPE(type,COUNT_TYPE))
|
||||
{
|
||||
/**
|
||||
* Find out whether the value is numeric and ends with '%' or '\0'
|
||||
@ -1090,7 +1090,7 @@ bool service_set_param_value (
|
||||
{
|
||||
unsigned int rc;
|
||||
|
||||
rc = find_type(&bool_typelib, valstr, strlen(valstr)+1);
|
||||
rc = find_type(&bool_type, valstr, strlen(valstr)+1);
|
||||
|
||||
if (rc > 0)
|
||||
{
|
||||
@ -1103,6 +1103,10 @@ bool service_set_param_value (
|
||||
{
|
||||
valbool = true;
|
||||
}
|
||||
/** add param to config */
|
||||
config_set_qualified_param(param,
|
||||
(void *)&valbool,
|
||||
BOOL_TYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1111,7 +1115,7 @@ bool service_set_param_value (
|
||||
}
|
||||
if (succp)
|
||||
{
|
||||
config_set_qualified_param(param, (void *)&valbool, BOOL_TYPE); /*< add param to config */
|
||||
service_add_qualified_param(service, param); /*< add param to svc */
|
||||
}
|
||||
return succp;
|
||||
}
|
||||
@ -1152,8 +1156,6 @@ static int find_type(
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add qualified config parameter to SERVICE struct.
|
||||
|
||||
Reference in New Issue
Block a user