diff --git a/server/modules/filter/cache/cache.h b/server/modules/filter/cache/cache.h index 3902cffc5..db3b91dcb 100644 --- a/server/modules/filter/cache/cache.h +++ b/server/modules/filter/cache/cache.h @@ -18,10 +18,12 @@ #include #include #include +#include #include "cachefilter.h" #include "cache_storage_api.h" class CacheFilterSession; +class StorageFactory; class Cache { diff --git a/server/modules/filter/cache/cache_storage_api.cc b/server/modules/filter/cache/cache_storage_api.cc index c00b83c97..e6fc4f2b0 100644 --- a/server/modules/filter/cache/cache_storage_api.cc +++ b/server/modules/filter/cache/cache_storage_api.cc @@ -11,6 +11,7 @@ * Public License. */ +#define MXS_MODULE_NAME "cache" #include "cache_storage_api.hh" #include diff --git a/server/modules/filter/cache/cachefilter.cc b/server/modules/filter/cache/cachefilter.cc index b55020f1e..49576b104 100644 --- a/server/modules/filter/cache/cachefilter.cc +++ b/server/modules/filter/cache/cachefilter.cc @@ -28,6 +28,9 @@ using std::string; static char VERSION_STRING[] = "V1.0.0"; +namespace +{ + static const CACHE_CONFIG DEFAULT_CONFIG = { CACHE_DEFAULT_MAX_RESULTSET_ROWS, @@ -44,6 +47,56 @@ static const CACHE_CONFIG DEFAULT_CONFIG = CACHE_DEFAULT_THREAD_MODEL, }; + +/** + * Frees all data of a config object, but not the object itself + * + * @param pConfig Pointer to a config object. + */ +void cache_config_finish(CACHE_CONFIG& config) +{ + MXS_FREE(config.rules); + MXS_FREE(config.storage); + MXS_FREE(config.storage_options); + MXS_FREE(config.storage_argv); // The items need not be freed, they point into storage_options. + + config.max_resultset_rows = 0; + config.max_resultset_size = 0; + config.rules = NULL; + config.storage = NULL; + config.storage_options = NULL; + config.storage_argc = 0; + config.storage_argv = NULL; + config.ttl = 0; + config.debug = 0; +} + +/** + * Frees all data of a config object, and the object itself + * + * @param pConfig Pointer to a config object. + */ +void cache_config_free(CACHE_CONFIG* pConfig) +{ + if (pConfig) + { + cache_config_finish(*pConfig); + MXS_FREE(pConfig); + } +} + +/** + * Resets the data without freeing anything. + * + * @param config Reference to a config object. + */ +void cache_config_reset(CACHE_CONFIG& config) +{ + memset(&config, 0, sizeof(config)); +} + +} + typedef struct cache_filter { cache_filter() @@ -632,50 +685,3 @@ static bool process_params(char **pzOptions, FILTER_PARAMETER **ppParams, CACHE_ return !error; } - -/** - * Frees all data of a config object, but not the object itself - * - * @param pConfig Pointer to a config object. - */ -void cache_config_finish(CACHE_CONFIG& config) -{ - MXS_FREE(config.rules); - MXS_FREE(config.storage); - MXS_FREE(config.storage_options); - MXS_FREE(config.storage_argv); // The items need not be freed, they point into storage_options. - - config.max_resultset_rows = 0; - config.max_resultset_size = 0; - config.rules = NULL; - config.storage = NULL; - config.storage_options = NULL; - config.storage_argc = 0; - config.storage_argv = NULL; - config.ttl = 0; - config.debug = 0; -} - -/** - * Frees all data of a config object, and the object itself - * - * @param pConfig Pointer to a config object. - */ -void cache_config_free(CACHE_CONFIG* pConfig) -{ - if (pConfig) - { - cache_config_finish(*pConfig); - MXS_FREE(pConfig); - } -} - -/** - * Resets the data without freeing anything. - * - * @param config Reference to a config object. - */ -void cache_config_reset(CACHE_CONFIG& config) -{ - memset(&config, 0, sizeof(config)); -} diff --git a/server/modules/filter/cache/cachefilter.h b/server/modules/filter/cache/cachefilter.h index 0bdc440fa..ce749fe9a 100644 --- a/server/modules/filter/cache/cachefilter.h +++ b/server/modules/filter/cache/cachefilter.h @@ -77,8 +77,4 @@ typedef struct cache_config cache_thread_model_t thread_model; /**< Thread model. */ } CACHE_CONFIG; -void cache_config_finish(CACHE_CONFIG& config); -void cache_config_free(CACHE_CONFIG* pConfig); -void cache_config_reset(CACHE_CONFIG& config); - #endif diff --git a/server/modules/filter/cache/rules.cc b/server/modules/filter/cache/rules.cc index 81ee0df04..1964411fd 100644 --- a/server/modules/filter/cache/rules.cc +++ b/server/modules/filter/cache/rules.cc @@ -15,6 +15,7 @@ #include "rules.h" #include #include +#include #include #include #include diff --git a/server/modules/filter/cache/storage.h b/server/modules/filter/cache/storage.h index f72e88ba1..2672407c3 100644 --- a/server/modules/filter/cache/storage.h +++ b/server/modules/filter/cache/storage.h @@ -13,6 +13,7 @@ */ #include +#include #include "cache_storage_api.h" class Storage