Skip to content

Commit acc7c3f

Browse files
Fix race condition blocking cleanup of goroutines (#57)
Signed-off-by: Bernhard Schmid <bernhard.schmid@de.ibm.com> Co-authored-by: Mirko Lazarevic <Mirko.Lazarevic@ibm.com>
1 parent c2b759c commit acc7c3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fluent/client/ws/connection.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ type connection struct {
102102
writeLock sync.Mutex
103103
stateLock sync.RWMutex
104104
readHandler ReadHandler
105-
closedSig chan struct{}
105+
done chan struct{}
106106
connState ConnState
107107
closeDeadline time.Duration
108108
}
109109

110110
func NewConnection(conn ext.Conn, opts ConnectionOptions) (Connection, error) {
111111
wsc := &connection{
112112
Conn: conn,
113-
closedSig: make(chan struct{}),
113+
done: make(chan struct{}),
114114
connState: ConnStateOpen,
115115
logger: opts.Logger,
116116
}
@@ -239,7 +239,7 @@ func (wsc *connection) CloseWithMsg(closeCode int, msg string) error {
239239
case <-time.After(wsc.closeDeadline):
240240
// sent a close, but never heard back, close anyway
241241
err = errors.New("close deadline expired")
242-
case <-wsc.closedSig:
242+
case <-wsc.done:
243243
}
244244
}
245245
}
@@ -285,7 +285,7 @@ func (wsc *connection) runReadLoop(nextMsg chan connMsg) {
285285

286286
close(nextMsg)
287287
wsc.unsetConnState(ConnStateListening)
288-
wsc.closedSig <- struct{}{}
288+
close(wsc.done)
289289
}()
290290

291291
msg := connMsg{}

0 commit comments

Comments
 (0)