[FIXED] Possible panic when server accepts TLS leafnode connection

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2020-10-19 10:03:00 -06:00
parent 923335e52d
commit 3b8d00e046
2 changed files with 64 additions and 3 deletions

View File

@@ -1204,6 +1204,39 @@ func TestLeafNodeTLS(t *testing.T) {
checkLeafNodeConnected(t, s)
}
func TestLeafNodeTLSConnCloseEarly(t *testing.T) {
content := `
listen: "127.0.0.1:-1"
leafnodes {
listen: "127.0.0.1:-1"
tls {
cert_file: "./configs/certs/server-cert.pem"
key_file: "./configs/certs/server-key.pem"
timeout: 2.0
}
}
`
conf := createConfFile(t, []byte(content))
defer os.Remove(conf)
s, opts := RunServerWithConfig(conf)
defer s.Shutdown()
lc, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", opts.LeafNode.Port))
if err != nil {
t.Fatalf("Unable to connect: %v", err)
}
// Then close right away
lc.Close()
// Check server does not crash...
time.Sleep(250 * time.Millisecond)
if s.ID() == "" {
t.Fatalf("should not happen")
}
}
type captureLeafNodeErrLogger struct {
dummyLogger
ch chan string