mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 07:23:03 +01:00
Threading cleanup. More to follow.
This commit is contained in:
parent
a7b6fdb84d
commit
8e07223ebf
@ -26,7 +26,7 @@
|
||||
|
||||
#include "../jrd/jrd.h"
|
||||
#include "../common/classes/alloc.h"
|
||||
#include "../jrd/block_cache.h"
|
||||
//#include "../jrd/block_cache.h"
|
||||
#include "../jrd/lls.h"
|
||||
#include "../common/classes/fb_string.h"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define JRD_BLOCK_CACHE_H
|
||||
|
||||
#include "../common/classes/alloc.h"
|
||||
#include "../jrd/smp_impl.h"
|
||||
#include "../common/classes/locks.h"
|
||||
|
||||
template <class T>
|
||||
class BlockCache
|
||||
@ -17,25 +17,23 @@ public:
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
Node* next;
|
||||
Node* next;
|
||||
};
|
||||
MemoryPool& pool;
|
||||
Node* head;
|
||||
V4Mutex lock;
|
||||
MemoryPool& pool;
|
||||
Node* head;
|
||||
Firebird::Mutex lock;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline T* BlockCache<T>::newBlock()
|
||||
{
|
||||
lock.acquire();
|
||||
Firebird::MutexLockGuard guard(lock);
|
||||
if (head)
|
||||
{
|
||||
T* result = reinterpret_cast<T*>(head);
|
||||
head = head->next;
|
||||
lock.release();
|
||||
return result;
|
||||
}
|
||||
lock.release();
|
||||
return FB_NEW(pool) T;
|
||||
}
|
||||
|
||||
@ -43,10 +41,9 @@ template<class T>
|
||||
inline void BlockCache<T>::returnBlock(T* back)
|
||||
{
|
||||
Node* returned = reinterpret_cast<Node*>(back);
|
||||
lock.acquire();
|
||||
Firebird::MutexLockGuard guard(lock);
|
||||
returned->next = head;
|
||||
head = returned;
|
||||
lock.release();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -66,4 +63,3 @@ BlockCache<T>::~BlockCache()
|
||||
}
|
||||
|
||||
#endif // JRD_BLOCK_CACHE_H
|
||||
|
||||
|
@ -236,7 +236,6 @@ static void init(void)
|
||||
**************************************/
|
||||
|
||||
if (!initialized) {
|
||||
THD_INIT;
|
||||
THD_GLOBAL_MUTEX_LOCK;
|
||||
if (!initialized) {
|
||||
gds__register_cleanup(cleanup, 0);
|
||||
|
@ -158,7 +158,6 @@ const SSHORT WAIT_PERIOD = -1;
|
||||
#endif /* SUPERSERVER */
|
||||
|
||||
# ifdef V4_THREADING
|
||||
# undef V4_INIT
|
||||
# undef V4_GLOBAL_MUTEX_LOCK
|
||||
# undef V4_GLOBAL_MUTEX_UNLOCK
|
||||
# undef V4_MUTEX_INIT
|
||||
@ -167,7 +166,6 @@ const SSHORT WAIT_PERIOD = -1;
|
||||
# undef V4_MUTEX_DESTROY
|
||||
# undef V4_JRD_MUTEX_LOCK
|
||||
# undef V4_JRD_MUTEX_UNLOCK
|
||||
# define V4_INIT THD_INIT
|
||||
# define V4_GLOBAL_MUTEX_LOCK {THREAD_EXIT(); THD_GLOBAL_MUTEX_LOCK; THREAD_ENTER();}
|
||||
# define V4_GLOBAL_MUTEX_UNLOCK THD_GLOBAL_MUTEX_UNLOCK
|
||||
# define V4_MUTEX_INIT(mutx) THD_MUTEX_INIT (mutx)
|
||||
@ -5485,7 +5483,6 @@ static Database* init(thread_db* tdbb,
|
||||
up a cleanup handler. Regardless, then lock the database mutex. */
|
||||
|
||||
if (!initialized) {
|
||||
THD_INIT;
|
||||
THREAD_EXIT();
|
||||
THD_GLOBAL_MUTEX_LOCK;
|
||||
THREAD_ENTER();
|
||||
|
@ -28,7 +28,6 @@
|
||||
#define JRD_PWD_H
|
||||
|
||||
#include "../jrd/ibase.h"
|
||||
#include "../jrd/smp_impl.h"
|
||||
#include "../jrd/thd.h"
|
||||
#include "../jrd/sha.h"
|
||||
#ifdef HAVE_STDLIB_H
|
||||
@ -97,7 +96,7 @@ private:
|
||||
static const UCHAR PWD_REQUEST[256];
|
||||
static const UCHAR TPB[4];
|
||||
|
||||
V4Mutex mutex;
|
||||
Firebird::Mutex mutex;
|
||||
|
||||
ISC_STATUS_ARRAY status;
|
||||
|
||||
|
@ -282,7 +282,7 @@ bool SecurityDatabase::lookup_user(TEXT * user_name, int *uid, int *gid, TEXT *
|
||||
uname[sizeof uname - 1] = 0;
|
||||
|
||||
THREAD_EXIT();
|
||||
mutex.acquire();
|
||||
mutex.enter();
|
||||
THREAD_ENTER();
|
||||
|
||||
// Attach database and compile request
|
||||
@ -296,7 +296,7 @@ bool SecurityDatabase::lookup_user(TEXT * user_name, int *uid, int *gid, TEXT *
|
||||
isc_detach_database(status, &tmp);
|
||||
}
|
||||
THREAD_ENTER();
|
||||
mutex.release();
|
||||
mutex.leave();
|
||||
ERR_post(isc_psw_attach, 0);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ bool SecurityDatabase::lookup_user(TEXT * user_name, int *uid, int *gid, TEXT *
|
||||
if (isc_start_transaction(status, &lookup_trans, 1, &lookup_db, sizeof(TPB), TPB))
|
||||
{
|
||||
THREAD_ENTER();
|
||||
mutex.release();
|
||||
mutex.leave();
|
||||
ERR_post(isc_psw_start_trans, 0);
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ bool SecurityDatabase::lookup_user(TEXT * user_name, int *uid, int *gid, TEXT *
|
||||
isc_detach_database(status, &lookup_db);
|
||||
}
|
||||
THREAD_ENTER();
|
||||
mutex.release();
|
||||
mutex.leave();
|
||||
|
||||
return found;
|
||||
}
|
||||
|
@ -546,7 +546,6 @@ void SCH_init(void)
|
||||
gds__register_cleanup(cleanup, 0);
|
||||
init_flag = true;
|
||||
#ifdef MULTI_THREAD
|
||||
THD_INIT;
|
||||
}
|
||||
} catch (const std::exception&) {
|
||||
scheduler_init_lock.leave();
|
||||
|
@ -208,13 +208,11 @@ int THD_wlck_unlock(wlck_t*);
|
||||
#endif // V4_THREADING
|
||||
|
||||
#ifdef ANY_THREADING
|
||||
#define THD_INIT
|
||||
#define THD_GLOBAL_MUTEX_LOCK THD_mutex_lock_global()
|
||||
#define THD_GLOBAL_MUTEX_UNLOCK THD_mutex_unlock_global()
|
||||
#define THD_MUTEX_LOCK(mutx) THD_mutex_lock (mutx)
|
||||
#define THD_MUTEX_UNLOCK(mutx) THD_mutex_unlock (mutx)
|
||||
#else
|
||||
#define THD_INIT
|
||||
#define THD_GLOBAL_MUTEX_LOCK
|
||||
#define THD_GLOBAL_MUTEX_UNLOCK
|
||||
#define THD_MUTEX_LOCK(mutx)
|
||||
|
@ -5961,10 +5961,6 @@ static void subsystem_enter(void)
|
||||
*
|
||||
**************************************/
|
||||
|
||||
#ifdef EMBEDDED
|
||||
THD_INIT;
|
||||
#endif
|
||||
|
||||
THREAD_ENTER();
|
||||
#if !(defined REQUESTER || defined SUPERCLIENT || defined SUPERSERVER)
|
||||
isc_enter_count++;
|
||||
|
Loading…
Reference in New Issue
Block a user