close the TLS crypto setup when session closes

This commit is contained in:
Marten Seemann 2018-10-28 12:52:26 +07:00
parent 06f96f4b6e
commit 8344dc8b64
2 changed files with 5 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"io"
"net"
"sync"
"time"
@ -603,6 +604,9 @@ runLoop:
}
s.logger.Infof("Connection %s closed.", s.srcConnID)
s.sessionRunner.removeConnectionID(s.srcConnID)
if s.version.UsesTLS() {
s.cryptoStreamHandler.(io.Closer).Close()
}
return closeErr.err
}

View file

@ -1638,6 +1638,7 @@ var _ = Describe("Client Session", func() {
})
Expect(err).ToNot(HaveOccurred())
// make sure the go routine returns
sess.version = protocol.Version39
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
sessionRunner.EXPECT().removeConnectionID(gomock.Any())
Expect(sess.Close()).To(Succeed())