1511 Commits

Author SHA1 Message Date
Markus Mäkelä
60d4e17996 Allow restriction of module command arguments
The module commands now support an optional flag for arguments that when
enabled checks that the argument module name matches the registered domain
name. This can be used to enforce argument type validity for arguments
that are given to modules that expect objects of a certain type.

For example, this is used by the cache and dbfwfilter to prevent valid
filters but of the wrong type being given as arguments.
2017-01-13 15:28:36 +02:00
Johan Wikman
265e5c0593 Rename FILTER_DEF to MXS_FILTER_DEF
Provide functions that allows the actual definition of MXS_FILTER_DEF
to be made private.
2017-01-13 14:30:11 +02:00
Johan Wikman
a41188bd5e Rename FILTER_VERSION to MXS_FILTER_VERSION 2017-01-13 14:26:45 +02:00
Johan Wikman
424849a9a2 Rename UPSTREAM to MXS_UPSTREAM
And DOWNSTREAM to MXS_DOWNSTREAM
2017-01-13 13:40:03 +02:00
Johan Wikman
356690c0e5 Filter.h split into public and private parts
- include/maxscale/filter.h
- server/core/maxscale/filter.h
2017-01-13 12:57:40 +02:00
Johan Wikman
ce182e3788 Introduce opaque type for filter session data 2017-01-13 11:03:43 +02:00
Johan Wikman
d0cc246b79 Rename FILTER to MXS_FILTER 2017-01-13 10:21:51 +02:00
Johan Wikman
e7b951c434 Rename FILTER_OBJECT to MXS_FILTER_OBJECT
Other clarifications to follow.
2017-01-13 10:03:23 +02:00
Johan Wikman
6248d2bb9f Change int to int32_t in plugin interfaces
Better to use types whose size is unquestionably unambiguous
in plugin interfaces.

As on current platforms sizeof(int32_t) == sizeof(int) plugins
need not immediately be changed to return int32_t:s instead of
int:s.
2017-01-13 09:55:40 +02:00
Markus Mäkelä
9168974882 Remove extra space after enum names
The monitor event enum values had an extra space which caused them to be
falsely classified as invalid parameters.
2017-01-12 15:33:48 +02:00
Johan Wikman
2fa12f796b Rename MYSQL_GET_PACKET_LEN to MYSQL_GET_PAYLOAD_LEN
The function returns the length of the payload, not the length of
the entire packet.
2017-01-12 14:24:14 +02:00
Markus Mäkelä
0865eada03 Add module configuration directory
This directory is intended to be the default working directory for
relative pathname resolution. The actual implementation for
MXS_MODULE_PARAM_PATH is done at a later step.
2017-01-11 14:24:26 +02:00
Markus Mäkelä
a196420c2d Move monitor script processing and launching into the core
This removes parts of the nearly identical code from all monitors.

The removal of monitor type specific event checking is done based on the
assumption that only the monitor that is monitoring the server can be the
cause for a state change. This removes the need to actually check that the
state change is relevant for each monitor and allows the event handling to
be moved into the core.
2017-01-11 14:21:57 +02:00
Markus Mäkelä
a1293fbd79 Add unique constraint to enumeration parameters
Enum parameters can now be declared unique. This prevents multiple values
for enumerations which only accept one value.
2017-01-10 16:52:29 +02:00
Markus Mäkelä
b352458870 Add size type to module parameters
The type represents byte sizes used for configuring buffers and file
sizes. The supported suffixes for binary units are k, m, g and t in both
upper and lower case.
2017-01-10 16:52:29 +02:00
Markus Mäkelä
b507976414 Use a constant instead of a hard-coded parameter limit
Limits are better defined with constants that can be reused elsewhere.
2017-01-09 14:17:34 +02:00
Markus Mäkelä
c500ddc768 Use module parameters in namedserverfilter
The namedserverfilter module now uses the module parameters.

Added new server type parameter which is validated both at startup and
runtime.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
9b2d382232 Use module parameters in mqfilter
Cleaned up mqfilter createInstance and converted it to use module
parameters.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
f156b1e4ee Add minimum and maximum values for integer parameters
The defined integer values can be used to give a default value the maximum
for its type.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
56ecdc219b Refactor config.c functions for testing
To test the configuration validation and default value generation, the
functions needed to be refactored to allow parameters to be passed
directly to the function.
2017-01-09 14:17:33 +02:00
Markus Mäkelä
eef0619865 Add default parameters to created monitors
When a monitor is created at runtime, it also needs to have the default
parameters. Ideally, this would be done when the monitor is allocated but
because of the way the configuration is processed, we need to do it after
user defined parameters are added.
2017-01-09 14:17:33 +02:00
Johan Wikman
75c257327e Fix G++ 4.4 issue
G++ 4.4 on CentOS6 seems to get confused by direct inheritance
from templates. Worked around by introducing typedef.
2017-01-09 13:17:49 +02:00
MassimilianoPinto
7c13b56e74 Fix compilation error on CentOS6
Fix compilation error on CentOS6
2017-01-09 12:07:18 +01:00
Johan Wikman
c3ddc3ac22 Cleanup server.h
- All (but the printing/debug functions) are now in snake_case.
- Functions made const correct.
- All function prototypes now have named arguments.

Documentation still to be moved, and file possibly split into
include/mascale/server.h and server/core/maxscale/server.h
2017-01-09 12:14:46 +02:00
Johan Wikman
171eb3f690 Provide backdoor to Buffer::iterator 2017-01-09 09:19:59 +02:00
Johan Wikman
0b4c379539 Add Closer, partial RAII class
Closer is a template using which C-style resources can be managed
in a C++ context where exceptions can occur. By placing a C resource
in a Closer instance, it is certain the resource will be freed when
the closing scope is exited irrespective of whether that occurs due
to the normal control flow, due to a return statement or an exception
having been thrown.

