Commit b368da7d authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Carlos Garnacho

Prevent against cur_cache being possibly NULL. Call check_finished() in

2009-03-04  Carlos Garnacho  <carlos@imendio.com>

        * src/libtracker-db/tracker-db-index.c (index_flush_item)
        (tracker_db_index_flush): Prevent against cur_cache being possibly
        NULL.
        * src/tracker-indexer/tracker-indexer.c (check_finished)
        (check_stopped): Call check_finished() in any case, not just after the
        cache has been flushed.

svn path=/trunk/; revision=3015
parent 08102d62
2009-03-04 Carlos Garnacho <carlos@imendio.com>
* src/libtracker-db/tracker-db-index.c (index_flush_item)
(tracker_db_index_flush): Prevent against cur_cache being possibly
NULL.
* src/tracker-indexer/tracker-indexer.c (check_finished)
(check_stopped): Call check_finished() in any case, not just after the
cache has been flushed.
2009-03-03 Mikael Ottela <mikael.ottela@ixonos.com>
* src/tracker-extract/tracker-extract-mp3.c: Fixed frame size
......
......@@ -784,7 +784,7 @@ index_flush_item (gpointer user_data)
return FALSE;
}
if (g_hash_table_size (priv->cache_layers->data) > 0) {
if (priv->cache_layers && g_hash_table_size (priv->cache_layers->data) > 0) {
GTimer *timer;
timer = g_timer_new ();
......@@ -807,13 +807,15 @@ index_flush_item (gpointer user_data)
} else {
GList *link;
/* Current cache being flushed is already empty, proceed with the next one */
link = priv->cache_layers;
priv->cache_layers = g_list_remove_link (priv->cache_layers, link);
g_hash_table_destroy (link->data);
g_list_free_1 (link);
if (priv->cache_layers) {
/* Current cache being flushed is already empty, proceed with the next one */
link = priv->cache_layers;
priv->cache_layers = g_list_remove_link (priv->cache_layers, link);
g_hash_table_destroy (link->data);
g_list_free_1 (link);
update_overloaded_status (indez);
update_overloaded_status (indez);
}
if (priv->cache_layers) {
g_debug ("Flushing next batch (%d words) to index...",
......@@ -984,28 +986,24 @@ tracker_db_index_flush (TrackerDBIndex *indez)
priv = TRACKER_DB_INDEX_GET_PRIVATE (indez);
#if 0
if (!priv->cur_cache || g_hash_table_size (priv->cur_cache) == 0) {
/* Nothing to flush */
return;
}
#endif
if (!priv->in_flush) {
set_in_flush (indez, TRUE);
}
g_debug ("Pushing a new batch (%d words) to be flushed to index...",
g_hash_table_size (priv->cur_cache));
if (priv->cur_cache && g_hash_table_size (priv->cur_cache) > 0) {
g_debug ("Pushing a new batch (%d words) to be flushed to index...",
g_hash_table_size (priv->cur_cache));
/* Put current cache into the queue and create a
* new one for keeping appending words
*/
priv->cache_layers = g_list_append (priv->cache_layers, priv->cur_cache);
priv->cur_cache = index_cache_new ();
/* Put current cache into the queue and create a
* new one for keeping appending words
*/
priv->cache_layers = g_list_append (priv->cache_layers, priv->cur_cache);
priv->cur_cache = index_cache_new ();
update_overloaded_status (indez);
}
init_flush (indez);
update_overloaded_status (indez);
}
void
......
......@@ -207,7 +207,8 @@ static void item_remove (TrackerIndexer *indexer,
PathInfo *info,
const gchar *dirname,
const gchar *basename);
static void check_finished (TrackerIndexer *indexer);
static void check_finished (TrackerIndexer *indexer,
gboolean interrupted);
static guint signals[LAST_SIGNAL] = { 0, };
......@@ -492,7 +493,7 @@ index_flushing_notify_cb (GObject *object,
!tracker_db_index_get_flushing (indexer->private->file_index) &&
!tracker_db_index_get_flushing (indexer->private->email_index)) {
/* The indexer has been already stopped and all indices are flushed */
check_finished (indexer);
check_finished (indexer, indexer->private->interrupted);
}
}
......@@ -727,7 +728,8 @@ check_started (TrackerIndexer *indexer)
}
static void
check_finished (TrackerIndexer *indexer)
check_finished (TrackerIndexer *indexer,
gboolean interrupted)
{
TrackerIndexerState state;
gdouble seconds_elapsed = 0;
......@@ -761,7 +763,7 @@ check_finished (TrackerIndexer *indexer)
seconds_elapsed,
indexer->private->items_processed,
indexer->private->items_indexed,
indexer->private->interrupted);
interrupted);
/* Reset stats */
indexer->private->items_processed = 0;
......@@ -774,9 +776,19 @@ static void
check_stopped (TrackerIndexer *indexer,
gboolean interrupted)
{
schedule_flush (indexer, TRUE);
state_set_flags (indexer, TRACKER_INDEXER_STATE_STOPPED);
indexer->private->interrupted = (interrupted != FALSE);
if ((indexer->private->state & TRACKER_INDEXER_STATE_STOPPED) == 0) {
schedule_flush (indexer, TRUE);
state_set_flags (indexer, TRACKER_INDEXER_STATE_STOPPED);
indexer->private->interrupted = (interrupted != FALSE);
} else {
/* If the indexer is stopped and the indices aren't
* being flushed, then it's ready for finishing right away
*/
if (!tracker_db_index_get_flushing (indexer->private->file_index) &&
!tracker_db_index_get_flushing (indexer->private->email_index)) {
check_finished (indexer, interrupted);
}
}
}
static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment