diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-08 03:12:16 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-08 03:12:16 +0000 |
| commit | 7117cd3a77afcf76b6488bd3e1d06f3160595027 (patch) | |
| tree | 0d2feadbd044021b3cc8b5a89a68a6e720bb0afb /src/backend/storage/file/fd.c | |
| parent | 89439b8c4fabf8e882f55c87979512af081f370b (diff) | |
| download | postgresql-7117cd3a77afcf76b6488bd3e1d06f3160595027.tar.gz | |
Cause ShutdownPostgres to do a normal transaction abort during backend
exit, instead of trying to take shortcuts. Introduce some additional
shutdown callback routines to eliminate kluges like having ProcKill
be responsible for shutting down the buffer manager. Ensure that the
order of operations during shutdown is predictable and what you would
expect given the module layering.
Diffstat (limited to 'src/backend/storage/file/fd.c')
| -rw-r--r-- | src/backend/storage/file/fd.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 2fb8165d2f..11ca95e833 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 - * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.119 2005/08/07 18:47:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.120 2005/08/08 03:11:49 tgl Exp $ * * NOTES: * @@ -297,6 +297,33 @@ pg_fdatasync(int fd) } /* + * InitFileAccess --- initialize this module during backend startup + * + * This is called during either normal or standalone backend start. + * It is *not* called in the postmaster. + */ +void +InitFileAccess(void) +{ + Assert(SizeVfdCache == 0); /* call me only once */ + + /* initialize cache header entry */ + VfdCache = (Vfd *) malloc(sizeof(Vfd)); + if (VfdCache == NULL) + ereport(FATAL, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("out of memory"))); + + MemSet((char *) &(VfdCache[0]), 0, sizeof(Vfd)); + VfdCache->fd = VFD_CLOSED; + + SizeVfdCache = 1; + + /* register proc-exit hook to ensure temp files are dropped at exit */ + on_proc_exit(AtProcExit_Files, 0); +} + +/* * count_usable_fds --- count how many FDs the system will let us open, * and estimate how many are already open. * @@ -622,25 +649,7 @@ AllocateVfd(void) DO_DB(elog(LOG, "AllocateVfd. Size %d", SizeVfdCache)); - if (SizeVfdCache == 0) - { - /* initialize header entry first time through */ - VfdCache = (Vfd *) malloc(sizeof(Vfd)); - if (VfdCache == NULL) - ereport(FATAL, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - MemSet((char *) &(VfdCache[0]), 0, sizeof(Vfd)); - VfdCache->fd = VFD_CLOSED; - - SizeVfdCache = 1; - - /* - * register proc-exit call to ensure temp files are dropped at - * exit - */ - on_proc_exit(AtProcExit_Files, 0); - } + Assert(SizeVfdCache > 0); /* InitFileAccess not called? */ if (VfdCache[0].nextFree == 0) { |
