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.
This commit is contained in:
Johan Wikman 2017-01-05 11:25:51 +02:00
parent 6a695c9407
commit a2a38f952a
49 changed files with 400 additions and 58 deletions

View File

@ -14,14 +14,6 @@
/**
* @file modinfo.h The module information interface
*
* @verbatim
* Revision History
*
* Date Who Description
* 02/06/14 Mark Riddoch Initial implementation
*
* @endverbatim
*/
#include <maxscale/cdefs.h>
@ -114,15 +106,53 @@ typedef struct mxs_module_param
/**
* The module information structure
*/
typedef struct
typedef struct mxs_module
{
MXS_MODULE_API modapi; /**< Module API type */
MXS_MODULE_STATUS status; /**< Module development status */
MXS_MODULE_VERSION api_version; /**< Module API version */
const char *description; /**< Module description */
const char *version; /**< Module version */
void *module_object; /**< Module type specific API implementation */
MXS_MODULE_PARAM parameters[]; /**< Declared parameters */
const char *description; /**< Module description */
const char *version; /**< Module version */
void *module_object; /**< Module type specific API implementation */
/**
* If non-NULL, this function is called once at process startup. If the
* function fails, MariaDB MaxScale will not start.
*
* @return 0 on success, non-zero on failure.
*/
int (*init)();
/**
* If non-NULL, this function is called once at process shutdown, provided
* the call to @c init succeeded.
*/
void (*finish)();
/**
* If non-NULL, this function is called once at the startup of every new thread.
* If the function fails, then the thread will terminate.
*
* @attention This function is *not* called for the thread where @c init is called.
*
* @return 0 on success, non-zero on failure.
*/
int (*thread_init)();
/**
* If non-NULL, this function is called when a thread terminates, provided the
* call to @c thread_init succeeded.
*
* @attention This function is *not* called for the thread where @c init is called.
*/
void (*thread_finish)();
#ifdef __cplusplus
// TODO: C++ does not have flexible arrays, so for the time being C++ modules
// TODO: are restricted to 10 parameters.
MXS_MODULE_PARAM parameters[11]; /**< Declared parameters */
#else
MXS_MODULE_PARAM parameters[]; /**< Declared parameters */
#endif
} MXS_MODULE;
/**

View File

@ -11,6 +11,7 @@
* Public License.
*/
#define MXS_MODULE_NAME "qc_sqlite"
#include <maxscale/modules.h>
#include <maxscale/query_classifier.h>
@ -127,7 +128,14 @@ extern "C"
QUERY_CLASSIFIER_VERSION,
"Dummy Query Classifier",
"V1.0.0",
&qc
&qc,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -2587,7 +2587,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
QUERY_CLASSIFIER_VERSION,
"Query classifier based upon MySQL Embedded",
"V1.0.0",
&qc
&qc,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -3202,7 +3202,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
QUERY_CLASSIFIER_VERSION,
"Query classifier using sqlite.",
"V1.0.0",
&qc
&qc,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -173,7 +173,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The CDC client to MaxScale authenticator implementation",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -619,7 +619,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"GSSAPI authenticator",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -284,7 +284,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"GSSAPI backend authenticator",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -74,7 +74,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The MaxScale HTTP BA authenticator",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -68,7 +68,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The MaxScale Admin client authenticator implementation",
"V2.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -92,7 +92,12 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The MySQL client to MaxScale authenticator implementation",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{ { MXS_END_MODULE_PARAMS} }
};
return &info;

View File

