mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +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:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.119 2004/01/08 06:01:21 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.120 2004/01/26 22:35:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -622,7 +622,16 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write lock file \"%s\": %m", filename)));
|
||||
}
|
||||
close(fd);
|
||||
if (close(fd))
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
unlink(filename);
|
||||
errno = save_errno;
|
||||
ereport(FATAL,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write lock file \"%s\": %m", filename)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Arrange for automatic removal of lockfile at proc_exit.
|
||||
@ -776,7 +785,13 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
if (close(fd))
|
||||
{
|
||||
ereport(LOG,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to file \"%s\": %m",
|
||||
directoryLockFile)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user