Skip to content

Commit 28d7b65

Browse files
authored
Fix destroy handler race (#141)
1 parent 0681b59 commit 28d7b65

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

internal/socket/duplex.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,11 @@ func (dc *DuplexConnection) destroyTransport() {
161161
}
162162

163163
func (dc *DuplexConnection) destroyHandler(err error) {
164-
// TODO: optimize callback map
165-
var callbacks []callback
166164
dc.messages.Range(func(_, value interface{}) bool {
167-
callbacks = append(callbacks, value.(callback))
165+
cb := value.(callback)
166+
cb.stopWithError(err)
168167
return true
169168
})
170-
for _, next := range callbacks {
171-
next.stopWithError(err)
172-
}
173169
}
174170

175171
func (dc *DuplexConnection) destroyFragment() {

0 commit comments

Comments
 (0)