Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e1c76c2

Browse files
committed
Change fd.c so that temp files are closed and deleted at
proc_exit time. I discovered that if the frontend closes the connection when you're inside a transaction block, there is nothing ensuring that temp files go away ... I wonder whether proc_exit ought to try to do an explicit transaction abort?
1 parent 887afac commit e1c76c2

File tree

1 file changed

+9
-5
lines changed
  • src/backend/storage/file

1 file changed

+9
-5
lines changed

src/backend/storage/file/fd.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.49 1999/10/13 15:02:29 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.50 1999/10/17 23:09:02 tgl Exp $
1010
*
1111
* NOTES:
1212
*
@@ -48,6 +48,7 @@
4848
#include "postgres.h"
4949
#include "miscadmin.h"
5050
#include "storage/fd.h"
51+
#include "storage/ipc.h"
5152

5253
/*
5354
* Problem: Postgres does a system(ld...) to do dynamic loading.
@@ -442,6 +443,9 @@ AllocateVfd()
442443
VfdCache->fd = VFD_CLOSED;
443444

444445
SizeVfdCache = 1;
446+
447+
/* register proc-exit call to ensure temp files are dropped at exit */
448+
on_proc_exit(AtEOXact_Files, NULL);
445449
}
446450

447451
if (VfdCache[0].nextFree == 0)
@@ -985,10 +989,10 @@ closeAllVfds()
985989
/*
986990
* AtEOXact_Files
987991
*
988-
* This routine is called during transaction commit or abort (it doesn't
989-
* particularly care which). All still-open temporary-file VFDs are closed,
990-
* which also causes the underlying files to be deleted. Furthermore,
991-
* all "allocated" stdio files are closed.
992+
* This routine is called during transaction commit or abort or backend
993+
* exit (it doesn't particularly care which). All still-open temporary-file
994+
* VFDs are closed, which also causes the underlying files to be deleted.
995+
* Furthermore, all "allocated" stdio files are closed.
992996
*/
993997
void
994998
AtEOXact_Files(void)

0 commit comments

Comments
 (0)