pgbackrest.git / summary / log / commit / refs
commit b792a14cd7dbdfb61362700ffc5fc01997db890c
Author: David Steele <david@pgmasters.net>
Date: Fri Oct 01 22:23:03 2021 +0000
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.
src/db/protocol.c | 4 ++--
src/protocol/server.c | 7 +++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/db/protocol.c b/src/db/protocol.c
index 0bf855a68..7856893e6 100644
--- a/src/db/protocol.c
+++ b/src/db/protocol.c
@@ -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
diff --git a/src/protocol/server.c b/src/protocol/server.c
index 284c30b85..44a991a60 100644
--- a/src/protocol/server.c
+++ b/src/protocol/server.c
@@ -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
[parent: ae40ed6ec9cf]