We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8bcb960 commit b1390dcCopy full SHA for b1390dc
client.go
@@ -16,6 +16,7 @@ type Client struct {
16
events chan *Event
17
closed bool
18
waiter sync.WaitGroup
19
+ lock sync.Mutex
20
lastFlush time.Time
21
lastWrite time.Time
22
}
@@ -99,8 +100,10 @@ func (c *Client) run() {
99
100
101
102
// send the event
103
+ c.lock.Lock()
104
io.Copy(c.write, ev)
105
c.lastWrite = time.Now()
106
+ c.lock.Unlock()
107
108
case <-c.close.CloseNotify():
109
c.closed = true
@@ -117,10 +120,12 @@ func (c *Client) flusher() {
117
120
118
121
for !c.closed {
119
122
<-ticker.C
123
124
if c.lastFlush.Before(c.lastWrite) {
125
c.lastFlush = c.lastWrite
126
c.flush.Flush()
127
128
129
130
131
ticker.Stop()
0 commit comments