Commit ff36b912 authored by Carlos Garnacho's avatar Carlos Garnacho

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.
parent 903b8291
......@@ -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),
g_slice_free (UpdateData, update_data);
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