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

Sessions entries in conn.mux() were being leaked on error. #199

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,19 @@ func (s *Session) NewSender(opts ...LinkOption) (*Sender, error) {
}

func (s *Session) mux(remoteBegin *performBegin) {
defer close(s.done)
defer func() {
// clean up session record in conn.mux()
select {
case s.conn.delSession <- s:
case <-s.conn.done:
s.err = s.conn.getErr()
}
if s.err == nil {
s.err = ErrSessionClosed
}
// Signal goroutines waiting on the session.
close(s.done)
}()

var (
links = make(map[uint32]*link) // mapping of remote handles to links
Expand Down Expand Up @@ -520,14 +532,6 @@ func (s *Session) mux(remoteBegin *performBegin) {
return
}
}

// release session
select {
case s.conn.delSession <- s:
s.err = ErrSessionClosed
case <-s.conn.done:
s.err = s.conn.getErr()
}
return

// handle allocation request
Expand Down