|
|
1927f5 |
From 409606679702536cfb207282c3d034eace83f2a4 Mon Sep 17 00:00:00 2001
|
|
|
1927f5 |
From: Debarshi Ray <debarshir@gnome.org>
|
|
|
1927f5 |
Date: Wed, 1 Oct 2014 19:31:01 +0200
|
|
|
1927f5 |
Subject: [PATCH 1/2] libtracker-miner: Ensure that the async function uses
|
|
|
1927f5 |
owned data
|
|
|
1927f5 |
|
|
|
1927f5 |
... and simplify parent directory tracking.
|
|
|
1927f5 |
|
|
|
1927f5 |
The GFileEnumerator keeps a reference to the directory that is being
|
|
|
1927f5 |
traversed, so we don't need to keep track of it ourselves.
|
|
|
1927f5 |
|
|
|
1927f5 |
https://bugzilla.gnome.org/show_bug.cgi?id=737768
|
|
|
1927f5 |
---
|
|
|
1927f5 |
src/libtracker-miner/tracker-crawler.c | 18 +++++++-----------
|
|
|
1927f5 |
1 file changed, 7 insertions(+), 11 deletions(-)
|
|
|
1927f5 |
|
|
|
1927f5 |
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
index c034204..2c6e0f0 100644
|
|
|
1927f5 |
--- a/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
+++ b/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
@@ -105,7 +105,6 @@ typedef struct {
|
|
|
1927f5 |
TrackerCrawler *crawler;
|
|
|
1927f5 |
DirectoryRootInfo *root_info;
|
|
|
1927f5 |
DirectoryProcessingData *dir_info;
|
|
|
1927f5 |
- GFile *dir_file;
|
|
|
1927f5 |
GCancellable *cancellable;
|
|
|
1927f5 |
} EnumeratorData;
|
|
|
1927f5 |
|
|
|
1927f5 |
@@ -596,9 +595,6 @@ enumerator_data_new (TrackerCrawler *crawler,
|
|
|
1927f5 |
ed->crawler = g_object_ref (crawler);
|
|
|
1927f5 |
ed->root_info = root_info;
|
|
|
1927f5 |
ed->dir_info = dir_info;
|
|
|
1927f5 |
- /* Make sure there's always a ref of the GFile while we're
|
|
|
1927f5 |
- * iterating it */
|
|
|
1927f5 |
- ed->dir_file = g_object_ref (G_FILE (dir_info->node->data));
|
|
|
1927f5 |
ed->cancellable = g_cancellable_new ();
|
|
|
1927f5 |
|
|
|
1927f5 |
crawler->priv->cancellables = g_list_prepend (crawler->priv->cancellables,
|
|
|
1927f5 |
@@ -607,7 +603,7 @@ enumerator_data_new (TrackerCrawler *crawler,
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
static void
|
|
|
1927f5 |
-enumerator_data_process (EnumeratorData *ed)
|
|
|
1927f5 |
+enumerator_data_process (GFile *parent, EnumeratorData *ed)
|
|
|
1927f5 |
{
|
|
|
1927f5 |
TrackerCrawler *crawler;
|
|
|
1927f5 |
GSList *l;
|
|
|
1927f5 |
@@ -623,7 +619,7 @@ enumerator_data_process (EnumeratorData *ed)
|
|
|
1927f5 |
children = g_list_prepend (children, child_data->child);
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
- g_signal_emit (crawler, signals[CHECK_DIRECTORY_CONTENTS], 0, ed->dir_info->node->data, children, &use;;
|
|
|
1927f5 |
+ g_signal_emit (crawler, signals[CHECK_DIRECTORY_CONTENTS], 0, parent, children, &use;;
|
|
|
1927f5 |
g_list_free (children);
|
|
|
1927f5 |
|
|
|
1927f5 |
if (!use) {
|
|
|
1927f5 |
@@ -640,7 +636,6 @@ enumerator_data_free (EnumeratorData *ed)
|
|
|
1927f5 |
g_list_remove (ed->crawler->priv->cancellables,
|
|
|
1927f5 |
ed->cancellable);
|
|
|
1927f5 |
|
|
|
1927f5 |
- g_object_unref (ed->dir_file);
|
|
|
1927f5 |
g_object_unref (ed->crawler);
|
|
|
1927f5 |
g_object_unref (ed->cancellable);
|
|
|
1927f5 |
g_slice_free (EnumeratorData, ed);
|
|
|
1927f5 |
@@ -690,6 +685,7 @@ file_enumerate_next_cb (GObject *object,
|
|
|
1927f5 |
ed = user_data;
|
|
|
1927f5 |
crawler = ed->crawler;
|
|
|
1927f5 |
cancelled = g_cancellable_is_cancelled (ed->cancellable);
|
|
|
1927f5 |
+ parent = g_file_enumerator_get_container (enumerator);
|
|
|
1927f5 |
|
|
|
1927f5 |
files = g_file_enumerator_next_files_finish (enumerator,
|
|
|
1927f5 |
result,
|
|
|
1927f5 |
@@ -710,7 +706,7 @@ file_enumerate_next_cb (GObject *object,
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
if (!cancelled) {
|
|
|
1927f5 |
- enumerator_data_process (ed);
|
|
|
1927f5 |
+ enumerator_data_process (parent, ed);
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
enumerator_data_free (ed);
|
|
|
1927f5 |
@@ -724,8 +720,6 @@ file_enumerate_next_cb (GObject *object,
|
|
|
1927f5 |
return;
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
- parent = ed->dir_info->node->data;
|
|
|
1927f5 |
-
|
|
|
1927f5 |
for (l = files; l; l = l->next) {
|
|
|
1927f5 |
const gchar *child_name;
|
|
|
1927f5 |
gboolean is_dir;
|
|
|
1927f5 |
@@ -814,6 +808,7 @@ file_enumerate_children (TrackerCrawler *crawler,
|
|
|
1927f5 |
DirectoryProcessingData *dir_data)
|
|
|
1927f5 |
{
|
|
|
1927f5 |
EnumeratorData *ed;
|
|
|
1927f5 |
+ GFile *dir_file;
|
|
|
1927f5 |
gchar *attrs;
|
|
|
1927f5 |
|
|
|
1927f5 |
ed = enumerator_data_new (crawler, info, dir_data);
|
|
|
1927f5 |
@@ -826,7 +821,8 @@ file_enumerate_children (TrackerCrawler *crawler,
|
|
|
1927f5 |
attrs = g_strdup (FILE_ATTRIBUTES);
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
- g_file_enumerate_children_async (ed->dir_file,
|
|
|
1927f5 |
+ dir_file = G_FILE (dir_data->node->data);
|
|
|
1927f5 |
+ g_file_enumerate_children_async (dir_file,
|
|
|
1927f5 |
attrs,
|
|
|
1927f5 |
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
|
|
1927f5 |
G_PRIORITY_LOW,
|
|
|
1927f5 |
--
|
|
|
1927f5 |
2.1.0
|
|
|
1927f5 |
|
|
|
1927f5 |
|
|
|
1927f5 |
From 0018667159e02a4b9e51ad2c9bbd76d666fbfe56 Mon Sep 17 00:00:00 2001
|
|
|
1927f5 |
From: Debarshi Ray <debarshir@gnome.org>
|
|
|
1927f5 |
Date: Wed, 1 Oct 2014 19:44:42 +0200
|
|
|
1927f5 |
Subject: [PATCH 2/2] libtracker-miner: Keep the crawler alive across async
|
|
|
1927f5 |
calls
|
|
|
1927f5 |
|
|
|
1927f5 |
The EnumeratorData held a reference to TrackerCrawler while
|
|
|
1927f5 |
enumerating. Just before closing the enumerator we destroy the
|
|
|
1927f5 |
EnumeratorData and drop the reference. This can lead to TrackerCrawler
|
|
|
1927f5 |
getting destroyed.
|
|
|
1927f5 |
|
|
|
1927f5 |
To prevent this, grab a new reference before dropping the older one
|
|
|
1927f5 |
and keep it till the asynchronous call is alive.
|
|
|
1927f5 |
|
|
|
1927f5 |
https://bugzilla.gnome.org/show_bug.cgi?id=737769
|
|
|
1927f5 |
---
|
|
|
1927f5 |
src/libtracker-miner/tracker-crawler.c | 5 +++--
|
|
|
1927f5 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
1927f5 |
|
|
|
1927f5 |
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
index 2c6e0f0..80befde 100644
|
|
|
1927f5 |
--- a/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
+++ b/src/libtracker-miner/tracker-crawler.c
|
|
|
1927f5 |
@@ -664,6 +664,7 @@ file_enumerator_close_cb (GObject *enumerator,
|
|
|
1927f5 |
* continue with queued files/directories.
|
|
|
1927f5 |
*/
|
|
|
1927f5 |
process_func_start (crawler);
|
|
|
1927f5 |
+ g_object_unref (crawler);
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
static void
|
|
|
1927f5 |
@@ -709,12 +710,12 @@ file_enumerate_next_cb (GObject *object,
|
|
|
1927f5 |
enumerator_data_process (parent, ed);
|
|
|
1927f5 |
}
|
|
|
1927f5 |
|
|
|
1927f5 |
- enumerator_data_free (ed);
|
|
|
1927f5 |
g_file_enumerator_close_async (enumerator,
|
|
|
1927f5 |
G_PRIORITY_DEFAULT,
|
|
|
1927f5 |
NULL,
|
|
|
1927f5 |
file_enumerator_close_cb,
|
|
|
1927f5 |
- crawler);
|
|
|
1927f5 |
+ g_object_ref (crawler));
|
|
|
1927f5 |
+ enumerator_data_free (ed);
|
|
|
1927f5 |
g_object_unref (enumerator);
|
|
|
1927f5 |
|
|
|
1927f5 |
return;
|
|
|
1927f5 |
--
|
|
|
1927f5 |
2.1.0
|
|
|
1927f5 |
|