diff options
author | jasplin <qt-info@nokia.com> | 2009-12-16 08:38:50 +0100 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2009-12-16 08:38:50 +0100 |
commit | a95cf50cab0b85d33f315064ecd2559bb78c818f (patch) | |
tree | 0fac304c1c4401028afc40890b50343656b3e313 /src/bmserver | |
parent | 36a9eccc0ad0c657b686931c2d36a84b6a43cc2b (diff) |
Added disksync=off option to bmserver.
The bmserver now checks if the BMDISKWRITESYNC
environment variable is set to 'off', in which
case disk writes are no longer synchronous. This
speeds up database insertions and updates, but
the database may be corrupted if the OS crashes
in the middle of a write operation.
Diffstat (limited to 'src/bmserver')
-rw-r--r-- | src/bmserver/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bmserver/main.cpp b/src/bmserver/main.cpp index 3f22b2f..38a036b 100644 --- a/src/bmserver/main.cpp +++ b/src/bmserver/main.cpp @@ -144,6 +144,22 @@ static bool initDatabase(const QString &dbfile, QString *error) return true; } +static void prepare(QSqlDatabase &db) +{ + QProcessEnvironment sysenv = QProcessEnvironment::systemEnvironment(); + + if (sysenv.value("BMDISKWRITESYNC") == "off") { + qDebug() << "sync off!"; + // Disable synchrounous disk writes ... + QSqlQuery query(db); + bool ok; + ok = query.exec("PRAGMA synchronous=off;"); + Q_ASSERT(ok); + } else { + qDebug() << "sync default ..."; + } +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -192,6 +208,8 @@ int main(int argc, char *argv[]) return 1; } + prepare(db); + Q_ASSERT(db.isValid()); BMServer server (serverPort, &db); |