Combine ModuleInit and GetModuleObject

The two functions can be combined into one as both are called only
once. This removes the need for the explicit ModuleInit function.
This commit is contained in:
Markus Mäkelä 2017-01-03 12:13:47 +02:00
parent 7df29aa1ec
commit 6c53999c97
45 changed files with 42 additions and 439 deletions

View File

@ -98,10 +98,6 @@ void qc_thread_end(void)
extern "C"
{
void ModuleInit()
{
}
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/

View File

@ -2591,10 +2591,6 @@ MODULE_INFO info =
"V1.0.0"
};
void ModuleInit()
{
}
QUERY_CLASSIFIER* GetModuleObject()
{
return &qc;

View File

@ -3203,10 +3203,6 @@ MODULE_INFO info =
"V1.0.0"
};
void ModuleInit()
{
}
QUERY_CLASSIFIER* GetModuleObject()
{
return &qc;

View File

@ -142,18 +142,8 @@ void *load_module(const char *module, const char *type)
return NULL;
}
void *sym;
/*
* If the module has a ModuleInit function cal it now.
*/
if ((sym = dlsym(dlhandle, "ModuleInit")) != NULL)
{
void (*ModuleInit)() = sym;
ModuleInit();
}
MODULE_INFO *mod_info = NULL;
void *sym;
if ((sym = dlsym(dlhandle, "info")) != NULL)
{

View File

@ -159,22 +159,6 @@ static bool cdc_add_new_user(const MODULECMD_ARG *args)
return rval;
}
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
modulecmd_arg_type_t args[] =
{
{ MODULECMD_ARG_SERVICE, "Service where the user is added"},
{ MODULECMD_ARG_STRING, "User to add"},
{ MODULECMD_ARG_STRING, "Password of the user"}
};
modulecmd_register_command("cdc", "add_user", cdc_add_new_user, 3, args);
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -185,6 +169,14 @@ void ModuleInit()
*/
GWAUTHENTICATOR* GetModuleObject()
{
modulecmd_arg_type_t args[] =
{
{ MODULECMD_ARG_SERVICE, "Service where the user is added"},
{ MODULECMD_ARG_STRING, "User to add"},
{ MODULECMD_ARG_STRING, "Password of the user"}
};
modulecmd_register_command("cdc", "add_user", cdc_add_new_user, 3, args);
return &MyObject;
}

View File

@ -620,13 +620,6 @@ MODULE_INFO info =
"V1.0.0"
};
/**
* Module initialization entry point
*/
void ModuleInit()
{
}
/**
* Module handle entry point
*/

View File

@ -284,13 +284,6 @@ MODULE_INFO info =
"V1.0.0"
};
/**
* Module initialization entry point
*/
void ModuleInit()
{
}
/**
* Module handle entry point
*/

View File

