shithub: gefs

Download patch

ref: 366cfab1bf689c387e90dfff1021fbace49a4aa2
parent: 2b6667f4f7faef9954b5ed75881b1fe9225d9705
author: Michael Forney <mforney@mforney.org>
date: Thu Feb 24 05:32:43 EST 2022

blk: fix sync queue ordering

We want to sync the lowest qgens first, so we need a min-heap here.

--- a/blk.c
+++ b/blk.c
@@ -926,7 +926,7 @@
 		abort();
 	q->heap[q->nheap] = b;
 	for(i = q->nheap; i > 0; i = (i-1)/2){
-		if(blkcmp(q->heap[i], q->heap[(i-1)/2]) == -1)
+		if(blkcmp(q->heap[i], q->heap[(i-1)/2]) == 1)
 			break;
 		t = q->heap[i];
 		q->heap[i] = q->heap[(i-1)/2];
@@ -954,9 +954,9 @@
 		m = i;
 		l = 2*i+1;
 		r = 2*i+2;
-		if(l < q->nheap && blkcmp(q->heap[m], q->heap[l]) == -1)
+		if(l < q->nheap && blkcmp(q->heap[m], q->heap[l]) == 1)
 			m = l;
-		if(r < q->nheap && blkcmp(q->heap[m], q->heap[r]) == -1)
+		if(r < q->nheap && blkcmp(q->heap[m], q->heap[r]) == 1)
 			m = r;
 		if(m == i)
 			break;