[Pkg-owncloud-commits] [owncloud-client] 117/211: csync_statedb: Finalize the precompiled statements after discovery.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:35 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 7822a6b0009ecf48ec0a6cec1ae4837abf8d650b
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Sat Oct 18 14:18:11 2014 +0200

    csync_statedb: Finalize the precompiled statements after discovery.
    
    As described in http://www.sqlite.org/cvstrac/wiki?p=MultiThreading precompiled
    statements should not be used across thread borders. However, the reconcile
    phase would reuse the statements if defined (it calls statedb function from
    a different thread) so it is saver to finalize them at the end of the
    update run.
---
 csync/src/csync.c         |  7 +++++++
 csync/src/csync_statedb.c | 37 ++++++++++++++++++++++---------------
 csync/src/csync_statedb.h |  6 ++++++
 src/mirall/syncengine.cpp |  1 +
 4 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/csync/src/csync.c b/csync/src/csync.c
index 834bcc1..b4f7a02 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -254,6 +254,13 @@ int csync_update(CSYNC *ctx) {
 
   csync_gettime(&finish);
 
+  /* Finalize the sql precompiled statements after the update run since
+   * it runs in its own thread. Precompiled statements shoult not be shared
+   * across thread borders according to
+   * http://www.sqlite.org/cvstrac/wiki?p=MultiThreading
+   */
+  csync_statedb_finalize_statements(ctx);
+
   CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG,
             "Update detection for remote replica took %.2f seconds "
             "walking %zu files.",
diff --git a/csync/src/csync_statedb.c b/csync/src/csync_statedb.c
index fbc961b..769573d 100644
--- a/csync/src/csync_statedb.c
+++ b/csync/src/csync_statedb.c
@@ -260,21 +260,7 @@ int csync_statedb_close(CSYNC *ctx) {
       return -1;
   }
 
-  /* deallocate query resources */
-  if( ctx->statedb.by_hash_stmt ) {
-      rc = sqlite3_finalize(ctx->statedb.by_hash_stmt);
-      ctx->statedb.by_hash_stmt = NULL;
-  }
-
-  if( ctx->statedb.by_fileid_stmt ) {
-      rc = sqlite3_finalize(ctx->statedb.by_fileid_stmt);
-      ctx->statedb.by_fileid_stmt = NULL;
-  }
-
-  if( ctx->statedb.by_inode_stmt ) {
-      rc = sqlite3_finalize(ctx->statedb.by_inode_stmt);
-      ctx->statedb.by_inode_stmt = NULL;
-  }
+  csync_statedb_finalize_statements(ctx);
 
   sqlite3_close(ctx->statedb.db);
 
@@ -383,6 +369,27 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
   return st;
 }
 
+void   csync_statedb_finalize_statements(CSYNC *ctx) {
+    if( !ctx ) {
+        return;
+    }
+
+    /* deallocate query resources */
+    if( ctx->statedb.by_fileid_stmt ) {
+        sqlite3_finalize(ctx->statedb.by_fileid_stmt);
+        ctx->statedb.by_fileid_stmt = NULL;
+    }
+    if( ctx->statedb.by_hash_stmt ) {
+        sqlite3_finalize(ctx->statedb.by_hash_stmt);
+        ctx->statedb.by_hash_stmt = NULL;
+    }
+    if( ctx->statedb.by_inode_stmt) {
+        sqlite3_finalize(ctx->statedb.by_inode_stmt);
+        ctx->statedb.by_inode_stmt = NULL;
+    }
+}
+
+
 csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
                                                       const char *file_id ) {
     csync_file_stat_t *st = NULL;
diff --git a/csync/src/csync_statedb.h b/csync/src/csync_statedb.h
index d38ae8c..92dbc18 100644
--- a/csync/src/csync_statedb.h
+++ b/csync/src/csync_statedb.h
@@ -98,6 +98,12 @@ int csync_statedb_get_below_path(CSYNC *ctx, const char *path);
  */
 c_strlist_t *csync_statedb_query(sqlite3 *db, const char *statement);
 
+/**
+ * @brief csync_statedb_finalize_statements - Clear prepared statements
+ * @param ctx The csync context
+ */
+void csync_statedb_finalize_statements(CSYNC *ctx);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index c0312e4..1458d3d 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -1074,6 +1074,7 @@ void SyncEngine::setSelectiveSyncBlackList(const QStringList& list)
 
 bool SyncEngine::estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s)
 {
+    Q_UNUSED(t);
     Q_FOREACH(const SyncFileItem &item, _syncedItems) {
         //qDebug() << Q_FUNC_INFO << fn << item._file << fn.startsWith(item._file) << item._file.startsWith(fn);
         if (item._file.startsWith(fn)) {

-- 
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