We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 0531238 + dadd0c8 commit 27e7861Copy full SHA for 27e7861
socketio/socketio.go
@@ -125,7 +125,8 @@ type ws interface {
125
}
126
127
type Websocket struct {
128
- mu sync.RWMutex
+ once sync.Once
129
+ mu sync.RWMutex
130
// The Fiber.Websocket connection
131
Conn *websocket.Conn
132
// Define if the connection is alive or not
@@ -568,9 +569,11 @@ func (kws *Websocket) disconnected(err error) {
568
569
570
// may be called multiple times from different go routines
571
if kws.IsAlive() {
- close(kws.done)
572
+ kws.once.Do(func() {
573
+ kws.setAlive(false)
574
+ close(kws.done)
575
+ })
576
- kws.setAlive(false)
577
578
// Fire error event if the connection is
579
// disconnected by an error
0 commit comments