Skip to content

Commit 128b745

Browse files
committed
log: m unset ticking flag on timer end
with defer, the flag is unset only when periodicFlush fn returns, which may be too late, as the timer has already stopped and so, the flag must be unset right away and not after any more delays.
1 parent 8359766 commit 128b745

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

intra/log/memconsole.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ const waitPeriodOnFull = 3 * time.Millisecond
4949
// memBufSize is the total region passed to Ftruncate/Mmap.
5050
var (
5151
nofpages = 16
52-
memSlotSize = charsPerLine // 800 bytes per slot
53-
memNumSlots = nofpages * unix.Getpagesize()/memSlotSize // slots that fit in one page
54-
memBufSize = memHdrSize + memNumSlots*memSlotSize // ~1 page
52+
memSlotSize = charsPerLine // 800 bytes per slot
53+
memNumSlots = nofpages * unix.Getpagesize() / memSlotSize // slots that fit in one page
54+
memBufSize = memHdrSize + memNumSlots*memSlotSize // ~1 page
5555
)
5656

5757
// mcbuf is a fixed-slot shared-memory region backed by a memfd.
@@ -288,10 +288,10 @@ rollover:
288288
// ticker is a one-shot timer goroutine started by the first-write after each
289289
// buffer reset. It fires once after memFlushInterval and calls periodicFlush.
290290
func (mc *Memconsole) ticker() {
291-
defer mc.ticking.Store(false)
292291
t := time.NewTimer(memFlushInterval)
293292
defer t.Stop()
294293
<-t.C
294+
mc.ticking.Store(false) // TODO: may be racy; mutex it?
295295
mc.periodicFlush()
296296
}
297297

0 commit comments

Comments
 (0)