diff --git a/src/jrd/Database.h b/src/jrd/Database.h index 3d6f730dad..02ffb6452a 100644 --- a/src/jrd/Database.h +++ b/src/jrd/Database.h @@ -253,8 +253,11 @@ public: CheckoutLockGuard(Database* dbb, Firebird::Mutex& m) : mutex(m) { - Checkout dcoHolder(dbb); - mutex.enter(); + if (!mutex.tryEnter()) + { + Checkout dcoHolder(dbb); + mutex.enter(); + } } ~CheckoutLockGuard() diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index ed81a32940..5740792e96 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -174,6 +174,9 @@ namespace inline void validateHandle(thread_db* tdbb, Jrd::Attachment* const attachment) { + if (attachment == tdbb->getAttachment()) + return; + if (!attachment->checkHandle() || !attachment->att_database->checkHandle()) { status_exception::raise(Arg::Gds(isc_bad_db_handle));