mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 00:03:02 +01:00
Fixed attachment lock usage. Minimized chances for races during database shutdown.
This commit is contained in:
parent
ca02915999
commit
647bad2d61
@ -398,7 +398,7 @@ int jrd_rel::blocking_ast_gcLock(void* ast_object)
|
||||
Lock* lock = relation->rel_gc_lock;
|
||||
Database* dbb = lock->lck_dbb;
|
||||
|
||||
AsyncContextHolder tdbb(dbb, FB_FUNCTION);
|
||||
AsyncContextHolder tdbb(dbb, FB_FUNCTION, lock);
|
||||
|
||||
fb_assert(!(relation->rel_flags & REL_gc_lockneed));
|
||||
if (relation->rel_flags & REL_gc_lockneed) // work already done synchronously ?
|
||||
|
@ -226,7 +226,7 @@ int CCH_down_grade_dbb(void* ast_object)
|
||||
{
|
||||
Lock* const lock = dbb->dbb_lock;
|
||||
|
||||
AsyncContextHolder tdbb(dbb, FB_FUNCTION, lock);
|
||||
AsyncContextHolder tdbb(dbb, FB_FUNCTION);
|
||||
|
||||
SyncLockGuard dsGuard(&dbb->dbb_sync, SYNC_EXCLUSIVE, "CCH_down_grade_dbb");
|
||||
|
||||
@ -234,7 +234,8 @@ int CCH_down_grade_dbb(void* ast_object)
|
||||
|
||||
// Process the database shutdown request, if any
|
||||
|
||||
SHUT_blocking_ast(tdbb, true);
|
||||
if (SHUT_blocking_ast(tdbb, true))
|
||||
return 0;
|
||||
|
||||
// If we are already shared, there is nothing more we can do.
|
||||
// If any case, the other guy probably wants exclusive access,
|
||||
|
@ -69,10 +69,10 @@ static void same_mode(Database* dbb)
|
||||
|
||||
static void check_backup_state(thread_db*);
|
||||
static bool notify_shutdown(thread_db*, SSHORT, SSHORT, Sync*);
|
||||
static void shutdown(thread_db*, SSHORT, bool);
|
||||
static bool shutdown(thread_db*, SSHORT, bool);
|
||||
|
||||
|
||||
void SHUT_blocking_ast(thread_db* tdbb, bool ast)
|
||||
bool SHUT_blocking_ast(thread_db* tdbb, bool ast)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -123,14 +123,11 @@ void SHUT_blocking_ast(thread_db* tdbb, bool ast)
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flag & isc_dpb_shut_force) && !delay)
|
||||
{
|
||||
shutdown(tdbb, flag, ast);
|
||||
return;
|
||||
}
|
||||
return shutdown(tdbb, flag, ast);
|
||||
|
||||
if (flag & isc_dpb_shut_attachment)
|
||||
dbb->dbb_ast_flags |= DBB_shut_attach;
|
||||
@ -138,6 +135,8 @@ void SHUT_blocking_ast(thread_db* tdbb, bool ast)
|
||||
dbb->dbb_ast_flags |= DBB_shut_force;
|
||||
if (flag & isc_dpb_shut_transaction)
|
||||
dbb->dbb_ast_flags |= DBB_shut_tran;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -485,7 +484,7 @@ static bool notify_shutdown(thread_db* tdbb, SSHORT flag, SSHORT delay, Sync* gu
|
||||
}
|
||||
|
||||
|
||||
static void shutdown(thread_db* tdbb, SSHORT flag, bool force)
|
||||
static bool shutdown(thread_db* tdbb, SSHORT flag, bool force)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -541,5 +540,9 @@ static void shutdown(thread_db* tdbb, SSHORT flag, bool force)
|
||||
|
||||
if (found)
|
||||
JRD_shutdown_attachments(dbb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace Firebird {
|
||||
class Sync;
|
||||
}
|
||||
|
||||
void SHUT_blocking_ast(Jrd::thread_db*, bool);
|
||||
bool SHUT_blocking_ast(Jrd::thread_db*, bool);
|
||||
void SHUT_database(Jrd::thread_db*, SSHORT, SSHORT, Firebird::Sync*);
|
||||
void SHUT_init(Jrd::thread_db*);
|
||||
void SHUT_online(Jrd::thread_db*, SSHORT, Firebird::Sync*);
|
||||
|
Loading…
Reference in New Issue
Block a user