MXS-2067: Replace most SPINLOCKs

Replaced SPINLOCK with std::mutex where possible, leaving out the more
complex cases. The big offenders remaining are the binlogrouter and the
gateway.cc OpenSSL locks.
This commit is contained in:
Markus Mäkelä
2018-09-26 09:35:33 +03:00
parent 50451166bb
commit ab4f870927
17 changed files with 76 additions and 215 deletions

View File

@ -19,6 +19,7 @@
#include <strings.h>
#include <iterator>
#include <mutex>
#include <maxscale/alloc.h>
#include <maxscale/buffer.h>
@ -30,7 +31,6 @@
#include <maxscale/mysql_utils.h>
/** These are used when converting MySQL wildcards to regular expressions */
static SPINLOCK re_lock = SPINLOCK_INIT;
static bool pattern_init = false;
static pcre2_code* re_percent = NULL;
static pcre2_code* re_single = NULL;
@ -1113,7 +1113,9 @@ int modutil_count_packets(GWBUF* buffer)
*/
void prepare_pcre2_patterns()
{
spinlock_acquire(&re_lock);
static std::mutex re_lock;
std::lock_guard<std::mutex> guard(re_lock);
if (!pattern_init)
{
int err;
@ -1158,7 +1160,6 @@ void prepare_pcre2_patterns()
re_escape = NULL;
}
}
spinlock_release(&re_lock);
}
/**