Skip to content

Commit

Permalink
Per valgrind, fix some memory leaks. (#799)
Browse files Browse the repository at this point in the history
* Per valgrind, fix some memory leaks.

We would be using PQfreemem on a PQExpBuffer, where it's expected to be
using destroyPQExpBuffer instead.

Also we were short of a call to finish the
connection to the monitor notification client when exiting from the service
keeper process, although adding this clean-up doesn't seem to impact the
valgrind reports.
  • Loading branch information
DimCitus committed Sep 7, 2021
1 parent ec8f8d9 commit c1daadf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/bin/pg_autoctl/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -1640,8 +1640,8 @@ pgsql_replication_slot_create_and_drop(PGSQL *pgsql, NodeAddressArray *nodeArray
if (!BuildNodesArrayValues(nodeArray, &sqlParams, values))
{
/* errors have already been logged */
PQfreemem(query);
PQfreemem(values);
destroyPQExpBuffer(query);
destroyPQExpBuffer(values);

return false;
}
Expand All @@ -1658,8 +1658,8 @@ pgsql_replication_slot_create_and_drop(PGSQL *pgsql, NodeAddressArray *nodeArray
&context,
parseReplicationSlotMaintain);

PQfreemem(query);
PQfreemem(values);
destroyPQExpBuffer(query);
destroyPQExpBuffer(values);

return success;
}
Expand Down Expand Up @@ -1717,8 +1717,8 @@ pgsql_replication_slot_maintain(PGSQL *pgsql, NodeAddressArray *nodeArray)
if (!BuildNodesArrayValues(nodeArray, &sqlParams, values))
{
/* errors have already been logged */
PQfreemem(query);
PQfreemem(values);
destroyPQExpBuffer(query);
destroyPQExpBuffer(values);

return false;
}
Expand All @@ -1735,8 +1735,8 @@ pgsql_replication_slot_maintain(PGSQL *pgsql, NodeAddressArray *nodeArray)
&context,
parseReplicationSlotMaintain);

PQfreemem(query);
PQfreemem(values);
destroyPQExpBuffer(query);
destroyPQExpBuffer(values);

return success;
}
Expand Down
1 change: 1 addition & 0 deletions src/bin/pg_autoctl/service_keeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ keeper_node_active_loop(Keeper *keeper, pid_t start_pid)

/* One last check that we do not have any connections open */
pgsql_finish(&(keeper->monitor.pgsql));
pgsql_finish(&(monitor->notificationClient));

if (nodeHasBeenDroppedFromTheMonitor)
{
Expand Down

0 comments on commit c1daadf

Please sign in to comment.