[tracker] libtracker-miner: Move to next priority queue segment after deleting tail
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-miner: Move to next priority queue segment after deleting tail
- Date: Tue, 23 Aug 2016 10:47:17 +0000 (UTC)
commit cbad8fe3dc898c540098efe2c7d9011018d24757
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 23 12:20:10 2016 +0200
libtracker-miner: Move to next priority queue segment after deleting tail
If the tail element of a segment is being removed, we didn't move on to the
next one, so accounting of subsequent segments might get broken if further
elements are removed that are the head or the tail of a segment.
Also, just do the "jump to next segment" bit generic, so the affected paths
just turn on a fetch_segment boolean flag.
https://bugzilla.gnome.org/show_bug.cgi?id=769035
src/libtracker-miner/tracker-priority-queue.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-priority-queue.c b/src/libtracker-miner/tracker-priority-queue.c
index 42c3d3e..85190cd 100644
--- a/src/libtracker-miner/tracker-priority-queue.c
+++ b/src/libtracker-miner/tracker-priority-queue.c
@@ -210,6 +210,7 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
segment = &g_array_index (queue->segments, PrioritySegment, n_segment);
while (list) {
+ gboolean fetch_segment = FALSE;
GList *elem;
elem = list;
@@ -222,18 +223,14 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
/* Last element of segment, remove it */
g_array_remove_index (queue->segments,
n_segment);
-
- if (list) {
- /* Fetch the next one */
- segment = &g_array_index (queue->segments,
- PrioritySegment,
- n_segment);
- }
+ fetch_segment = TRUE;
} else if (elem == segment->first_elem) {
/* First elemen in segment */
segment->first_elem = elem->next;
} else if (elem == segment->last_elem) {
segment->last_elem = elem->prev;
+ n_segment++;
+ fetch_segment = TRUE;
}
if (destroy_notify) {
@@ -247,13 +244,17 @@ tracker_priority_queue_foreach_remove (TrackerPriorityQueue *queue,
elem == segment->last_elem) {
/* Move on to the next segment */
n_segment++;
- g_assert (n_segment < queue->segments->len);
-
- segment = &g_array_index (queue->segments,
- PrioritySegment,
- n_segment);
+ fetch_segment = TRUE;
}
}
+
+ if (list && fetch_segment) {
+ /* Fetch the next segment */
+ g_assert (n_segment < queue->segments->len);
+ segment = &g_array_index (queue->segments,
+ PrioritySegment,
+ n_segment);
+ }
}
return updated;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]