Fix inconsequential fd leak in the new mark_file_as_archived() function.
authorAndres Freund <[email protected]>
Sun, 4 Jan 2015 13:36:21 +0000 (14:36 +0100)
committerAndres Freund <[email protected]>
Sun, 4 Jan 2015 13:36:21 +0000 (14:36 +0100)
As every error in mark_file_as_archived() will lead to a failure of
pg_basebackup the FD leak couldn't ever lead to a real problem.  It
seems better to fix the leak anyway though, rather than silence
Coverity, as the usage of the function might get extended or copied at
some point in the future.

Pointed out by Coverity.

Backpatch to 9.2, like the relevant part of the previous patch.

src/bin/pg_basebackup/receivelog.c

index 123f44526cb2e31333105c692f0b343e4b6e8b05..dc1d7d864845f38d6f2cc074ca6f21774c675d3c 100644 (file)
@@ -81,6 +81,9 @@ mark_file_as_archived(const char *basedir, const char *fname)
    {
        fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"),
                progname, tmppath, strerror(errno));
+
+       close(fd);
+
        return false;
    }