mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
fixed posix SS - use recursive mutex to protect security DB access
This commit is contained in:
parent
42db58c37f
commit
35520bc1f1
@ -197,19 +197,6 @@ public:
|
||||
|
||||
#endif //WIN_NT
|
||||
|
||||
// RAII holder of mutex lock
|
||||
class MutexLockGuard
|
||||
{
|
||||
public:
|
||||
explicit MutexLockGuard(Mutex &alock)
|
||||
: lock(&alock) { lock->enter(); }
|
||||
~MutexLockGuard() { lock->leave(); }
|
||||
private:
|
||||
// Forbid copy constructor
|
||||
MutexLockGuard(const MutexLockGuard& source);
|
||||
Mutex *lock;
|
||||
};
|
||||
|
||||
// Recursive mutex
|
||||
class RecursiveMutex
|
||||
{
|
||||
@ -231,6 +218,23 @@ public:
|
||||
int leave();
|
||||
};
|
||||
|
||||
// RAII holder
|
||||
template <typename M>
|
||||
class LockGuard
|
||||
{
|
||||
public:
|
||||
explicit LockGuard(M &alock)
|
||||
: lock(&alock) { lock->enter(); }
|
||||
~LockGuard() { lock->leave(); }
|
||||
private:
|
||||
// Forbid copy constructor
|
||||
LockGuard(const LockGuard& source);
|
||||
M *lock;
|
||||
};
|
||||
|
||||
typedef LockGuard<Mutex> MutexLockGuard;
|
||||
typedef LockGuard<RecursiveMutex> RecursiveMutexLockGuard;
|
||||
|
||||
} //namespace Firebird
|
||||
|
||||
#endif // CLASSES_LOCKS_H
|
||||
|
@ -90,6 +90,7 @@ private:
|
||||
static const UCHAR TPB[4];
|
||||
|
||||
Firebird::Mutex mutex;
|
||||
Firebird::RecursiveMutex counterMutex;
|
||||
|
||||
ISC_STATUS_ARRAY status;
|
||||
|
||||
|
@ -235,7 +235,7 @@ namespace {
|
||||
|
||||
void SecurityDatabase::fini()
|
||||
{
|
||||
Firebird::MutexLockGuard guard(mutex);
|
||||
Firebird::RecursiveMutexLockGuard guard(counterMutex);
|
||||
counter -= (is_cached) ? 1 : 0;
|
||||
#ifndef EMBEDDED
|
||||
if (counter == 1 && lookup_db)
|
||||
@ -247,7 +247,7 @@ void SecurityDatabase::fini()
|
||||
|
||||
void SecurityDatabase::init()
|
||||
{
|
||||
Firebird::MutexLockGuard guard(mutex);
|
||||
Firebird::RecursiveMutexLockGuard guard(counterMutex);
|
||||
counter += (is_cached) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user