mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 18:03:04 +01:00
Backport fixes for memory leaks found by Jiří, see "Memory leak with external engine plugin" in fb-devel
This commit is contained in:
parent
679ecad8ef
commit
f1cb457406
@ -1187,16 +1187,15 @@ void ExtEngineManager::makeFunction(thread_db* tdbb, CompilerScratch* csb, Jrd::
|
||||
CallerName(obj_udf, udf->getName().identifier) :
|
||||
CallerName(obj_package_header, udf->getName().package)));
|
||||
|
||||
///MemoryPool& pool = *tdbb->getDefaultPool();
|
||||
MemoryPool& pool = *getDefaultMemoryPool();
|
||||
MemoryPool& pool = *tdbb->getAttachment()->att_pool;
|
||||
|
||||
AutoPtr<RoutineMetadata> metadata(FB_NEW_POOL(pool) RoutineMetadata(pool));
|
||||
metadata->package = udf->getName().package;
|
||||
metadata->name = udf->getName().identifier;
|
||||
metadata->entryPoint = entryPointTrimmed;
|
||||
metadata->body = body;
|
||||
metadata->inputParameters = Routine::createMetadata(udf->getInputFields());
|
||||
metadata->outputParameters = Routine::createMetadata(udf->getOutputFields());
|
||||
metadata->inputParameters.assignRefNoIncr(Routine::createMetadata(udf->getInputFields()));
|
||||
metadata->outputParameters.assignRefNoIncr(Routine::createMetadata(udf->getOutputFields()));
|
||||
|
||||
FbLocalStatus status;
|
||||
|
||||
@ -1222,10 +1221,10 @@ void ExtEngineManager::makeFunction(thread_db* tdbb, CompilerScratch* csb, Jrd::
|
||||
Arg::Gds(isc_eem_func_not_returned) << udf->getName().toString() << engine);
|
||||
}
|
||||
|
||||
extInputParameters = inBuilder->getMetadata(&status);
|
||||
extInputParameters.assignRefNoIncr(inBuilder->getMetadata(&status));
|
||||
status.check();
|
||||
|
||||
extOutputParameters = outBuilder->getMetadata(&status);
|
||||
extOutputParameters.assignRefNoIncr(outBuilder->getMetadata(&status));
|
||||
status.check();
|
||||
}
|
||||
|
||||
@ -1237,13 +1236,15 @@ void ExtEngineManager::makeFunction(thread_db* tdbb, CompilerScratch* csb, Jrd::
|
||||
|
||||
try
|
||||
{
|
||||
udf->fun_external = FB_NEW_POOL(getPool()) Function(tdbb, this, attInfo->engine,
|
||||
udf->fun_external = FB_NEW_POOL(pool) Function(tdbb, this, attInfo->engine,
|
||||
metadata.release(), externalFunction, udf);
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(getPool()) CompoundStmtNode(getPool());
|
||||
MemoryPool& csbPool = csb->csb_pool;
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(csbPool) CompoundStmtNode(csbPool);
|
||||
|
||||
IntMessageNode* intInMessageNode = udf->getInputFields().hasData() ?
|
||||
FB_NEW_POOL(getPool()) IntMessageNode(tdbb, getPool(), csb, 0,
|
||||
FB_NEW_POOL(csbPool) IntMessageNode(tdbb, csbPool, csb, 0,
|
||||
udf->getInputFields(), udf->getInputFormat()) :
|
||||
NULL;
|
||||
ExtMessageNode* extInMessageNode = NULL;
|
||||
@ -1252,38 +1253,38 @@ void ExtEngineManager::makeFunction(thread_db* tdbb, CompilerScratch* csb, Jrd::
|
||||
{
|
||||
mainNode->statements.add(intInMessageNode);
|
||||
|
||||
extInMessageNode = FB_NEW_POOL(getPool()) ExtMessageNode(tdbb, getPool(), csb, 2, extInputFormat);
|
||||
extInMessageNode = FB_NEW_POOL(csbPool) ExtMessageNode(tdbb, csbPool, csb, 2, extInputFormat);
|
||||
mainNode->statements.add(extInMessageNode);
|
||||
}
|
||||
|
||||
IntMessageNode* intOutMessageNode = FB_NEW_POOL(getPool()) IntMessageNode(tdbb, getPool(), csb, 1,
|
||||
IntMessageNode* intOutMessageNode = FB_NEW_POOL(csbPool) IntMessageNode(tdbb, csbPool, csb, 1,
|
||||
udf->getOutputFields(), udf->getOutputFormat());
|
||||
mainNode->statements.add(intOutMessageNode);
|
||||
|
||||
ExtMessageNode* extOutMessageNode = FB_NEW_POOL(getPool()) ExtMessageNode(tdbb, getPool(), csb, 3,
|
||||
ExtMessageNode* extOutMessageNode = FB_NEW_POOL(csbPool) ExtMessageNode(tdbb, csbPool, csb, 3,
|
||||
extOutputFormat);
|
||||
mainNode->statements.add(extOutMessageNode);
|
||||
|
||||
// Initialize the output fields into the external message.
|
||||
InitOutputNode* initOutputNode = FB_NEW_POOL(getPool()) InitOutputNode(
|
||||
tdbb, getPool(), csb, udf->getOutputFields(), extOutMessageNode);
|
||||
InitOutputNode* initOutputNode = FB_NEW_POOL(csbPool) InitOutputNode(
|
||||
tdbb, csbPool, csb, udf->getOutputFields(), extOutMessageNode);
|
||||
mainNode->statements.add(initOutputNode);
|
||||
|
||||
if (intInMessageNode)
|
||||
{
|
||||
ReceiveNode* receiveNode = intInMessageNode ? FB_NEW_POOL(getPool()) ReceiveNode(getPool()) : NULL;
|
||||
ReceiveNode* receiveNode = intInMessageNode ? FB_NEW_POOL(csbPool) ReceiveNode(csbPool) : NULL;
|
||||
receiveNode->message = intInMessageNode;
|
||||
receiveNode->statement = FB_NEW_POOL(getPool()) MessageMoverNode(
|
||||
getPool(), intInMessageNode, extInMessageNode);
|
||||
receiveNode->statement = FB_NEW_POOL(csbPool) MessageMoverNode(
|
||||
csbPool, intInMessageNode, extInMessageNode);
|
||||
mainNode->statements.add(receiveNode);
|
||||
}
|
||||
|
||||
ExtFunctionNode* extFunctionNode = FB_NEW_POOL(getPool()) ExtFunctionNode(getPool(),
|
||||
ExtFunctionNode* extFunctionNode = FB_NEW_POOL(csbPool) ExtFunctionNode(csbPool,
|
||||
extInMessageNode, extOutMessageNode, udf->fun_external);
|
||||
mainNode->statements.add(extFunctionNode);
|
||||
extFunctionNode->message = intOutMessageNode;
|
||||
extFunctionNode->statement = FB_NEW_POOL(getPool()) MessageMoverNode(
|
||||
getPool(), extOutMessageNode, intOutMessageNode);
|
||||
extFunctionNode->statement = FB_NEW_POOL(csbPool) MessageMoverNode(
|
||||
csbPool, extOutMessageNode, intOutMessageNode);
|
||||
|
||||
JrdStatement* statement = udf->getStatement();
|
||||
PAR_preparsed_node(tdbb, NULL, mainNode, NULL, &csb, &statement, false, 0);
|
||||
@ -1310,16 +1311,15 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_
|
||||
CallerName(obj_procedure, prc->getName().identifier) :
|
||||
CallerName(obj_package_header, prc->getName().package)));
|
||||
|
||||
///MemoryPool& pool = *tdbb->getDefaultPool();
|
||||
MemoryPool& pool = *getDefaultMemoryPool();
|
||||
MemoryPool& pool = *tdbb->getAttachment()->att_pool;
|
||||
|
||||
AutoPtr<RoutineMetadata> metadata(FB_NEW_POOL(pool) RoutineMetadata(pool));
|
||||
metadata->package = prc->getName().package;
|
||||
metadata->name = prc->getName().identifier;
|
||||
metadata->entryPoint = entryPointTrimmed;
|
||||
metadata->body = body;
|
||||
metadata->inputParameters = Routine::createMetadata(prc->getInputFields());
|
||||
metadata->outputParameters = Routine::createMetadata(prc->getOutputFields());
|
||||
metadata->inputParameters.assignRefNoIncr(Routine::createMetadata(prc->getInputFields()));
|
||||
metadata->outputParameters.assignRefNoIncr(Routine::createMetadata(prc->getOutputFields()));
|
||||
|
||||
FbLocalStatus status;
|
||||
|
||||
@ -1346,10 +1346,10 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_
|
||||
prc->getName().toString() << engine);
|
||||
}
|
||||
|
||||
extInputParameters = inBuilder->getMetadata(&status);
|
||||
extInputParameters.assignRefNoIncr(inBuilder->getMetadata(&status));
|
||||
status.check();
|
||||
|
||||
extOutputParameters = outBuilder->getMetadata(&status);
|
||||
extOutputParameters.assignRefNoIncr(outBuilder->getMetadata(&status));
|
||||
status.check();
|
||||
}
|
||||
|
||||
@ -1361,13 +1361,15 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_
|
||||
|
||||
try
|
||||
{
|
||||
prc->setExternal(FB_NEW_POOL(getPool()) Procedure(tdbb, this, attInfo->engine,
|
||||
prc->setExternal(FB_NEW_POOL(pool) Procedure(tdbb, this, attInfo->engine,
|
||||
metadata.release(), externalProcedure, prc));
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(getPool()) CompoundStmtNode(getPool());
|
||||
MemoryPool& csbPool = csb->csb_pool;
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(csbPool) CompoundStmtNode(csbPool);
|
||||
|
||||
IntMessageNode* intInMessageNode = prc->getInputFields().hasData() ?
|
||||
FB_NEW_POOL(getPool()) IntMessageNode(tdbb, getPool(), csb, 0,
|
||||
FB_NEW_POOL(csbPool) IntMessageNode(tdbb, csbPool, csb, 0,
|
||||
prc->getInputFields(), prc->getInputFormat()) :
|
||||
NULL;
|
||||
ExtMessageNode* extInMessageNode = NULL;
|
||||
@ -1376,32 +1378,32 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_
|
||||
{
|
||||
mainNode->statements.add(intInMessageNode);
|
||||
|
||||
extInMessageNode = FB_NEW_POOL(getPool()) ExtMessageNode(tdbb, getPool(), csb, 2, extInputFormat);
|
||||
extInMessageNode = FB_NEW_POOL(csbPool) ExtMessageNode(tdbb, csbPool, csb, 2, extInputFormat);
|
||||
mainNode->statements.add(extInMessageNode);
|
||||
}
|
||||
|
||||
IntMessageNode* intOutMessageNode = FB_NEW_POOL(getPool()) IntMessageNode(tdbb, getPool(), csb, 1,
|
||||
IntMessageNode* intOutMessageNode = FB_NEW_POOL(csbPool) IntMessageNode(tdbb, csbPool, csb, 1,
|
||||
prc->getOutputFields(), prc->getOutputFormat());
|
||||
mainNode->statements.add(intOutMessageNode);
|
||||
|
||||
ExtMessageNode* extOutMessageNode = FB_NEW_POOL(getPool()) ExtMessageNode(tdbb, getPool(),
|
||||
ExtMessageNode* extOutMessageNode = FB_NEW_POOL(csbPool) ExtMessageNode(tdbb, csbPool,
|
||||
csb, 3, extOutputFormat);
|
||||
mainNode->statements.add(extOutMessageNode);
|
||||
|
||||
// Initialize the output fields into the external message.
|
||||
InitOutputNode* initOutputNode = FB_NEW_POOL(getPool()) InitOutputNode(
|
||||
tdbb, getPool(), csb, prc->getOutputFields(), extOutMessageNode);
|
||||
InitOutputNode* initOutputNode = FB_NEW_POOL(csbPool) InitOutputNode(
|
||||
tdbb, csbPool, csb, prc->getOutputFields(), extOutMessageNode);
|
||||
mainNode->statements.add(initOutputNode);
|
||||
|
||||
ReceiveNode* receiveNode = intInMessageNode ?
|
||||
FB_NEW_POOL(getPool()) ReceiveNode(getPool()) : NULL;
|
||||
FB_NEW_POOL(csbPool) ReceiveNode(csbPool) : NULL;
|
||||
|
||||
if (intInMessageNode)
|
||||
{
|
||||
CompoundStmtNode* receiveSubStatement = FB_NEW_POOL(getPool()) CompoundStmtNode(getPool());
|
||||
receiveSubStatement->statements.add(FB_NEW_POOL(getPool()) MessageMoverNode(
|
||||
getPool(), intInMessageNode, extInMessageNode));
|
||||
receiveSubStatement->statements.add(FB_NEW_POOL(getPool()) StallNode(getPool()));
|
||||
CompoundStmtNode* receiveSubStatement = FB_NEW_POOL(csbPool) CompoundStmtNode(csbPool);
|
||||
receiveSubStatement->statements.add(FB_NEW_POOL(csbPool) MessageMoverNode(
|
||||
csbPool, intInMessageNode, extInMessageNode));
|
||||
receiveSubStatement->statements.add(FB_NEW_POOL(csbPool) StallNode(csbPool));
|
||||
|
||||
receiveNode->statement = receiveSubStatement;
|
||||
receiveNode->message = intInMessageNode;
|
||||
@ -1409,9 +1411,9 @@ void ExtEngineManager::makeProcedure(thread_db* tdbb, CompilerScratch* csb, jrd_
|
||||
mainNode->statements.add(receiveNode);
|
||||
}
|
||||
else
|
||||
mainNode->statements.add(FB_NEW_POOL(getPool()) StallNode(getPool()));
|
||||
mainNode->statements.add(FB_NEW_POOL(csbPool) StallNode(csbPool));
|
||||
|
||||
ExtProcedureNode* extProcedureNode = FB_NEW_POOL(getPool()) ExtProcedureNode(getPool(),
|
||||
ExtProcedureNode* extProcedureNode = FB_NEW_POOL(csbPool) ExtProcedureNode(csbPool,
|
||||
extInMessageNode, extOutMessageNode, intOutMessageNode, prc->getExternal());
|
||||
mainNode->statements.add(extProcedureNode);
|
||||
|
||||
@ -1439,8 +1441,7 @@ void ExtEngineManager::makeTrigger(thread_db* tdbb, CompilerScratch* csb, Jrd::T
|
||||
ContextManager<IExternalTrigger> ctxManager(tdbb, attInfo, attInfo->adminCharSet,
|
||||
CallerName(obj_trigger, trg->name));
|
||||
|
||||
///MemoryPool& pool = *tdbb->getDefaultPool();
|
||||
MemoryPool& pool = *getDefaultMemoryPool();
|
||||
MemoryPool& pool = *tdbb->getAttachment()->att_pool;
|
||||
|
||||
AutoPtr<RoutineMetadata> metadata(FB_NEW_POOL(pool) RoutineMetadata(pool));
|
||||
metadata->name = trg->name;
|
||||
@ -1501,13 +1502,15 @@ void ExtEngineManager::makeTrigger(thread_db* tdbb, CompilerScratch* csb, Jrd::T
|
||||
|
||||
try
|
||||
{
|
||||
trg->extTrigger = FB_NEW_POOL(getPool()) Trigger(tdbb, pool, csb, this, attInfo->engine,
|
||||
trg->extTrigger = FB_NEW_POOL(pool) Trigger(tdbb, pool, csb, this, attInfo->engine,
|
||||
metadata.release(), externalTrigger, trg);
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(getPool()) CompoundStmtNode(getPool());
|
||||
MemoryPool& csbPool = csb->csb_pool;
|
||||
|
||||
CompoundStmtNode* mainNode = FB_NEW_POOL(csbPool) CompoundStmtNode(csbPool);
|
||||
mainNode->statements.append(trg->extTrigger->computedStatements);
|
||||
|
||||
ExtTriggerNode* extTriggerNode = FB_NEW_POOL(getPool()) ExtTriggerNode(getPool(),
|
||||
ExtTriggerNode* extTriggerNode = FB_NEW_POOL(csbPool) ExtTriggerNode(csbPool,
|
||||
trg->extTrigger);
|
||||
mainNode->statements.add(extTriggerNode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user