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