Skip to content

Commit 04d667f

Browse files
committed
further improve flusher locking
1 parent b1390dc commit 04d667f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ func (c *Client) run() {
118118
func (c *Client) flusher() {
119119
ticker := time.NewTicker(100 * time.Millisecond)
120120

121-
for !c.closed {
121+
for {
122122
<-ticker.C
123123
c.lock.Lock()
124+
if c.closed {
125+
break
126+
}
124127
if c.lastFlush.Before(c.lastWrite) {
125128
c.lastFlush = c.lastWrite
126129
c.flush.Flush()

0 commit comments

Comments
 (0)