Move config_runtime.h and externcmd.h to core

+ some cleanup
This commit is contained in:
Esa Korhonen
2017-01-24 12:40:44 +02:00
parent 641896872e
commit b187afdcf4
10 changed files with 19 additions and 25 deletions

View File

@ -10,17 +10,18 @@
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include "maxscale/config_runtime.h"
#include <strings.h>
#include <maxscale/atomic.h>
#include <maxscale/config_runtime.h>
#include <maxscale/paths.h>
#include <maxscale/spinlock.h>
#include "maxscale/config.h"
#include "maxscale/service.h"
#include "maxscale/monitor.h"
#include "maxscale/modules.h"
#include "maxscale/service.h"
static SPINLOCK crt_lock = SPINLOCK_INIT;

View File

@ -11,9 +11,17 @@
* Public License.
*/
#include <maxscale/externcmd.h>
#include "maxscale/externcmd.h"
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <maxscale/alloc.h>
#include <maxscale/log_manager.h>
#include <maxscale/pcre2.h>
/**
* Tokenize a string into arguments suitable for a execvp call.

View File

@ -0,0 +1,178 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* @file config_runtime.h - Functions for runtime configuration modifications
*/
#include <maxscale/cdefs.h>
#include <maxscale/monitor.h>
#include <maxscale/server.h>
#include <maxscale/service.h>
/**
* @brief Create a new server
*
* This function creates a new, persistent server by first allocating a new
* server and then storing the resulting configuration file on disk. This
* function should be used only from administrative interface modules and internal
* modules should use server_alloc() instead.
*
* @param name Server name
* @param address Network address
* @param port Network port
* @param protocol Protocol module name
* @param authenticator Authenticator module name
* @param options Options for the authenticator module
* @return True on success, false if an error occurred
*/
bool runtime_create_server(const char *name, const char *address,
const char *port, const char *protocol,
const char *authenticator, const char *options);
/**
* @brief Destroy a server
*
* This removes any created server configuration files and marks the server removed
* If the server is not in use.
*
* @param server Server to destroy
* @return True if server was destroyed
*/
bool runtime_destroy_server(SERVER *server);
/**
* @brief Link a server to an object
*
* This function links the server to another object. The target can be either
* a monitor or a service.
*
* @param server Server to link
* @param target The monitor or service where the server is added
* @return True if the object was found and the server was linked to it, false
* if no object matching @c target was found
*/
bool runtime_link_server(SERVER *server, const char *target);
/**
* @brief Unlink a server from an object
*
* This function unlinks the server from another object. The target can be either
* a monitor or a service.
*
* @param server Server to unlink
* @param target The monitor or service from which the server is removed
* @return True if the object was found and the server was unlinked from it, false
* if no object matching @c target was found
*/
bool runtime_unlink_server(SERVER *server, const char *target);
/**
* @brief Alter server parameters
*
* @param server Server to alter
* @param key Key to modify
* @param value New value
* @return True if @c key was one of the supported parameters
*/
bool runtime_alter_server(SERVER *server, char *key, char *value);
/**
* @brief Enable SSL for a server
*
* The @c key , @c cert and @c ca parameters are required. @c version and @c depth
* are optional.
*
* @note SSL cannot be disabled at runtime.
*
* @param server Server to configure
* @param key Path to SSL private key
* @param cert Path to SSL public certificate
* @param ca Path to certificate authority
* @param version Required SSL Version
* @param depth Certificate verification depth
* @return True if SSL was successfully enabled
*/
bool runtime_enable_server_ssl(SERVER *server, const char *key, const char *cert,
const char *ca, const char *version, const char *depth);
/**
* @brief Alter monitor parameters
*
* @param monitor Monitor to alter
* @param key Key to modify
* @param value New value
* @return True if @c key was one of the supported parameters
*/
bool runtime_alter_monitor(MXS_MONITOR *monitor, char *key, char *value);
/**
* @brief Create a new listener for a service
*
* This function adds a new listener to a service and starts it.
*
* @param service Service where the listener is added
* @param name Name of the listener
* @param addr Listening address, NULL for default of 0.0.0.0
* @param port Listening port, NULL for default of 3306
* @param proto Listener protocol, NULL for default of "MySQLClient"
* @param auth Listener authenticator, NULL for protocol default authenticator
* @param auth_opt Options for the authenticator, NULL for no options
* @param ssl_key SSL key, NULL for no key
* @param ssl_cert SSL cert, NULL for no cert
* @param ssl_ca SSL CA cert, NULL for no CA cert
* @param ssl_version SSL version, NULL for default of "MAX"
* @param ssl_depth SSL cert verification depth, NULL for default
*
* @return True if the listener was successfully created and started
*/
bool runtime_create_listener(SERVICE *service, const char *name, const char *addr,
const char *port, const char *proto, const char *auth,
const char *auth_opt, const char *ssl_key,
const char *ssl_cert, const char *ssl_ca,
const char *ssl_version, const char *ssl_depth);
/**
* @brief Destroy a listener
*
* This disables the listener by removing it from the polling system. It also
* removes any generated configurations for this listener.
*
* @param service Service where the listener exists
* @param name Name of the listener
*
* @return True if the listener was successfully destroyed
*/
bool runtime_destroy_listener(SERVICE *service, const char *name);
/**
* @brief Create a new monitor
*
* @param name Name of the monitor
* @param module Monitor module
* @return True if new monitor was created and persisted
*/
bool runtime_create_monitor(const char *name, const char *module);
/**
* @brief Destroy a monitor
*
* Monitors are not removed from the runtime configuration but they are stopped.
* Destroyed monitor are removed after a restart.
*
* @param monitor Monitor to destroy
* @return True if monitor was destroyed
*/
bool runtime_destroy_monitor(MXS_MONITOR *monitor);

