aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/file/fd.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-26 22:35:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-26 22:35:32 +0000
commitc77f363384c3f4a6bbc73f501d2459e94382a30b (patch)
treec722b460526c687c1ec9c546aed71b52fbcb3cc4 /src/backend/storage/file/fd.c
parente0707cbae9cb5360cd044231fda921fffe8095c5 (diff)
downloadpostgresql-c77f363384c3f4a6bbc73f501d2459e94382a30b.tar.gz
postgresql-c77f363384c3f4a6bbc73f501d2459e94382a30b.zip
Ensure that close() and fclose() are checked for errors, at least in
cases involving writes. Per recent discussion about the possibility of close-time failures on some filesystems. There is a TODO item for this, too.
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r--src/backend/storage/file/fd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 4875b7f2bcf..df7d58d7940 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.105 2003/12/20 17:31:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.106 2004/01/26 22:35:32 tgl Exp $
*
* NOTES:
*
@@ -397,7 +397,7 @@ LruDelete(File file)
/* close the file */
if (close(vfdP->fd))
- elog(LOG, "failed to close \"%s\": %m",
+ elog(ERROR, "failed to close \"%s\": %m",
vfdP->fileName);
--nfile;
@@ -842,7 +842,7 @@ FileClose(File file)
/* close the file */
if (close(vfdP->fd))
- elog(LOG, "failed to close \"%s\": %m",
+ elog(ERROR, "failed to close \"%s\": %m",
vfdP->fileName);
--nfile;
@@ -1069,7 +1069,13 @@ TryAgain:
return NULL;
}
-void
+/*
+ * Close a file returned by AllocateFile.
+ *
+ * Note we do not check fclose's return value --- it is up to the caller
+ * to handle close errors.
+ */
+int
FreeFile(FILE *file)
{
int i;
@@ -1089,7 +1095,7 @@ FreeFile(FILE *file)
if (i < 0)
elog(WARNING, "file passed to FreeFile was not obtained from AllocateFile");
- fclose(file);
+ return fclose(file);
}
/*