ref: 90a6fc91052ebe27f3e1fa0d96d0876c00b48ff3
parent: 111d42550f50f79b9b357d130b8bcdbafc5165ee
author: Ori Bernstein <[email protected]>
date: Sat Dec 31 13:54:43 EST 2022
fix log trimming
--- a/mq.c
+++ b/mq.c
@@ -113,18 +113,17 @@
void
trimlog(Mq *q)
{
- Msg *m, *n;
+ Msg *m;
if(maxlog < 0)
return;
- n = nil;
- for(m = q->loghd; m != nil && q->logsz >= maxlog; m = n){
- n = m->next;
+ while(q->loghd != nil && q->logsz >= maxlog){
+ m = q->loghd;
+ q->loghd = m->next;
q->logsz -= m->count;
msgunref(m);
}
- q->loghd = n;
- if(m == nil)
+ if(q->loghd == nil)
q->logtl = nil;
}