1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Use temp mem context when calling command handlers.

It is safer and more efficient to free memory after each handler completes.

The db command handlers use the server context so update them to use the top context.
This commit is contained in:
David Steele 2021-10-01 18:23:03 -04:00
parent ae40ed6ec9
commit b792a14cd7
2 changed files with 5 additions and 6 deletions

View File

@ -39,11 +39,11 @@ dbOpenProtocol(PackRead *const param, ProtocolServer *const server)
// If the db list does not exist then create it in the prior context (which should be persistent)
if (dbProtocolLocal.pgClientList == NULL)
{
MEM_CONTEXT_PRIOR_BEGIN()
MEM_CONTEXT_BEGIN(memContextTop())
{
dbProtocolLocal.pgClientList = lstNewP(sizeof(PgClient *));
}
MEM_CONTEXT_PRIOR_END();
MEM_CONTEXT_END();
}
// Add db to the list

View File

@ -179,9 +179,8 @@ protocolServerProcess(
// If handler was found then process
if (handler != NULL)
{
// Send the command to the handler. Run the handler in the server's memory context in case any persistent data
// needs to be stored by the handler.
MEM_CONTEXT_BEGIN(objMemContext(this))
// Send the command to the handler
MEM_CONTEXT_TEMP_BEGIN()
{
// Initialize retries in case of command failure
bool retry = false;
@ -229,7 +228,7 @@ protocolServerProcess(
}
while (retry);
}
MEM_CONTEXT_END();
MEM_CONTEXT_TEMP_END();
}
// Else check built-in commands
else