Updated code based on review of 9a04984

This commit is contained in:
Markus Makela
2015-10-30 17:23:31 +02:00
parent cd55f62051
commit 3187f2c3f8
2 changed files with 4 additions and 7 deletions

View File

@ -859,7 +859,7 @@ int modutil_count_statements(GWBUF* buffer)
/** /**
* Initialize the PCRE2 patterns used when converting MySQL wildcards to PCRE syntax. * Initialize the PCRE2 patterns used when converting MySQL wildcards to PCRE syntax.
*/ */
void init_pcre2_patterns() void prepare_pcre2_patterns()
{ {
spinlock_acquire(&re_lock); spinlock_acquire(&re_lock);
if (!pattern_init) if (!pattern_init)
@ -875,6 +875,7 @@ void init_pcre2_patterns()
(re_escape = pcre2_compile(pattern_escape, PCRE2_ZERO_TERMINATED, (re_escape = pcre2_compile(pattern_escape, PCRE2_ZERO_TERMINATED,
0, &err, &erroff, NULL))) 0, &err, &erroff, NULL)))
{ {
assert(!pattern_init);
pattern_init = true; pattern_init = true;
} }
else else
@ -910,10 +911,7 @@ void init_pcre2_patterns()
*/ */
mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char* string) mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char* string)
{ {
if (!pattern_init) prepare_pcre2_patterns();
{
init_pcre2_patterns();
}
mxs_pcre2_result_t rval = MXS_PCRE2_ERROR; mxs_pcre2_result_t rval = MXS_PCRE2_ERROR;
bool err = false; bool err = false;
PCRE2_SIZE matchsize = strlen(string) + 1; PCRE2_SIZE matchsize = strlen(string) + 1;
@ -943,7 +941,7 @@ mxs_pcre2_result_t modutil_mysql_wildcard_match(const char* pattern, const char*
rval = mxs_pcre2_simple_match(matchstr, string, PCRE2_CASELESS, &errcode); rval = mxs_pcre2_simple_match(matchstr, string, PCRE2_CASELESS, &errcode);
if (rval == MXS_PCRE2_ERROR) if (rval == MXS_PCRE2_ERROR)
{ {
if(errcode != 0) if (errcode != 0)
{ {
PCRE2_UCHAR errbuf[STRERROR_BUFLEN]; PCRE2_UCHAR errbuf[STRERROR_BUFLEN];
pcre2_get_error_message(errcode, errbuf, sizeof(errbuf)); pcre2_get_error_message(errcode, errbuf, sizeof(errbuf));

View File

@ -52,7 +52,6 @@
*/ */
#include <mysqlmon.h> #include <mysqlmon.h>
#include <pcre2.h>
#include <modutil.h> #include <modutil.h>
/** Defined in log_manager.cc */ /** Defined in log_manager.cc */