mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user