[Pkg-owncloud-commits] [owncloud-client] 135/211: SocketApi: Properly manage the database connections.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:37 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 26f068bcabcd453ec4e1611bf5ed58309164134b
Author: Klaas Freitag <freitag at owncloud.com>
Date: Mon Oct 20 17:31:00 2014 +0200
SocketApi: Properly manage the database connections.
Removed the fishy closeDb() method of SqlQuery again.
---
src/mirall/ownsql.cpp | 7 -------
src/mirall/ownsql.h | 3 ---
src/mirall/socketapi.cpp | 12 ++++++++++--
src/mirall/socketapi.h | 1 +
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/mirall/ownsql.cpp b/src/mirall/ownsql.cpp
index a563a7c..c87fb05 100644
--- a/src/mirall/ownsql.cpp
+++ b/src/mirall/ownsql.cpp
@@ -286,11 +286,4 @@ void SqlQuery::reset()
SQLITE_DO(sqlite3_reset(_stmt));
}
-void SqlQuery::closeDb()
-{
- if( _db) {
- SQLITE_DO(sqlite3_close(_db) );
- _db = 0;
- }
-}
} // namespace Mirall
diff --git a/src/mirall/ownsql.h b/src/mirall/ownsql.h
index ee40943..eacd5b3 100644
--- a/src/mirall/ownsql.h
+++ b/src/mirall/ownsql.h
@@ -57,9 +57,6 @@ public:
quint64 int64Value(int index);
QByteArray baValue(int index);
- // use only in rare cases, invalidates the internal db object.
- void closeDb();
-
bool isSelect();
bool isPragma();
bool exec();
diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp
index c5e3c93..bf61a49 100644
--- a/src/mirall/socketapi.cpp
+++ b/src/mirall/socketapi.cpp
@@ -229,10 +229,16 @@ void SocketApi::slotUnregisterPath( const QString& alias )
SqlQuery *h = _dbQueries[f];
if( h ) {
h->finish();
- h->closeDb();
}
_dbQueries.remove(f);
}
+ if( _openDbs.contains(f) ) {
+ SqlDatabase *db = _openDbs[f];
+ if( db ) {
+ db->close();
+ }
+ _openDbs.remove(f);
+ }
}
}
@@ -393,7 +399,9 @@ SqlQuery* SocketApi::getSqlQuery( Folder *folder )
if( fi.exists() ) {
SqlDatabase *db = new SqlDatabase;
- if( db->open(dbFileName) ) {
+ if( db && db->open(dbFileName) ) {
+ _openDbs.insert(folder, db);
+
SqlQuery *query = new SqlQuery(*db);
rc = query->prepare(sql);
diff --git a/src/mirall/socketapi.h b/src/mirall/socketapi.h
index a46b567..24460bd 100644
--- a/src/mirall/socketapi.h
+++ b/src/mirall/socketapi.h
@@ -86,6 +86,7 @@ private:
QList<SocketType*> _listeners;
c_strlist_t *_excludes;
QHash<Folder*, SqlQuery*> _dbQueries;
+ QHash<Folder*, SqlDatabase*> _openDbs;
};
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list