~aleteoryx/muditaos

982e1b8d5012b7731420a8314de83f78012545a7 — Lucjan Bryndza 5 years ago 7d4452f
[EGD-6105] Fix database synchronization

std::fflush used in the sqlite3vfs sync only the stdio buffer
but without sync internal filesystem. Additional fsync call fix
this issue.
1 files changed, 4 insertions(+), 4 deletions(-)

M module-db/Database/sqlite3vfs.cpp
M module-db/Database/sqlite3vfs.cpp => module-db/Database/sqlite3vfs.cpp +4 -4
@@ 128,7 128,6 @@
#include <Utils.hpp>
#include <dirent.h>

//#include <log/log.hpp> //left for future debug

/*
 ** Size of the write buffer used by journal files in bytes.


@@ 433,9 432,10 @@ static int ecophoneSync(sqlite3_file *pFile, int flags)
    if (rc != SQLITE_OK) {
        return rc;
    }

    // rc = fflush(p->fd);  //FF doesn't have this function
    rc = SQLITE_OK;
    rc = fileno(p->fd);
    if (rc > 0) {
        rc = fsync(rc);
    }
    return (rc == 0 ? SQLITE_OK : SQLITE_IOERR_FSYNC);
}