[tracker/rss-enclosures] tracker-fts: Make fulltext_vtab to be per-thread data.
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] tracker-fts: Make fulltext_vtab to be per-thread data.
- Date: Mon, 3 May 2010 00:37:21 +0000 (UTC)
commit dbc77efe0930cbe17fd4333bcee21b7d8407ccb2
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Apr 14 18:16:19 2010 +0200
tracker-fts: Make fulltext_vtab to be per-thread data.
src/libtracker-fts/tracker-fts.c | 58 +++++++++++++++++++++++++------------
1 files changed, 39 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-fts/tracker-fts.c b/src/libtracker-fts/tracker-fts.c
index bb46d72..5d7e397 100644
--- a/src/libtracker-fts/tracker-fts.c
+++ b/src/libtracker-fts/tracker-fts.c
@@ -2128,7 +2128,7 @@ static int sql_prepare(sqlite3 *db, const char *zDb, const char *zName,
/* Forward reference */
typedef struct fulltext_vtab fulltext_vtab;
-static fulltext_vtab *tracker_fts_vtab = NULL;
+static GStaticPrivate tracker_fts_vtab_key = G_STATIC_PRIVATE_INIT;
static TrackerFtsMapFunc map_function = NULL;
/* A single term in a query is represented by an instances of
@@ -3311,6 +3311,12 @@ static int constructVtab(
TrackerLanguage *language;
int min_len, max_len;
+ v = g_static_private_get (&tracker_fts_vtab_key);
+
+ if(v) {
+ return SQLITE_OK;
+ }
+
v = (fulltext_vtab *) sqlite3_malloc(sizeof(fulltext_vtab));
if( v==0 ) return SQLITE_NOMEM;
CLEAR(v);
@@ -3375,7 +3381,7 @@ static int constructVtab(
FTSTRACE(("FTS3 Connect %p\n", v));
- tracker_fts_vtab = v;
+ g_static_private_set (&tracker_fts_vtab_key, v, NULL);
return SQLITE_OK;
}
@@ -3483,7 +3489,7 @@ static int fulltextCreate(sqlite3 *db, void *pAux,
/* Decide how to handle an SQL query. */
static int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
int i;
int iCons = -1; /* Index of constraint to use */
FTSTRACE(("FTS3 BestIndex\n"));
@@ -3526,7 +3532,7 @@ static int fulltextDisconnect(sqlite3_vtab *pVTab){
}
static int fulltextDestroy(sqlite3_vtab *pVTab){
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
int rc;
FTSTRACE(("FTS3 Destroy %p\n", pVTab));
@@ -4131,7 +4137,7 @@ static int fulltextClose(sqlite3_vtab_cursor *pCursor){
static int fulltextNext(sqlite3_vtab_cursor *pCursor){
fulltext_cursor *c = (fulltext_cursor *) pCursor;
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
int rc;
PLReader plReader;
gboolean first_pos = TRUE;
@@ -4662,7 +4668,7 @@ static int fulltextFilter(
int argc, sqlite3_value **argv /* Arguments for the indexing scheme */
){
fulltext_cursor *c = (fulltext_cursor *) pCursor;
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
int rc;
int i;
StringBuffer sb;
@@ -4743,7 +4749,7 @@ static int fulltextEof(sqlite3_vtab_cursor *pCursor){
static int fulltextColumn(sqlite3_vtab_cursor *pCursor,
sqlite3_context *pContext, int idxCol){
fulltext_cursor *c = (fulltext_cursor *) pCursor;
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
#ifdef STORE_CATEGORY
if (idxCol == 0) {
@@ -6915,12 +6921,14 @@ static int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,
#endif
static int fulltextSync(sqlite3_vtab *pVtab){
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
FTSTRACE(("FTS3 xSync()\n"));
- return flushPendingTerms(tracker_fts_vtab);
+ return flushPendingTerms(v);
}
static int fulltextBegin(sqlite3_vtab *pVtab){
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
FTSTRACE(("FTS3 xBegin()\n"));
/* Any buffered updates should have been cleared by the previous
@@ -6931,7 +6939,7 @@ static int fulltextBegin(sqlite3_vtab *pVtab){
}
static int fulltextCommit(sqlite3_vtab *pVtab){
- fulltext_vtab *v = tracker_fts_vtab;
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
FTSTRACE(("FTS3 xCommit()\n"));
/* Buffered updates should have been cleared by fulltextSync(). */
@@ -6940,8 +6948,9 @@ static int fulltextCommit(sqlite3_vtab *pVtab){
}
static int fulltextRollback(sqlite3_vtab *pVtab){
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
FTSTRACE(("FTS3 xRollback()\n"));
- return clearPendingTerms(tracker_fts_vtab);
+ return clearPendingTerms(v);
}
/*
@@ -7733,7 +7742,7 @@ static int fulltextRename(
sqlite3_vtab *pVtab,
const char *zName
){
- fulltext_vtab *p = tracker_fts_vtab;
+ fulltext_vtab *p = g_static_private_get (&tracker_fts_vtab_key);
int rc = SQLITE_NOMEM;
char *zSql = sqlite3_mprintf(
"ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';"
@@ -7819,7 +7828,11 @@ int tracker_fts_init(sqlite3 *db, int create){
}
void tracker_fts_shutdown (void){
- fulltext_vtab_destroy(tracker_fts_vtab);
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
+ fulltext_vtab_destroy(v);
+
+ g_static_private_set (&tracker_fts_vtab_key, NULL, NULL);
}
void tracker_fts_set_map_function(TrackerFtsMapFunc map_func){
@@ -7827,21 +7840,28 @@ void tracker_fts_set_map_function(TrackerFtsMapFunc map_func){
}
int tracker_fts_update_init(int id){
- return initPendingTerms(tracker_fts_vtab, id);
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
+ return initPendingTerms(v, id);
}
int tracker_fts_update_text(int id, int column_id,
const char *text, gboolean limit_word_length){
- return buildTerms(tracker_fts_vtab, id, text,
- column_id, limit_word_length);
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
+ return buildTerms(v, id, text, column_id, limit_word_length);
}
void tracker_fts_update_commit(void){
- fulltextSync((sqlite3_vtab *) tracker_fts_vtab);
- fulltextCommit((sqlite3_vtab *) tracker_fts_vtab);
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
+ fulltextSync((sqlite3_vtab *) v);
+ fulltextCommit((sqlite3_vtab *) v);
}
void tracker_fts_update_rollback(void){
- fulltextRollback((sqlite3_vtab *) tracker_fts_vtab);
+ fulltext_vtab *v = g_static_private_get (&tracker_fts_vtab_key);
+
+ fulltextRollback((sqlite3_vtab *) v);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]