Move thread initialization into Worker::run

By moving the initialization into Worker::run, all threads, including the
main thread, are properly initialized. This was not noticed before as
qc_sqlite initialized the main thread in the process initialization
callback.
This commit is contained in:
Markus Mäkelä
2017-09-15 17:24:59 +03:00
parent 93dafc9031
commit d00c5b2838
4 changed files with 28 additions and 32 deletions

View File

@ -92,6 +92,9 @@ int dbfw_yyparse(void*);
#endif
MXS_END_DECLS
namespace
{
/** The rules and users for each thread */
struct DbfwThread
{
@ -107,6 +110,8 @@ struct DbfwThread
thread_local DbfwThread* this_thread = NULL;
}
bool parse_at_times(const char** tok, char** saveptr, Rule* ruledef);
bool parse_limit_queries(Dbfw* instance, Rule* ruledef, const char* rule, char** saveptr);
static void rule_free_all(Rule* rule);
@ -450,6 +455,7 @@ bool dbfw_show_rules_json(const MODULECMD_ARG *argv, json_t** output)
static int dbfw_thr_init()
{
ss_dassert(this_thread == NULL);
int rval = 0;
if ((this_thread = new (std::nothrow) DbfwThread) == NULL)