[tracker/dont-interrupt-create-statement] squash
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dont-interrupt-create-statement] squash
- Date: Mon, 24 May 2010 14:13:08 +0000 (UTC)
commit 0f62cec663504d7ced2150915cc1a8cbe90200db
Author: Philip Van Hoof <philip codeminded be>
Date: Mon May 24 16:11:35 2010 +0200
squash
src/libtracker-db/tracker-db-interface-sqlite.c | 35 +++++++++++++++-------
1 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index ba951a6..61ee78f 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -54,6 +54,16 @@
#define TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE_O(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_CURSOR_SQLITE, TrackerDBCursorSqlitePrivate))
#define TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE(o) (((TrackerDBCursorSqlite *)o)->priv)
+/* I have no idea what the 'exact' meaning of nOps is in this API call, but
+ * experimentally I noticed that 9 is a relatively good value. It has to do
+ * with the frequency of check_interrupt being called. Presumably the amount
+ * of SQLite 'ops', or something. The documentation of SQLite isn't very
+ * enlightening about this either. I guess the higher you can make it, the
+ * fewer overhead you induce. I fear, though, that it might depend on the
+ * speed of the platform whether or not this value is actually a good value. */
+
+#define SQLITE_PROGRESS_HANDLER_NOPS_VALUE 9
+
typedef struct TrackerDBStatementSqlitePrivate TrackerDBStatementSqlitePrivate;
typedef struct TrackerDBCursorSqlitePrivate TrackerDBCursorSqlitePrivate;
typedef struct TrackerDBCursorSqlite TrackerDBCursorSqlite;
@@ -81,7 +91,7 @@ struct TrackerDBInterfaceSqlitePrivate {
guint in_transaction : 1;
guint ro : 1;
guint fts_initialized : 1;
- GMutex *interrupt_mutex;
+ GStaticRecMutex interrupt_mutex;
gboolean interrupt;
};
@@ -495,12 +505,12 @@ check_interrupt (void *user_data)
TrackerDBInterfaceSqlitePrivate *priv = user_data;
gint ret = 0;
- g_mutex_lock (priv->interrupt_mutex);
+ g_static_rec_mutex_lock (&priv->interrupt_mutex);
if (priv->interrupt) {
ret = 1;
priv->interrupt = FALSE;
}
- g_mutex_unlock (priv->interrupt_mutex);
+ g_static_rec_mutex_unlock (&priv->interrupt_mutex);
return ret;
}
@@ -510,7 +520,7 @@ open_database (TrackerDBInterfaceSqlitePrivate *priv)
{
g_assert (priv->filename != NULL);
- priv->interrupt_mutex = g_mutex_new ();
+ g_static_rec_mutex_init (&priv->interrupt_mutex);
if (!priv->ro) {
if (sqlite3_open (priv->filename, &priv->db) != SQLITE_OK) {
@@ -526,7 +536,8 @@ open_database (TrackerDBInterfaceSqlitePrivate *priv)
}
}
- sqlite3_progress_handler (priv->db, 0, check_interrupt, priv);
+ sqlite3_progress_handler (priv->db, SQLITE_PROGRESS_HANDLER_NOPS_VALUE,
+ check_interrupt, priv);
sqlite3_create_function (priv->db, "SparqlRegex", 3, SQLITE_ANY,
priv, &function_sparql_regex,
@@ -647,6 +658,9 @@ close_database (GObject *object,
rc = sqlite3_close (priv->db);
g_warn_if_fail (rc == SQLITE_OK);
+
+ /* Verified that this is how you're supposed to use it (I know it looks strange) */
+ g_static_rec_mutex_free (&priv->interrupt_mutex);
}
void
@@ -672,7 +686,6 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_message ("Closed sqlite3 database:'%s'", priv->filename);
- g_mutex_free (priv->interrupt_mutex);
g_free (priv->filename);
@@ -793,17 +806,17 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface *db_interface,
g_debug ("Preparing query: '%s'", query);
- g_mutex_lock (priv->interrupt_mutex);
+ g_static_rec_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));
- g_mutex_unlock (priv->interrupt_mutex);
+ g_static_rec_mutex_unlock (&priv->interrupt_mutex);
return NULL;
}
- g_mutex_unlock (priv->interrupt_mutex);
+ g_static_rec_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);
@@ -939,9 +952,9 @@ tracker_db_interface_sqlite_interrupt (TrackerDBInterface *iface)
priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (iface);
- g_mutex_lock (priv->interrupt_mutex);
+ g_static_rec_mutex_lock (&priv->interrupt_mutex);
priv->interrupt = TRUE;
- g_mutex_unlock (priv->interrupt_mutex);
+ g_static_rec_mutex_unlock (&priv->interrupt_mutex);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]