mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 04:43:03 +01:00
Backported CORE-6371: Avoid server crash on shutdown in case of wrong reference counting in UDR
This commit is contained in:
parent
625482daed
commit
456b3e3cc2
@ -52,13 +52,13 @@ using namespace Firebird;
|
||||
|
||||
|
||||
// static method
|
||||
Jrd::Attachment* Jrd::Attachment::create(Database* dbb)
|
||||
Jrd::Attachment* Jrd::Attachment::create(Database* dbb, Firebird::IProvider* provider)
|
||||
{
|
||||
MemoryPool* const pool = dbb->createPool();
|
||||
|
||||
try
|
||||
{
|
||||
Attachment* const attachment = FB_NEW_POOL(*pool) Attachment(pool, dbb);
|
||||
Attachment* const attachment = FB_NEW_POOL(*pool) Attachment(pool, dbb, provider);
|
||||
pool->setStatsGroup(attachment->att_memory_stats);
|
||||
return attachment;
|
||||
}
|
||||
@ -171,7 +171,7 @@ void Jrd::Attachment::backupStateReadUnLock(thread_db* tdbb)
|
||||
}
|
||||
|
||||
|
||||
Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb)
|
||||
Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb, IProvider* provider)
|
||||
: att_pool(pool),
|
||||
att_memory_stats(&dbb->dbb_memory_stats),
|
||||
att_database(dbb),
|
||||
@ -204,7 +204,8 @@ Jrd::Attachment::Attachment(MemoryPool* pool, Database* dbb)
|
||||
att_dyn_req(*pool),
|
||||
att_charsets(*pool),
|
||||
att_charset_ids(*pool),
|
||||
att_pools(*pool)
|
||||
att_pools(*pool),
|
||||
att_provider(provider)
|
||||
{
|
||||
att_internal.grow(irq_MAX);
|
||||
att_dyn_req.grow(drq_MAX);
|
||||
|
@ -228,7 +228,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
static Attachment* create(Database* dbb);
|
||||
static Attachment* create(Database* dbb, Firebird::IProvider* provider);
|
||||
static void destroy(Attachment* const attachment);
|
||||
|
||||
MemoryPool* const att_pool; // Memory pool
|
||||
@ -384,9 +384,17 @@ public:
|
||||
|
||||
JAttachment* getInterface() throw();
|
||||
|
||||
Firebird::IProvider* getProvider()
|
||||
{
|
||||
fb_assert(att_provider);
|
||||
return att_provider;
|
||||
}
|
||||
|
||||
private:
|
||||
Attachment(MemoryPool* pool, Database* dbb);
|
||||
Attachment(MemoryPool* pool, Database* dbb, Firebird::IProvider* provider);
|
||||
~Attachment();
|
||||
|
||||
Firebird::IProvider* att_provider; // Provider which created this attachment
|
||||
};
|
||||
|
||||
|
||||
|
@ -926,7 +926,7 @@ namespace Jrd {
|
||||
UserId user;
|
||||
user.usr_user_name = "Database Crypter";
|
||||
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(&dbb);
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(&dbb, NULL);
|
||||
RefPtr<SysStableAttachment> sAtt(FB_NEW SysStableAttachment(attachment));
|
||||
attachment->setStable(sAtt);
|
||||
attachment->att_filename = dbb.dbb_filename;
|
||||
|
@ -604,7 +604,7 @@ ExtEngineManager::ExternalContextImpl::ExternalContextImpl(thread_db* tdbb,
|
||||
internalAttachment->getStable()->addRef();
|
||||
|
||||
externalAttachment = MasterInterfacePtr()->registerAttachment
|
||||
(AutoPlugin<JProvider>(JProvider::getInstance()), internalAttachment->getInterface());
|
||||
(internalAttachment->getProvider(), internalAttachment->getInterface());
|
||||
}
|
||||
|
||||
ExtEngineManager::ExternalContextImpl::~ExternalContextImpl()
|
||||
|
@ -2957,7 +2957,7 @@ void BufferControl::cache_writer(BufferControl* bcb)
|
||||
UserId user;
|
||||
user.usr_user_name = "Cache Writer";
|
||||
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb);
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb, NULL);
|
||||
RefPtr<SysStableAttachment> sAtt(FB_NEW SysStableAttachment(attachment));
|
||||
attachment->setStable(sAtt);
|
||||
attachment->att_filename = dbb->dbb_filename;
|
||||
|
@ -1056,7 +1056,7 @@ static void unwindAttach(thread_db* tdbb, const Exception& ex, FbStatusVector*
|
||||
Jrd::Attachment* attachment, Database* dbb, bool internalFlag);
|
||||
static JAttachment* initAttachment(thread_db*, const PathName&, const PathName&, RefPtr<const Config>, bool,
|
||||
const DatabaseOptions&, RefMutexUnlock&, IPluginConfig*, JProvider*);
|
||||
static JAttachment* create_attachment(const PathName&, Database*, const DatabaseOptions&, bool newDb);
|
||||
static JAttachment* create_attachment(const PathName&, Database*, IProvider* provider, const DatabaseOptions&, bool newDb);
|
||||
static void prepare_tra(thread_db*, jrd_tra*, USHORT, const UCHAR*);
|
||||
static void start_transaction(thread_db* tdbb, bool transliterate, jrd_tra** tra_handle,
|
||||
Jrd::Attachment* attachment, unsigned int tpb_length, const UCHAR* tpb);
|
||||
@ -6122,7 +6122,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam
|
||||
fb_assert(!(dbb->dbb_flags & DBB_new));
|
||||
|
||||
tdbb->setDatabase(dbb);
|
||||
jAtt = create_attachment(alias_name, dbb, options, !attach_flag);
|
||||
jAtt = create_attachment(alias_name, dbb, provider, options, !attach_flag);
|
||||
|
||||
if (dbb->dbb_linger_timer)
|
||||
dbb->dbb_linger_timer->reset();
|
||||
@ -6180,7 +6180,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam
|
||||
dbbGuard.lock(SYNC_EXCLUSIVE);
|
||||
|
||||
tdbb->setDatabase(dbb);
|
||||
jAtt = create_attachment(alias_name, dbb, options, !attach_flag);
|
||||
jAtt = create_attachment(alias_name, dbb, provider, options, !attach_flag);
|
||||
tdbb->setAttachment(jAtt->getHandle());
|
||||
} // end scope
|
||||
|
||||
@ -6217,6 +6217,7 @@ static JAttachment* initAttachment(thread_db* tdbb, const PathName& expanded_nam
|
||||
|
||||
static JAttachment* create_attachment(const PathName& alias_name,
|
||||
Database* dbb,
|
||||
IProvider* provider,
|
||||
const DatabaseOptions& options,
|
||||
bool newDb)
|
||||
{
|
||||
@ -6241,7 +6242,7 @@ static JAttachment* create_attachment(const PathName& alias_name,
|
||||
status_exception::raise(Arg::Gds(isc_att_shutdown));
|
||||
}
|
||||
|
||||
attachment = Jrd::Attachment::create(dbb);
|
||||
attachment = Jrd::Attachment::create(dbb, provider);
|
||||
attachment->att_next = dbb->dbb_attachments;
|
||||
dbb->dbb_attachments = attachment;
|
||||
}
|
||||
|
@ -4866,7 +4866,7 @@ void Database::garbage_collector(Database* dbb)
|
||||
UserId user;
|
||||
user.usr_user_name = "Garbage Collector";
|
||||
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb);
|
||||
Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb, NULL);
|
||||
RefPtr<SysStableAttachment> sAtt(FB_NEW SysStableAttachment(attachment));
|
||||
attachment->setStable(sAtt);
|
||||
attachment->att_filename = dbb->dbb_filename;
|
||||
|
Loading…
Reference in New Issue
Block a user