Reindent server/core/service.c

This commit is contained in:
Johan Wikman
2015-11-30 19:36:44 +02:00
parent ed06d4f14c
commit 8601068dc2
2 changed files with 1540 additions and 1410 deletions

File diff suppressed because it is too large Load Diff

View File

@ -65,19 +65,20 @@ struct users;
* that should be loaded to support the client connection and the port that the
* protocol should use to listen for incoming client connections.
*/
typedef struct servprotocol {
typedef struct servprotocol
{
char *protocol; /**< Protocol module to load */
unsigned short port; /**< Port to listen on */
char *address; /**< Address to listen with */
DCB *listener; /**< The DCB for the listener */
struct servprotocol
*next; /**< Next service protocol */
struct servprotocol *next; /**< Next service protocol */
} SERV_PROTOCOL;
/**
* The service statistics structure
*/
typedef struct {
typedef struct
{
time_t started; /**< The time when the service was started */
int n_failed_starts; /**< Number of times this service has failed to start */
int n_sessions; /**< Number of sessions created on service since start */
@ -89,8 +90,9 @@ typedef struct {
for this service to allow the gateway to login to the backend
database and extact information such as the user table or other
database status or configuration data.
*/
typedef struct {
*/
typedef struct
{
char *name; /**< The user name to use to extract information */
char *authdata; /**< The authentication data requied */
} SERVICE_USER;
@ -98,24 +100,28 @@ typedef struct {
/**
* The service refresh rate holds the counter and last load time_t
for this service to load users data from the backend database
*/
typedef struct {
*/
typedef struct
{
int nloads;
time_t last;
} SERVICE_REFRESH_RATE;
typedef struct server_ref_t{
typedef struct server_ref_t
{
struct server_ref_t *next;
SERVER* server;
}SERVER_REF;
typedef enum {
typedef enum
{
SSL_DISABLED,
SSL_ENABLED,
SSL_REQUIRED
} ssl_mode_t;
enum{
enum
{
SERVICE_SSLV3,
SERVICE_TLS10,
#ifdef OPENSSL_1_0
@ -142,19 +148,18 @@ enum{
* and a set of client side protocol/port pairs used to listen for new connections
* to the service.
*/
typedef struct service {
typedef struct service
{
char *name; /**< The service name */
int state; /**< The service state */
SERV_PROTOCOL *ports; /**< Linked list of ports and protocols
* that this service will listen on.
*/
char *routerModule; /**< Name of router module to use */
char **routerOptions;/**< Router specific option strings */
struct router_object
*router; /**< The router we are using */
void *router_instance;
/**< The router instance for this service */
char *version_string;/** version string for this service listeners */
char **routerOptions; /**< Router specific option strings */
struct router_object *router; /**< The router we are using */
void *router_instance; /**< The router instance for this service */
char *version_string; /** version string for this service listeners */
SERVER_REF *dbref; /** server references */
SERVICE_USER credentials; /**< The cedentials of the service user */
SPINLOCK spin; /**< The service spinlock */
@ -163,8 +168,7 @@ typedef struct service {
int enable_root; /**< Allow root user access */
int localhost_match_wildcard_host; /**< Match localhost against wildcard */
HASHTABLE *resources; /**< hastable for service resources, i.e. database names */
CONFIG_PARAMETER*
svc_config_param; /*< list of config params and values */
CONFIG_PARAMETER* svc_config_param;/*< list of config params and values */
int svc_config_version; /*< Version number of configuration */
bool svc_do_shutdown; /*< tells the service to exit loops etc. */
bool users_from_all; /*< Load users from one server or all of them */
@ -172,10 +176,8 @@ typedef struct service {
* when querying them from the server. MySQL Workbench seems
* to escape at least the underscore character. */
bool optimize_wildcard; /*< Convert wildcard grants to individual database grants */
SPINLOCK
users_table_spin; /**< The spinlock for users data refresh */
SERVICE_REFRESH_RATE
rate_limit; /**< The refresh rate limit for users table */
SPINLOCK users_table_spin; /**< The spinlock for users data refresh */
SERVICE_REFRESH_RATE rate_limit; /**< The refresh rate limit for users table */
FILTER_DEF **filters; /**< Ordered list of filters */
int n_filters; /**< Number of filters */
int conn_timeout; /*< Session timeout in seconds */
@ -195,7 +197,13 @@ typedef struct service {
bool log_auth_warnings; /*< Log authentication failures and warnings */
} SERVICE;
typedef enum count_spec_t {COUNT_NONE=0, COUNT_ATLEAST, COUNT_EXACT, COUNT_ATMOST} count_spec_t;
typedef enum count_spec_t
{
COUNT_NONE = 0,
COUNT_ATLEAST,
COUNT_EXACT,
COUNT_ATMOST
} count_spec_t;
#define SERVICE_STATE_ALLOC 1 /**< The service has been allocated */
#define SERVICE_STATE_STARTED 2 /**< The service has been started */
@ -231,28 +239,26 @@ extern void serviceSetRetryOnFailure(SERVICE *service, char* value);
extern void serviceWeightBy(SERVICE *, char *);
extern char *serviceGetWeightingParameter(SERVICE *);
extern int serviceEnableLocalhostMatchWildcardHost(SERVICE *, int);
int serviceStripDbEsc(SERVICE* service, int action);
int serviceAuthAllServers(SERVICE *service, int action);
int serviceOptimizeWildcard(SERVICE *service, int action);
extern int serviceStripDbEsc(SERVICE* service, int action);
extern int serviceAuthAllServers(SERVICE *service, int action);
extern int serviceOptimizeWildcard(SERVICE *service, int action);
extern void service_update(SERVICE *, char *, char *, char *);
extern int service_refresh_users(SERVICE *);
extern void printService(SERVICE *);
extern void printAllServices();
extern void dprintAllServices(DCB *);
bool service_set_param_value (
SERVICE* service,
extern bool service_set_param_value(SERVICE* service,
CONFIG_PARAMETER* param,
char* valstr,
count_spec_t count_spec,
config_param_type_t type);
extern void dprintService(DCB *, SERVICE *);
extern void dListServices(DCB *);
extern void dListListeners(DCB *);
char* service_get_name(SERVICE* svc);
void service_shutdown();
extern char* service_get_name(SERVICE* svc);
extern void service_shutdown();
extern int serviceSessionCountAll();
extern RESULTSET *serviceGetList();
extern RESULTSET *serviceGetListenerList();
#endif