Skip to content

Commit 85a069f

Browse files
author
Sokolov Yura
committed
cfs.c: preventive protection from future leaks.
1 parent e4c4565 commit 85a069f

File tree

1 file changed

+6
-0
lines changed
  • src/backend/storage/file

1 file changed

+6
-0
lines changed

src/backend/storage/file/cfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include "utils/guc.h"
5555
#include "utils/rel.h"
5656
#include "utils/builtins.h"
57+
#include "utils/memutils.h"
5758
#include "utils/resowner_private.h"
5859

5960

@@ -1427,6 +1428,7 @@ static bool cfs_gc_scan_tablespace(int worker_id)
14271428

14281429
static void cfs_gc_bgworker_main(Datum arg)
14291430
{
1431+
MemoryContext MemCxt;
14301432
int worker_id = DatumGetInt32(arg);
14311433

14321434
pqsignal(SIGINT, cfs_gc_cancel);
@@ -1439,6 +1441,9 @@ static void cfs_gc_bgworker_main(Datum arg)
14391441

14401442
elog(INFO, "Start CFS garbage collector %d (enabled=%d)", MyProcPid, cfs_state->background_gc_enabled);
14411443

1444+
MemCxt = AllocSetContextCreate(TopMemoryContext, "CFS worker ctx",
1445+
ALLOCSET_DEFAULT_SIZES);
1446+
MemoryContextSwitchTo(MemCxt);
14421447
while (true)
14431448
{
14441449
int timeout = cfs_gc_period;
@@ -1448,6 +1453,7 @@ static void cfs_gc_bgworker_main(Datum arg)
14481453
{
14491454
timeout = CFS_RETRY_TIMEOUT;
14501455
}
1456+
MemoryContextReset(MemCxt);
14511457
if (cfs_gc_stop || --cfs_state->max_iterations <= 0)
14521458
{
14531459
break;

0 commit comments

Comments
 (0)