]> granicus.if.org Git - postgresql/commitdiff
Fix file descriptor leak at end of recovery.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sun, 21 Dec 2014 19:49:03 +0000 (21:49 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sun, 21 Dec 2014 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.

src/backend/access/transam/xlog.c

index 9e45976179788c62f9461efb1932c5c0874e7ad6..e5dddd4751b2edd9f4e4f579ce609b7abaa22775 100644 (file)
@@ -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))));
        }
 
        /*