From 610a9e8f319eafcbcf193e4b90119a6f89d0caf9 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Thu, 16 Feb 2017 11:12:31 +0100 Subject: SQLite: Disable mutex on connections By default SQLite opens DB in Serialized mode, allowing connections to be used from several threads simultaneously: https://www.sqlite.org/threadsafe.html According to Qt documentation, database can only be used from one thread. This change opens sqlite dabases in "Multi-thread" mode, so that one does not pay for useless mutex locking for each DB access Change-Id: Ife61f1a648d74c91d3b27a2ce0059d052ccc62b2 Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira --- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/sqldrivers/sqlite') diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index c2feaeea56..8f336fd173 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -700,6 +700,8 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c if (openUriOption) openMode |= SQLITE_OPEN_URI; + openMode |= SQLITE_OPEN_NOMUTEX; + if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) { sqlite3_busy_timeout(d->access, timeOut); setOpen(true); -- cgit v1.2.3