View File

@ -0,0 +1,39 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
*
* Change Date: 2019-07-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cdefs.h>
#include <unistd.h>
MXS_BEGIN_DECLS
#define MAXSCALE_EXTCMD_ARG_MAX 256
typedef struct extern_cmd_t
{
char** argv; /*< Argument vector for the command, first being the actual command
* being executed. */
int n_exec; /*< Number of times executed */
pid_t child; /*< PID of the child process */
} EXTERNCMD;
char* externcmd_extract_command(const char* argstr);
EXTERNCMD* externcmd_allocate(char* argstr);
void externcmd_free(EXTERNCMD* cmd);
int externcmd_execute(EXTERNCMD* cmd);
bool externcmd_substitute_arg(EXTERNCMD* cmd, const char* re, const char* replace);
bool externcmd_can_execute(const char* argstr);
bool externcmd_matches(const EXTERNCMD* cmd, const char* match);
MXS_END_DECLS

View File

@ -35,7 +35,6 @@
#include <maxscale/alloc.h>
#include <mysqld_error.h>
#include <maxscale/externcmd.h>
#include <maxscale/paths.h>
#include <maxscale/log_manager.h>
#include <maxscale/mysql_utils.h>
@ -44,6 +43,7 @@
#include <maxscale/spinlock.h>
#include "maxscale/config.h"
#include "maxscale/externcmd.h"
#include "maxscale/monitor.h"
#include "maxscale/modules.h"

View File

@ -31,7 +31,6 @@
#include <string.h>
#include <maxscale/monitor.h>
#include <maxscale/spinlock.h>
#include <maxscale/externcmd.h>
#include <maxscale/thread.h>
#include <mysql.h>
#include <mysqld_error.h>

View File

@ -28,7 +28,6 @@
#include <maxscale/dcb.h>
#include <maxscale/modinfo.h>
#include <maxscale/config.h>
#include <maxscale/externcmd.h>
/**
* @file mmmon.h - The Multi-Master monitor

View File

@ -48,7 +48,6 @@
#include <maxscale/dcb.h>
#include <maxscale/modinfo.h>
#include <maxscale/config.h>
#include <maxscale/externcmd.h>
#include <maxscale/hashtable.h>
MXS_BEGIN_DECLS

View File

@ -46,6 +46,7 @@
*
* @endverbatim
*/
#include <maxscale/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
@ -71,10 +72,10 @@
#include <maxscale/housekeeper.h>
#include <maxscale/listmanager.h>
#include <maxscale/maxscale.h>
#include <maxscale/config_runtime.h>
#include <maxscale/version.h>
#include <maxscale/log_manager.h>
#include "../../../core/maxscale/config_runtime.h"
#include "../../../core/maxscale/modules.h"
#include "../../../core/maxscale/monitor.h"
#include "../../../core/maxscale/session.h"