mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 09:20:39 +01:00
Unload ib_util.dll (.so) when unloading the engine.
This commit is contained in:
parent
62f99f6e18
commit
04bf24ae75
@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "firebird.h"
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -78,7 +79,8 @@ using namespace Firebird;
|
||||
|
||||
namespace
|
||||
{
|
||||
bool volatile initDone = false;
|
||||
const ModuleLoader::Module* bootModule = reinterpret_cast<ModuleLoader::Module*>(0x1);
|
||||
std::atomic<const ModuleLoader::Module*> ibUtilModule;
|
||||
|
||||
struct IbUtilStartup
|
||||
{
|
||||
@ -123,7 +125,7 @@ namespace
|
||||
}
|
||||
|
||||
ibUtilUnit(IbUtil::alloc);
|
||||
initDone = true;
|
||||
ibUtilModule = module;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -132,9 +134,12 @@ namespace
|
||||
|
||||
void IbUtil::initialize()
|
||||
{
|
||||
if (initDone || fb_utils::bootBuild())
|
||||
if (ibUtilModule)
|
||||
return;
|
||||
|
||||
if (fb_utils::bootBuild())
|
||||
{
|
||||
initDone = true;
|
||||
ibUtilModule = bootModule;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -172,6 +177,16 @@ void IbUtil::initialize()
|
||||
message[2].c_str(), message[3].c_str());
|
||||
}
|
||||
|
||||
void IbUtil::finalize()
|
||||
{
|
||||
const ModuleLoader::Module* module = ibUtilModule.exchange(nullptr);
|
||||
|
||||
if (!module || module == bootModule)
|
||||
return;
|
||||
|
||||
delete module;
|
||||
}
|
||||
|
||||
void* IbUtil::alloc(long size)
|
||||
{
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
@ -318,7 +333,7 @@ void FUN_evaluate(thread_db* tdbb, const Function* function, const NestValueArra
|
||||
*
|
||||
**************************************/
|
||||
// We may be in danger of AV in UDF if ib_util init failed
|
||||
if (!initDone)
|
||||
if (!ibUtilModule)
|
||||
{
|
||||
ERR_post(Arg::Gds(isc_random) << "ib_util init failed - UDF usage disabled");
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class IbUtil
|
||||
{
|
||||
public:
|
||||
static void initialize();
|
||||
static void finalize();
|
||||
|
||||
static void* alloc(long size);
|
||||
static bool free(void* ptr);
|
||||
|
@ -4654,6 +4654,7 @@ void JProvider::shutdown(CheckStatusWrapper* status, unsigned int timeout, const
|
||||
// PluginManager wants to lock a mutex, which is sometimes already locked in current thread
|
||||
TraceManager::shutdown();
|
||||
Mapping::shutdownIpc();
|
||||
IbUtil::finalize();
|
||||
}
|
||||
|
||||
// Wait for completion of all attacment shutdown threads
|
||||
|
Loading…
Reference in New Issue
Block a user