@ -177,7 +177,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The MySQL MaxScale to backend server authenticator",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -70,7 +70,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The Null client authenticator implementation",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -67,7 +67,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
GWAUTHENTICATOR_VERSION,
"The Null client authenticator implementation",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -200,10 +200,10 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{ MODULECMD_ARG_OUTPUT, "The output dcb" },
{ MODULECMD_ARG_FILTER, "Cache name" }
};
modulecmd_register_command("cache", "show", cache_command_show,
MXS_ARRAY_NELEMS(show_argv), show_argv);
MXS_NOTICE("Initialized cache module %s.\n", VERSION_STRING);
static MXS_MODULE info =
@ -213,7 +213,14 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A caching filter that is capable of caching and returning cached data.",
VERSION_STRING,
&CacheFilter::s_object
&CacheFilter::s_object,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -123,7 +123,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A routing hint filter that send queries to the master after data modification",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -817,7 +817,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"Firewall Filter",
"V1.2.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -64,7 +64,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A hint parsing filter",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -96,7 +96,15 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"Lua Filter",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Parameters */
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -29,7 +29,14 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A masking filter that is capable of masking/obfuscating returned column values.",
"V1.0.0",
&MaskingFilter::s_object
&MaskingFilter::s_object,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -88,7 +88,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A filter that is capable of limiting the resultset number of rows.",
"V1.0.0",
&object
&object,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -269,7 +269,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A RabbitMQ query logging filter",
"V1.0.2",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -104,7 +104,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A routing hint filter that uses regular expressions to direct queries",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -163,7 +163,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A simple query logging filter",
"V1.1.1",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -114,7 +114,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A query rewrite filter that uses regular expressions to rewrite queries",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -318,7 +318,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A tee piece in the filter plumbing",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -93,7 +93,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A simple query counting filter",
"V2.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -147,7 +147,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"A top N query logging filter",
"V1.0.1",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -166,7 +166,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
FILTER_VERSION,
"Transaction Performance Monitoring filter",
"V1.0.1",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -360,7 +360,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MONITOR_VERSION,
"Aurora monitor",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -78,6 +78,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
"A Galera cluster monitor",
"V2.0.0",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{"disable_master_failback", MXS_MODULE_PARAM_BOOL, "false"},
{"available_when_donor", MXS_MODULE_PARAM_BOOL, "false"},

View File

@ -79,6 +79,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
"A Multi-Master Multi Master monitor",
"V1.1.1",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{"detect_stale_master", MXS_MODULE_PARAM_BOOL, "false"},
{MXS_END_MODULE_PARAMS}

View File

@ -113,6 +113,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
"A MySQL Master/Slave replication monitor",
"V1.5.0",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{"detect_replication_lag", MXS_MODULE_PARAM_BOOL, "false"},
{"detect_stale_master", MXS_MODULE_PARAM_BOOL, "true"},

View File

@ -72,6 +72,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
"A MySQL cluster SQL node monitor",
"V2.1.0",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS} // No parameters
}

View File

@ -92,7 +92,15 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_MODULE_IN_DEVELOPMENT,
MXS_PROTOCOL_VERSION,
"A Change Data Capture Listener implementation for use in binlog events retrieval",
"V1.0.0"
"V1.0.0",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -89,7 +89,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"An experimental HTTPD implementation for use in administration",
"V1.2.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -111,7 +111,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"The MySQL to backend server protocol",
"V2.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -119,7 +119,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"The client to MaxScale MySQL protocol implementation",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -192,7 +192,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"A maxscale protocol for the administration interface",
"V2.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -109,7 +109,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"A telnet deamon protocol for simple administration interface",
"V1.1.1",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;
}

View File

@ -78,7 +78,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
MXS_PROTOCOL_VERSION,
"Test protocol",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -161,6 +161,10 @@ MXS_MODULE* MXS_CREATE_MODULE()
"Binlogrouter",
"V1.0.0",
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{
"binlogdir",

View File

@ -161,7 +161,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"Binlogrouter",
"V2.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -89,7 +89,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"The admin user interface",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -88,7 +88,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"The debug user interface",
"V1.1.1",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -112,7 +112,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"The MaxScale Information Schema",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -145,7 +145,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"A connection based router to load balance based on connections",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -134,7 +134,14 @@ MXS_MODULE *MXS_CREATE_MODULE()
MXS_MODULE_API_ROUTER, MXS_MODULE_GA, ROUTER_VERSION,
"A Read/Write splitting router for enhancement read scalability",
"V1.1.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
MXS_NOTICE("Initializing statement-based read/write split router module.");

View File

@ -618,7 +618,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"A database sharding router for simple sharding",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;

View File

@ -69,7 +69,14 @@ MXS_MODULE* MXS_CREATE_MODULE()
ROUTER_VERSION,
"A test router - not for use in real systems",
"V1.0.0",
&MyObject
&MyObject,
NULL, /* Process init. */
NULL, /* Process finish. */
NULL, /* Thread init. */
NULL, /* Thread finish. */
{
{MXS_END_MODULE_PARAMS}
}
};
return &info;