[tracker/wip/sam/meson] libtracker-miner: Move to next priority queue segment after deleting tail
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/sam/meson] libtracker-miner: Move to next priority queue segment after deleting tail
- Date: Sun, 25 Sep 2016 13:19:44 +0000 (UTC)
commit 3e783d7ea53ce20554b090221c82c5bcd7f39f57
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]