Skip to content

Commit

Permalink
Fix destroy handler race (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
echistyakov authored Jan 20, 2025
1 parent 0681b59 commit 28d7b65
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions internal/socket/duplex.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,11 @@ func (dc *DuplexConnection) destroyTransport() {
}

func (dc *DuplexConnection) destroyHandler(err error) {
// TODO: optimize callback map
var callbacks []callback
dc.messages.Range(func(_, value interface{}) bool {
callbacks = append(callbacks, value.(callback))
cb := value.(callback)
cb.stopWithError(err)
return true
})
for _, next := range callbacks {
next.stopWithError(err)
}
}

func (dc *DuplexConnection) destroyFragment() {
Expand Down

0 comments on commit 28d7b65

Please sign in to comment.