@ -74,14 +74,6 @@ typedef struct http_auth
char* pw;
}HTTP_AUTH;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -68,14 +68,6 @@ static GWAUTHENTICATOR MyObject =
users_default_loadusers /* Load generic users */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -93,14 +93,6 @@ static int mysql_auth_set_client_data(
MySQLProtocol *protocol,
GWBUF *buffer);
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -177,14 +177,6 @@ static GWAUTHENTICATOR MyObject =
NULL /* We don't need to load users */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -70,14 +70,6 @@ static GWAUTHENTICATOR MyObject =
users_default_loadusers /* Load generic users */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -67,14 +67,6 @@ static GWAUTHENTICATOR MyObject =
users_default_loadusers /* Load generic users */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -202,22 +202,18 @@ MODULE_INFO info =
VERSION_STRING
};
extern "C" void ModuleInit()
extern "C" FILTER_OBJECT *GetModuleObject()
{
static modulecmd_arg_type_t show_argv[] =
{
{ 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);
}
extern "C" FILTER_OBJECT *GetModuleObject()
{
return &CacheFilter::s_object;
};

View File

@ -116,18 +116,6 @@ typedef struct
time_t last_modification; /*< Time of the last data modifying operation */
} CCR_SESSION;
/**
* The module initialization routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -794,12 +794,14 @@ bool dbfw_show_rules(const MODULECMD_ARG *argv)
}
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
/*lint -e14 */
void ModuleInit()
FILTER_OBJECT * GetModuleObject()
{
modulecmd_arg_type_t args_rules_reload[] =
{
@ -816,20 +818,6 @@ void ModuleInit()
};
modulecmd_register_command("dbfwfilter", "rules", dbfw_show_rules, 2, args_rules_show);
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
* "module object", this is a structure with the set of
* external entry points for this module.
*
* @return The module object
*/
FILTER_OBJECT * GetModuleObject()
{
return &MyObject;
}

View File

@ -57,19 +57,6 @@ static FILTER_OBJECT MyObject =
NULL, // No destroyInstance
};
/**
* The module initialization routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -180,18 +180,6 @@ typedef struct
UPSTREAM up;
} LUA_SESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* Create a new instance of the Lua filter.
*

View File

@ -27,13 +27,9 @@ MODULE_INFO info =
"V1.0.0"
};
extern "C" void ModuleInit()
{
MXS_NOTICE("Initialized masking module.");
}
extern "C" FILTER_OBJECT *GetModuleObject()
{
MXS_NOTICE("Initialized masking module.");
return &MaskingFilter::s_object;
}

View File

@ -68,14 +68,6 @@ MODULE_INFO info =
"V1.0.0"
};
/**
* The module initialization functions, called when the module has
* been loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point function, called when the module is loaded.
*

View File

@ -262,18 +262,6 @@ typedef struct
void sendMessage(void* data);
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -97,18 +97,6 @@ typedef struct
int active; /* Is filter active */
} REGEXHINT_SESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -156,18 +156,6 @@ static FILE* open_log_file(uint32_t, QLA_INSTANCE *, const char *);
static int write_log_entry(uint32_t, FILE*, QLA_INSTANCE*, QLA_SESSION*, const char*,
const char*, size_t);
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -106,18 +106,6 @@ typedef struct
void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* new);
void log_nomatch(REGEX_INSTANCE* inst, char* re, char* old);
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -305,22 +305,6 @@ orphan_free(void* data)
#endif
}
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
spinlock_init(&orphanLock);
#ifdef SS_DEBUG
spinlock_init(&debug_lock);
#endif
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -332,6 +316,10 @@ ModuleInit()
FILTER_OBJECT *
GetModuleObject()
{
spinlock_init(&orphanLock);
#ifdef SS_DEBUG
spinlock_init(&debug_lock);
#endif
return &MyObject;
}

View File

@ -82,18 +82,6 @@ typedef struct
int count;
} TEST_SESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -140,18 +140,6 @@ typedef struct
struct timeval disconnect;
} TOPN_SESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
* @see function load_module in load_utils.c for explanation of lint
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -158,15 +158,6 @@ typedef struct
size_t max_sql_size;
} TPM_SESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -41,16 +41,6 @@ typedef struct aurora_monitor
bool events[MAX_MONITOR_EVENT]; /**< Enabled monitor events */
} AURORA_MONITOR;
/**
* The module initialisation routine, called when the module is first loaded.
*/
/*lint -e14 */
void
ModuleInit()
{
}
/*lint +e14 */
/**
* @brief Update the status of a server
*

View File

@ -59,16 +59,6 @@ static MONITOR_OBJECT MyObject =
diagnostics
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise the Multi-Master Monitor module.");
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -80,6 +70,7 @@ ModuleInit()
MONITOR_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise the Multi-Master Monitor module.");
return &MyObject;
}
/*lint +e14 */

View File

@ -107,16 +107,6 @@ static MONITOR_OBJECT MyObject =
diagnostics
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise the MySQL Monitor module.");
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -128,6 +118,7 @@ ModuleInit()
MONITOR_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise the MySQL Monitor module.");
return &MyObject;
}

View File

