ref: 98a2dab2668194f4bd30e7d3f337ec3be5bfeaeb
parent: 1d1477ab0b51a00bd4f82a3ee1f788a0c82033f0
author: Ori Bernstein <[email protected]>
date: Tue Feb 16 20:12:58 EST 2021
pack.c: we want the oldest open, not the newest. Check for < instead of >=, and record the most recent time we opened a pack, instead of the first time.
--- a/pack.c
+++ b/pack.c
@@ -255,7 +255,6 @@
if(pf->pack == nil){
if((pf->pack = Bopen(pf->path, OREAD)) == nil)
return nil;
- pf->opentm = nsec();
openpacks++;
}
if(openpacks == Npackcache){
@@ -262,7 +261,7 @@
t = pf->opentm;
best = -1;
for(i = 0; i < npackf; i++){
- if(packf[i].opentm >= t && packf[i].refs > 0){
+ if(packf[i].opentm < t && packf[i].refs > 0){
t = packf[i].opentm;
best = i;
}
@@ -273,6 +272,7 @@
openpacks--;
}
}
+ pf->opentm = nsec();
pf->refs++;
return pf->pack;
}