bdr: mergme: Don't leak a file descriptor in bdr_count_serialize
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 24 May 2013 18:39:38 +0000 (14:39 -0400)
committerAndres Freund <andres@anarazel.de>
Mon, 27 May 2013 22:52:25 +0000 (00:52 +0200)
contrib/bdr/bdr.c
contrib/bdr/bdr_count.c

index cfa5dbaf5c8b045feb16d1f781d562494f182d00..5fe17474483f9214725484ad7f98c0b395ded518 100644 (file)
@@ -413,7 +413,8 @@ bdr_apply_main(void *main_arg)
         * background process goes away immediately in an emergency.
         */
        rc = WaitLatchOrSocket(&MyProc->procLatch,
-       WL_SOCKET_READABLE | WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
+                              WL_SOCKET_READABLE | WL_LATCH_SET |
+                              WL_TIMEOUT | WL_POSTMASTER_DEATH,
                               fd, 1000L);
 
        ResetLatch(&MyProc->procLatch);
index 08ff8e55173c1f91b18c68b910092928b24e2da0..d3ed3019accd7efd4141a620e32660146cc75054 100644 (file)
@@ -430,6 +430,8 @@ bdr_count_serialize(void)
                        tpath)));
    }
 
+   CloseTransientFile(fd);
+
    /* rename into place */
    if (rename(tpath, path) != 0)
        ereport(ERROR,
@@ -490,13 +492,13 @@ bdr_count_unserialize(void)
 
    if (serial.version != bdr_count_version)
    {
-       elog(NOTICE, "version of stat file changed, zeroing");
+       elog(WARNING, "version of stat file changed, zeroing");
        goto zero_file;
    }
 
    if (serial.nr_slots > bdr_count_nnodes)
    {
-       elog(NOTICE, "stat file has more stats than we need, zeroing");
+       elog(WARNING, "stat file has more stats than we need, zeroing");
        goto zero_file;
    }
 
@@ -516,6 +518,7 @@ out:
        CloseTransientFile(fd);
    LWLockRelease(BdrCountCtl->lock);
    return;
+
 zero_file:
    CloseTransientFile(fd);
    LWLockRelease(BdrCountCtl->lock);