@ -57,16 +57,6 @@ static MONITOR_OBJECT MyObject =
diagnostics
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -78,6 +68,7 @@ ModuleInit()
MONITOR_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise the MySQL Cluster Monitor module.");
return &MyObject;
}
/*lint +e14 */

View File

@ -88,15 +88,6 @@ static GWPROTOCOL MyObject =
cdc_default_auth /* default authentication */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -89,14 +89,6 @@ static GWPROTOCOL MyObject =
NULL /**< Connection limit reached */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -112,14 +112,6 @@ static GWPROTOCOL MyObject =
NULL /* Connection limit reached */
};
/*
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/*
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -114,14 +114,6 @@ static GWPROTOCOL MyObject =
gw_connection_limit /* Send error connection limit */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -191,15 +191,6 @@ static GWPROTOCOL MyObject =
NULL /**< Connection limit reached */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
MXS_INFO("Initialise MaxScaled Protocol module.");;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -210,6 +201,7 @@ void ModuleInit()
*/
GWPROTOCOL* GetModuleObject()
{
MXS_INFO("Initialise MaxScaled Protocol module.");
return &MyObject;
}
/*lint +e14 */

View File

@ -102,15 +102,6 @@ static GWPROTOCOL MyObject =
static void telnetd_command(DCB *, unsigned char *cmd);
static void telnetd_echo(DCB *dcb, int enable);
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
MXS_INFO("Initialise Telnetd Protocol module.");
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -121,6 +112,7 @@ void ModuleInit()
*/
GWPROTOCOL* GetModuleObject()
{
MXS_INFO("Initialise Telnetd Protocol module.");
return &MyObject;
}
/*lint +e14 */

View File

@ -77,14 +77,6 @@ static GWPROTOCOL MyObject =
test_connection_limit /**< Connection limit */
};
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the

View File

@ -78,18 +78,6 @@ extern int execute_cmd(CLI_SESSION *cli);
static SPINLOCK instlock;
static CLI_INSTANCE *instances;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise debug CLI router module.");
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -101,6 +89,9 @@ ModuleInit()
ROUTER_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise debug CLI router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
}

View File

@ -102,18 +102,6 @@ static ROUTER_OBJECT MyObject =
static SPINLOCK instlock;
static INFO_INSTANCE *instances;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise MaxInfo router module.");
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -125,6 +113,9 @@ ModuleInit()
ROUTER_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise MaxInfo router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
}

View File

@ -137,18 +137,6 @@ static int handle_state_switch(DCB* dcb, DCB_REASON reason, void * routersession
static SPINLOCK instlock;
static ROUTER_INSTANCE *instances;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise readconnroute router module.");
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -160,6 +148,9 @@ ModuleInit()
ROUTER_OBJECT *
GetModuleObject()
{
MXS_NOTICE("Initialise readconnroute router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
}

View File

@ -126,15 +126,6 @@ static bool have_enough_servers(ROUTER_CLIENT_SES *rses, const int min_nsrv,
int router_nsrv, ROUTER_INSTANCE *router);
static bool create_backends(ROUTER_CLIENT_SES *rses, backend_ref_t** dest, int* n_backend);
/**
* The module initialization routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
MXS_NOTICE("Initializing statement-based read/write split router module.");
}
/**
* The module entry point routine. It is this routine that
* must return the structure that is referred to as the
@ -145,6 +136,7 @@ void ModuleInit()
*/
ROUTER_OBJECT *GetModuleObject()
{
MXS_NOTICE("Initializing statement-based read/write split router module.");
return &MyObject;
}

View File

@ -607,17 +607,6 @@ bool check_shard_status(ROUTER_INSTANCE* router, char* shard)
return false;
}
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void ModuleInit()
{
MXS_NOTICE("Initializing Schema Sharding Router.");
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -628,6 +617,9 @@ void ModuleInit()
*/
ROUTER_OBJECT* GetModuleObject()
{
MXS_NOTICE("Initializing Schema Sharding Router.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
}

View File

@ -61,16 +61,6 @@ typedef struct
{
} TESTSESSION;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the