git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfb64fd)
Fix file descriptor leak at end of recovery.
2014年12月21日 19:49:03 +0000 (21:49 +0200)
2014年12月21日 19:51:59 +0000 (21:51 +0200)
XLogFileInit() returns a file descriptor, which needs to be closed. The leak
was short-lived, since the startup process exits shortly afterwards, but it
was clearly a bug, nevertheless.

Per Coverity report.


diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 9e45976179788c62f9461efb1932c5c0874e7ad6..e5dddd4751b2edd9f4e4f579ce609b7abaa22775 100644 (file)
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5043,8 +5043,15 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
else
{
bool use_existent = true;
+ int fd;
- XLogFileInit(startLogSegNo, &use_existent, true);
+ fd = XLogFileInit(startLogSegNo, &use_existent, true);
+
+ if (close(fd))
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not close log file %s: %m",
+ XLogFileNameP(ThisTimeLineID, startLogSegNo))));
}
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /