Skip to content

Commit

Permalink
Refactor Close method in websocketPeer to handle duplicate close calls
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Apr 2, 2024
1 parent 2798a81 commit 9609aab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions transport/websocketpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ func (w *websocketPeer) IsLocal() bool { return false }
//
// *** Do not call Send after calling Close. ***
func (w *websocketPeer) Close() {
select {
case <-w.closed:
return
default:
}

// Tell sendHandler to exit and discard any queued messages. Do not close
// wr channel in case there are incoming messages during close.
w.cancelSender()
Expand Down

0 comments on commit 9609aab

Please sign in to comment.