]> git.hungrycats.org Git - bees/commitdiff
hash: test m_fd with !! before the close-time fsync
authorZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 18:50:13 +0000 (14:50 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 18:55:18 +0000 (14:55 -0400)
"m_close_fsync && m_fd" converts the Fd to int, so an empty Fd (-1)
passes the test and bees_fsync(-1) runs on close.  Use "!!m_fd".

The test came in with commit
937af86331421ac58eeef089d5ab1623edc5b1e0
("state: add persistent state config and memory-only hash table").

Assisted-by: Claude-Code:claude-opus-5-5
src/bees-hash.cc

index 6f2a258fe0f83326184b2e7e54417fae0ec3759d..2722f40dc95d47aeff6b74e8d91087e333fbc3a4 100644 (file)
@@ -1262,7 +1262,7 @@ BeesHashTable::stop_wait()
        BEESLOGDEBUG("Waiting for hash_writeback thread");
        m_writeback_thread.join();
 
-       if (m_persistent && m_close_fsync && m_fd) {
+       if (m_persistent && m_close_fsync && !!m_fd) {
                BEESNOTE("fsync hash table on close");
                BEESLOGDEBUG("fsync hash table on close");
                catch_all([&]() { bees_fsync(m_fd); });