Fix bug in the test of file descriptor of current WAL file in pg_receivexlog.
authorFujii Masao <fujii@postgresql.org>
Wed, 19 Nov 2014 10:10:04 +0000 (19:10 +0900)
committerFujii Masao <fujii@postgresql.org>
Wed, 19 Nov 2014 10:10:04 +0000 (19:10 +0900)
In pg_receivexlog, in order to check whether the current WAL file is
being opened or not, its file descriptor has to be checked against -1
as an invalid value. But, oops, 7900e94 added the incorrect test
checking the descriptor against 1. This commit fixes that bug.

Back-patch to 9.4 where the bug was added.

Spotted by Magnus Hagander

src/bin/pg_basebackup/receivelog.c

index 1b8a5ad15ce74f269e9082008607c824dbac2f4b..f0f8760e2dbc81d3fcb2e55e333301e85fc4750e 100644 (file)
@@ -1021,7 +1021,7 @@ ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
        if (replyRequested && still_sending)
        {
                if (reportFlushPosition && lastFlushPosition < blockpos &&
-                       walfile != 1)
+                       walfile != -1)
                {
                        /*
                         * If a valid flush location needs to be reported,