Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
add read from link.rx when sending a detach to eliminate deadlock on …
Browse files Browse the repository at this point in the history
…send
  • Loading branch information
devigned authored and vcabbage committed Aug 2, 2018
1 parent 1c4e912 commit f04efab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,13 +1307,24 @@ func (l *link) muxDetach() {
Closed: true,
Error: detachError,
}
select {
case l.session.tx <- fr:
case <-l.session.done:
if l.err == nil {
l.err = l.session.err

Loop:
for {
select {
case l.session.tx <- fr:
// after sending the detach frame, break the read loop
break Loop
case fr := <-l.rx:
// discard incoming frames to avoid blocking session.mux
if fr, ok := fr.(*performDetach); ok && fr.Closed {
l.detachReceived = true
}
case <-l.session.done:
if l.err == nil {
l.err = l.session.err
}
return
}
return
}

// don't wait for remote to detach when already
Expand Down

0 comments on commit f04efab

Please sign in to comment.