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

Commit ddf76e6

Browse files
alanconwayvcabbage
authored andcommittedDec 3, 2019
Sessions entries in conn.mux() were being leaked on error.
Defer cleanup of conn.mux() session entries in Session.mux() so it is always called. Signed-off-by: Alan Conway <aconway@redhat.com>
1 parent b59f454 commit ddf76e6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎client.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,19 @@ func (s *Session) NewSender(opts ...LinkOption) (*Sender, error) {
469469
}
470470

471471
func (s *Session) mux(remoteBegin *performBegin) {
472-
defer close(s.done)
472+
defer func() {
473+
// clean up session record in conn.mux()
474+
select {
475+
case s.conn.delSession <- s:
476+
case <-s.conn.done:
477+
s.err = s.conn.getErr()
478+
}
479+
if s.err == nil {
480+
s.err = ErrSessionClosed
481+
}
482+
// Signal goroutines waiting on the session.
483+
close(s.done)
484+
}()
473485

474486
var (
475487
links = make(map[uint32]*link) // mapping of remote handles to links
@@ -520,14 +532,6 @@ func (s *Session) mux(remoteBegin *performBegin) {
520532
return
521533
}
522534
}
523-
524-
// release session
525-
select {
526-
case s.conn.delSession <- s:
527-
s.err = ErrSessionClosed
528-
case <-s.conn.done:
529-
s.err = s.conn.getErr()
530-
}
531535
return
532536

533537
// handle allocation request

0 commit comments

Comments
 (0)
This repository has been archived.