MXS-1354: Add missing locking to the Users class

The Users class now performs locking when a method is called. This will
prevent concurrent access to the internal map of users.

Added missing const versions of SpinLockGuard.
This commit is contained in:
Markus Mäkelä
2017-08-15 10:18:40 +03:00
parent a48758a9d8
commit 4a179d973b
2 changed files with 17 additions and 7 deletions

View File

@ -46,7 +46,7 @@ public:
/**
* Acquires the spinlock.
*/
void acquire()
void acquire() const
{
spinlock_acquire(&m_lock);
}
@ -54,7 +54,7 @@ public:
/**
* Releases the spinlock.
*/
void release()
void release() const
{
spinlock_release(&m_lock);
}
@ -64,7 +64,7 @@ private:
SpinLock& operator = (const SpinLock&) /* = delete */;
private:
SPINLOCK m_lock;
mutable SPINLOCK m_lock;
};
/**
@ -85,7 +85,7 @@ public:
*
* @param lock The spinlock to lock.
*/
SpinLockGuard(SPINLOCK& lock)
SpinLockGuard(const SPINLOCK& lock)
: m_lock(lock)
{
spinlock_acquire(&m_lock);
@ -96,7 +96,7 @@ public:
*
* @param lock The spinlock to lock.
*/
SpinLockGuard(SpinLock& lock)
SpinLockGuard(const SpinLock& lock)
: m_lock(lock.m_lock)
{
spinlock_acquire(&m_lock);
@ -115,7 +115,7 @@ private:
SpinLockGuard(const SpinLockGuard&) /* = delete */;
SpinLockGuard& operator = (const SpinLockGuard&) /* = delete */;
SPINLOCK& m_lock;
const SPINLOCK& m_lock;
};
}