[tracker] tracker-fts: Make the property list per-thread data
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-fts: Make the property list per-thread data
- Date: Sun, 7 Dec 2014 22:14:16 +0000 (UTC)
commit a105aacd5531d0d5e7d2af7c12c156c3375135af
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Nov 30 12:34:31 2014 +0100
tracker-fts: Make the property list per-thread data
This is global memory, and shared across threads, which doesn't play well
when (un)initializing it, as multiple simultaneous accesses can occur.
src/libtracker-data/tracker-db-interface-sqlite.c | 4 ----
src/libtracker-fts/tracker-fts.c | 20 ++++++--------------
src/libtracker-fts/tracker-fts.h | 1 -
3 files changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 3490c42..85dba3a 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1333,10 +1333,6 @@ tracker_db_interface_sqlite_finalize (GObject *object)
db_interface = TRACKER_DB_INTERFACE (object);
-#if HAVE_TRACKER_FTS
- tracker_fts_shutdown_db (db_interface->db);
-#endif
-
close_database (db_interface);
g_free (db_interface->fts_insert_str);
diff --git a/src/libtracker-fts/tracker-fts.c b/src/libtracker-fts/tracker-fts.c
index e8fb4c1..dc47bae 100644
--- a/src/libtracker-fts/tracker-fts.c
+++ b/src/libtracker-fts/tracker-fts.c
@@ -33,8 +33,8 @@ static gsize module_initialized = 0;
#endif
-static gchar **property_names = NULL;
static gboolean initialized = FALSE;
+static GPrivate property_names_key = G_PRIVATE_INIT ((GDestroyNotify) g_strfreev);
gboolean
@@ -209,6 +209,9 @@ function_property_names (sqlite3_context *context,
int argc,
sqlite3_value *argv[])
{
+ gchar **property_names;
+
+ property_names = g_private_get (&property_names_key);
sqlite3_result_blob (context, property_names, sizeof (property_names), NULL);
}
@@ -236,6 +239,7 @@ tracker_fts_init_db (sqlite3 *db,
GHashTableIter iter;
GList *columns;
GList *table_columns;
+ gchar **property_names;
g_return_val_if_fail (initialized == TRUE, FALSE);
@@ -251,6 +255,7 @@ tracker_fts_init_db (sqlite3 *db,
}
property_names = tracker_glist_to_string_list (columns);
+ g_private_replace (&property_names_key, property_names);
g_list_free (columns);
/* Register functions with the database, including one to get property names */
@@ -260,19 +265,6 @@ tracker_fts_init_db (sqlite3 *db,
}
gboolean
-tracker_fts_shutdown_db (sqlite3 *db)
-{
- g_return_val_if_fail (initialized == TRUE, FALSE);
-
- if (property_names != NULL) {
- g_strfreev (property_names);
- property_names = NULL;
- }
-
- return TRUE;
-}
-
-gboolean
tracker_fts_create_table (sqlite3 *db,
gchar *table_name,
GHashTable *tables,
diff --git a/src/libtracker-fts/tracker-fts.h b/src/libtracker-fts/tracker-fts.h
index df76a37..fb4e804 100644
--- a/src/libtracker-fts/tracker-fts.h
+++ b/src/libtracker-fts/tracker-fts.h
@@ -32,7 +32,6 @@ gboolean tracker_fts_init (void);
gboolean tracker_fts_shutdown (void);
gboolean tracker_fts_init_db (sqlite3 *db,
GHashTable *tables);
-gboolean tracker_fts_shutdown_db (sqlite3 *db);
gboolean tracker_fts_create_table (sqlite3 *db,
gchar *table_name,
GHashTable *tables,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]