diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-01-12 21:54:01 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-01-12 21:54:01 +0000 |
commit | 6162432de9fb023b710c171f196e27b910e45fa7 (patch) | |
tree | 51bba2e60ca2d3497b365b23edd52d52574faae2 /src/backend/storage/file/fd.c | |
parent | be8477bc3718a05b02dd7e9f8236c16394f9a027 (diff) | |
download | postgresql-6162432de9fb023b710c171f196e27b910e45fa7.tar.gz postgresql-6162432de9fb023b710c171f196e27b910e45fa7.zip |
Add more critical-section calls: all code sections that hold spinlocks
are now critical sections, so as to ensure die() won't interrupt us while
we are munging shared-memory data structures. Avoid insecure intermediate
states in some code that proc_exit will call, like palloc/pfree. Rename
START/END_CRIT_CODE to START/END_CRIT_SECTION, since that seems to be
what people tend to call them anyway, and make them be called with () like
a function call, in hopes of not confusing pg_indent.
I doubt that this is sufficient to make SIGTERM safe anywhere; there's
just too much code that could get invoked during proc_exit().
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 3cff7932129..9ad40849eb3 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.69 2000/12/08 22:21:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.70 2001/01/12 21:53:58 tgl Exp $ * * NOTES: * @@ -770,7 +770,11 @@ FileClose(File file) * Delete the file if it was temporary */ if (VfdCache[file].fdstate & FD_TEMPORARY) + { + /* reset flag so that die() interrupt won't cause problems */ + VfdCache[file].fdstate &= ~FD_TEMPORARY; unlink(VfdCache[file].fileName); + } /* * Return the Vfd slot to the free list @@ -1049,7 +1053,8 @@ AllocateFile(char *name, char *mode) TryAgain: if ((file = fopen(name, mode)) != NULL) { - allocatedFiles[numAllocatedFiles++] = file; + allocatedFiles[numAllocatedFiles] = file; + numAllocatedFiles++; return file; } @@ -1080,7 +1085,8 @@ FreeFile(FILE *file) { if (allocatedFiles[i] == file) { - allocatedFiles[i] = allocatedFiles[--numAllocatedFiles]; + numAllocatedFiles--; + allocatedFiles[i] = allocatedFiles[numAllocatedFiles]; break; } } |