[tracker/dont-interrupt-create-statement] Make the lock smaller, squash
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dont-interrupt-create-statement] Make the lock smaller, squash
- Date: Mon, 24 May 2010 11:29:19 +0000 (UTC)
commit cb3ed0410a33934c378ab1f1faeec817913b7356
Author: Philip Van Hoof <philip codeminded be>
Date: Mon May 24 13:27:56 2010 +0200
Make the lock smaller, squash
src/libtracker-db/tracker-db-interface-sqlite.c | 22 +++++-----------------
1 files changed, 5 insertions(+), 17 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 2c50fb3..0291541 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -765,21 +765,9 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface *db_interface,
{
TrackerDBInterfaceSqlitePrivate *priv;
TrackerDBStatementSqlite *stmt;
- TrackerDBStatement *ret;
priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
- /* This mutex prevents an interrupt from happening while we are preparing a
- * query. We don't have any interrupt handling for create_statement at any
- * place in the code, it would be a massive undertaking to support handling
- * interrupting while preparing a query. Which is why we block the interrupt
- * until after we prepared the query. Because prepared statements end up in
- * a cache wont it happen often that this lock is needed. But still, we do
- * need to protect against sqlite3_interrupt while sqlite3_prepare_v2 takes
- * place, as the 'return NULL' isn't handled anywhere in the code. */
-
- g_mutex_lock (priv->interrupt_mutex);
-
stmt = g_hash_table_lookup (priv->dynamic_statements, query);
if (!stmt) {
@@ -787,6 +775,8 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface *db_interface,
g_debug ("Preparing query: '%s'", query);
+ g_mutex_lock (priv->interrupt_mutex);
+
if (sqlite3_prepare_v2 (priv->db, query, -1, &sqlite_stmt, NULL) != SQLITE_OK) {
g_critical ("Unable to prepare query '%s': %s", query, sqlite3_errmsg (priv->db));
@@ -795,17 +785,15 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface *db_interface,
return NULL;
}
+ g_mutex_unlock (priv->interrupt_mutex);
+
stmt = tracker_db_statement_sqlite_new (TRACKER_DB_INTERFACE_SQLITE (db_interface), sqlite_stmt);
g_hash_table_insert (priv->dynamic_statements, g_strdup (query), stmt);
} else {
tracker_db_statement_sqlite_reset (stmt);
}
- ret = g_object_ref (stmt);
-
- g_mutex_unlock (priv->interrupt_mutex);
-
- return ret;
+ return g_object_ref (stmt);
}
static TrackerDBResultSet *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]