diff options
-rw-r--r-- | csync/src/csync.c | 7 | ||||
-rw-r--r-- | csync/src/csync_statedb.c | 37 | ||||
-rw-r--r-- | csync/src/csync_statedb.h | 6 | ||||
-rw-r--r-- | 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 834bcc18c..b4f7a02c4 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 fbc961b03..769573de5 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 d38ae8cfa..92dbc18e5 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 c0312e46e..1458d3dfe 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)) { |