mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
Backported fix for CORE-900: Deadlock when attaching simultaneously with services and standard APIs
This commit is contained in:
parent
a3c4fe1f4d
commit
66625457d4
@ -183,15 +183,45 @@ const SSHORT WAIT_PERIOD = -1;
|
||||
#ifdef SUPERSERVER
|
||||
|
||||
extern SLONG trace_pools;
|
||||
static REC_MUTX_T databases_rec_mutex;
|
||||
|
||||
// BRS. 03/23/2003
|
||||
// Those empty defines was substituted with #if defined(V4_THREADING) && !defined(SUPERSERVER)
|
||||
//#define V4_JRD_MUTEX_LOCK(mutx)
|
||||
//#define V4_JRD_MUTEX_UNLOCK(mutx)
|
||||
|
||||
#define JRD_SS_INIT_MUTEX THD_rec_mutex_init (&databases_rec_mutex)
|
||||
#define JRD_SS_DESTROY_MUTEX THD_rec_mutex_destroy (&databases_rec_mutex)
|
||||
namespace
|
||||
{
|
||||
REC_MUTX_T databases_rec_mutex;
|
||||
|
||||
class DatabasesInit
|
||||
{
|
||||
public:
|
||||
static void init()
|
||||
{
|
||||
THD_rec_mutex_init(&databases_rec_mutex);
|
||||
}
|
||||
static void cleanup()
|
||||
{
|
||||
THD_rec_mutex_destroy(&databases_rec_mutex);
|
||||
}
|
||||
};
|
||||
|
||||
class DatabasesInitInstance : public Firebird::InitMutex<DatabasesInit>
|
||||
{
|
||||
public:
|
||||
DatabasesInitInstance()
|
||||
{
|
||||
init();
|
||||
}
|
||||
~DatabasesInitInstance()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
DatabasesInitInstance holder;
|
||||
}
|
||||
|
||||
#define JRD_SS_MUTEX_LOCK {THREAD_EXIT();\
|
||||
THD_rec_mutex_lock (&databases_rec_mutex);\
|
||||
THREAD_ENTER();}
|
||||
@ -200,8 +230,6 @@ static REC_MUTX_T databases_rec_mutex;
|
||||
#define JRD_SS_THD_MUTEX_UNLOCK THD_rec_mutex_unlock (&databases_rec_mutex)
|
||||
|
||||
#else
|
||||
#define JRD_SS_INIT_MUTEX
|
||||
#define JRD_SS_DESTROY_MUTEX
|
||||
#define JRD_SS_MUTEX_LOCK
|
||||
#define JRD_SS_MUTEX_UNLOCK
|
||||
#define JRD_SS_THD_MUTEX_LOCK
|
||||
@ -3453,16 +3481,20 @@ ISC_STATUS GDS_SERVICE_ATTACH(ISC_STATUS* user_status,
|
||||
|
||||
tdbb->tdbb_status_vector = user_status;
|
||||
tdbb->tdbb_database = NULL;
|
||||
|
||||
|
||||
JRD_SS_MUTEX_LOCK;
|
||||
|
||||
try
|
||||
{
|
||||
*svc_handle = SVC_attach(service_length, service_name, spb_length, spb);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
JRD_SS_MUTEX_UNLOCK;
|
||||
return error(user_status, ex);
|
||||
}
|
||||
|
||||
JRD_SS_MUTEX_UNLOCK;
|
||||
return return_success(tdbb);
|
||||
}
|
||||
|
||||
@ -4819,7 +4851,6 @@ static void cleanup(void* arg)
|
||||
#if defined(V4_THREADING) && !defined(SUPERSERVER)
|
||||
V4_MUTEX_DESTROY(databases_mutex);
|
||||
#endif
|
||||
JRD_SS_DESTROY_MUTEX;
|
||||
initialized = false;
|
||||
databases = NULL;
|
||||
}
|
||||
@ -5526,7 +5557,6 @@ static Database* init(thread_db* tdbb,
|
||||
#if defined(V4_THREADING) && !defined(SUPERSERVER)
|
||||
V4_MUTEX_INIT(databases_mutex);
|
||||
#endif
|
||||
JRD_SS_INIT_MUTEX;
|
||||
gds__register_cleanup(cleanup, 0);
|
||||
initialized = true;
|
||||
JRD_cache_default = Config::getDefaultDbCachePages();
|
||||
|
Loading…
Reference in New Issue
Block a user