File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 99 "reflect"
1010 "strings"
1111 "sync"
12+ "sync/atomic"
1213 "time"
1314
1415 "github.com/google/uuid"
@@ -51,7 +52,7 @@ type webSocketClient struct {
5152 connParams map [string ]interface {}
5253 errChan chan error
5354 subscriptions subscriptionMap
54- isClosing bool
55+ isClosing atomic. Bool
5556 sync.Mutex
5657}
5758
@@ -107,14 +108,14 @@ func (w *webSocketClient) waitForConnAck() error {
107108func (w * webSocketClient ) handleErr (err error ) {
108109 w .Lock ()
109110 defer w .Unlock ()
110- if ! w .isClosing {
111+ if ! w .isClosing . Load () {
111112 w .errChan <- err
112113 }
113114}
114115
115116func (w * webSocketClient ) listenWebSocket () {
116117 for {
117- if w .isClosing {
118+ if w .isClosing . Load () {
118119 return
119120 }
120121 _ , message , err := w .conn .ReadMessage ()
@@ -208,7 +209,7 @@ func (w *webSocketClient) Close() error {
208209 }
209210 w .Lock ()
210211 defer w .Unlock ()
211- w .isClosing = true
212+ w .isClosing . Store ( true )
212213 close (w .errChan )
213214 return w .conn .Close ()
214215}
You can’t perform that action at this time.
0 commit comments