[tracker-miners/wip/carlosg/shuffle-libtracker-miner: 80/115] libtracker-miner: Untangle SPARQL buffer task memory management



commit 88b92f309187455a5186ed3f517286942a699c08
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Sep 9 12:15:36 2018 +0200

    libtracker-miner: Untangle SPARQL buffer task memory management
    
    On one hand, the refcounting assignment was wrong, the task callback
    is meant to receive a reference on the TrackerTask where it was
    getting none.
    
    On the other hand, after fixing it there is a circular reference
    between the GTask and the TrackerTask that would prevent both to
    be freed, break it by disposing the GTask as soon as it's dispatched.

 src/libtracker-miner/tracker-sparql-buffer.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-sparql-buffer.c b/src/libtracker-miner/tracker-sparql-buffer.c
index d814bbd5a..0bedd07b6 100644
--- a/src/libtracker-miner/tracker-sparql-buffer.c
+++ b/src/libtracker-miner/tracker-sparql-buffer.c
@@ -276,9 +276,13 @@ tracker_sparql_buffer_update_array_cb (GObject      *object,
                        g_task_return_error (task_data->async_task,
                                             g_error_copy (error));
                } else {
-                       g_task_return_pointer (task_data->async_task, task, NULL);
+                       g_task_return_pointer (task_data->async_task,
+                                              tracker_task_ref (task),
+                                              (GDestroyNotify) tracker_task_unref);
                }
 
+               g_clear_object (&task_data->async_task);
+
                /* No need to deallocate the task here, it will be done when
                 * unref-ing the UpdateArrayData below */
        }
@@ -382,9 +386,12 @@ tracker_sparql_buffer_update_cb (GObject      *object,
                g_task_return_error (task_data->async_task, error);
        } else {
                g_task_return_pointer (task_data->async_task,
-                                      update_data->task, NULL);
+                                      tracker_task_ref (update_data->task),
+                                      (GDestroyNotify) tracker_task_unref);
        }
 
+       g_clear_object (&task_data->async_task);
+
        tracker_task_pool_remove (TRACKER_TASK_POOL (update_data->buffer),
                                  update_data->task);
        g_slice_free (UpdateData, update_data);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]