To be used with Closer, the CloserTraits template must be specialized
for the type in question. With this change specializations are provided
for FILE*, json_t*, pcre_code* and pcre2_match_data*.
2017-01-09 09:19:59 +02:00
Johan Wikman
d078f56dc5 qc: Reveal function usage
MXS-1070

Just interface changes. Implementation follow in separate changes.
2017-01-09 09:17:38 +02:00
Johan Wikman
8fc5bdc2f1 Perform query classifier initialization implicitly
The setting up and the initialization of the query classifier has
now been separated. The gateway explicitly sets up the query
classifier (i.e. chooses which one to use and what arguments to
provide), but the actual initialization is performed as part of
the general module initialization.
2017-01-09 09:16:35 +02:00
Johan Wikman
530c0e9617 QC: Setup and initialization separated
This is in preparation for using the general process/thread
initialization mechanism.
2017-01-09 09:16:35 +02:00
Markus Mäkelä
6a64de649b Increate parameter limit to 64
Modules can now declare up to 64 parameters.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
2611f9a701 Give parameters as CONFIG_PARAMETER for FILTER::createInstance
The filters should use the same configuration parameters as other modules
use. This allows them to use the common configuration management functions
to get values from it.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
f1fa982dc6 Remove qualified configuration parameters
The parameters were only used by readwritesplit. These can be substituted
with the new module parameters.
2017-01-05 19:51:22 +02:00
Markus Mäkelä
9fa2de29d9 Return enum values as integers instead of strings
If the enums are converted to the acutual enum values before they are
returned, this removes the need for the modules to process the enum
strings to enum values. This allows modules to use enumerations with
minimal effort.
2017-01-05 19:51:22 +02:00
Johan Wikman
03391748ee Call [process|thread] [init|finish] functions of modules
The process initialization function was also renamed from init to
process_init.
2017-01-05 16:17:50 +02:00
Johan Wikman
a2a38f952a Add [process|thread] [init|finish] functions to modules
The MXS_MODULDE object now contains optinal pointers for functions
to be called att process and thread startup and shutdown. Since the
functions were added to the end, strictly speaking, all structures
would not have needed to have been modified, but better to be
explicit. In a subsequent change, these will be called.

C++ does not support flexible arrays, so for the time being C++
modules are restricted to 10 parameters. Better approach is to
factor out the parameters to a separate array and then just store
a pointer to that array in MXS_MODULE.
2017-01-05 14:44:02 +02:00
Johan Wikman
6a695c9407 Provide access to modules
With the provided functions it is possible to iterate over all loaded
modules or over all modules of a specific type.
2017-01-05 14:37:01 +02:00
Johan Wikman
2abe956056 Rename GWPROTOCOL to MXS_PROTOCOL 2017-01-05 14:36:44 +02:00
Johan Wikman
19ce28a43a Rename gw_protocol.h to protocol.h 2017-01-05 14:36:44 +02:00
Markus Mäkelä
257cb5c209 Add path and service module parameter types
The path type is validated if the module requested path
validation. Service checks can be done both on startup and at
runtime. This allows dynamic changes to module parameters to be validated
without a configuration context.
2017-01-05 10:48:58 +02:00
Markus Mäkelä
e0ad6188ad Add module parameter options
The options allow the modules to impose type specific restrictions on the
parameters. This can be used to offload file permission and mandatory
parameter checks to the core.
2017-01-05 10:48:58 +02:00
Markus Mäkelä
2b50ce6548 Create defines for default directories
This allows the default directories to be used in initializers where
constant expressions are required.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
4c008844ca Always include maxscale/cdefs.h first
Two headers didn't include the file.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
2e074f4eb4 Introduce common SQLite header
The header declares the missing v2 handle closing function for older
versions of SQLite.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
cefc253e2c Check configuration with declared parameters
The declared parameters are now used to check whether the configuration is
valid. As the filters and monitors don't use the new declarations, the
code needs to be commented out. Once the parameter processing has been
migrated to the new system, the code can be enabled.
2017-01-05 09:58:10 +02:00
Markus Mäkelä
241dbb464a Add framework for declaration of module parameters
The MXS_MODULE structure now contains a member for parameters. This can be
used by the modules to declare accepted parameters, their types and the
default values. Currently only count, integer, boolean, string and enum
values are supported.
2017-01-05 09:58:10 +02:00
Johan Wikman
801c6cfbef Define _GNU_SOURCE in include/maxscale/cdefs.h 2017-01-04 09:55:52 +02:00
Markus Mäkelä
33d98830dd Provide read-only access to loaded modules
The MXS_MODULE structure of each module is now globally exposed by the
`get_module` function. This allows the module information of any module to
be queried.

This information can then be used to validate various things but the main
goal is to provide a way for modules to declare accepted parameters in the
MXS_MODULE structure. This will be done in a later commit.

Also the function documentation is now in the header file. This should
make it easier to read.
2017-01-04 07:39:47 +02:00
Markus Mäkelä
0215ad32a1 Fix double declaration of _XOPEN_SOURCE
The adminusers.c file declared it twice; first explicitly and then
implicitly by including cdefs.h.
2017-01-04 05:55:55 +02:00
Markus Mäkelä
f78db1aab9 Fix modinfo.h comments
The comments referred to a non-existent type.
2017-01-03 20:19:22 +02:00
Markus Mäkelä
66430a3584 Fix persisted monitors not working
This prevented persisted monitors from being deleted after a restart.
2017-01-03 20:18:15 +02:00