diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-12-21 21:49:03 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-12-21 21:51:59 +0200 |
commit | 2ef6c66a2b1ed288a5e4448989d4b85082d22736 (patch) | |
tree | f84874b9ced9bb02ba915c9814c03884b385b84f /src/backend/access/transam/xlog.c | |
parent | cfb64fde7bb93fb44ebcb1f1924faec5b5705af7 (diff) | |
download | postgresql-2ef6c66a2b1ed288a5e4448989d4b85082d22736.tar.gz postgresql-2ef6c66a2b1ed288a5e4448989d4b85082d22736.zip |
Fix file descriptor leak at end of recovery.
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.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 9e459761797..e5dddd4751b 100644 --- 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)))); } /* |