What version of Go are you using (go version)?
go1.7
What operating system and processor architecture are you using (go env)?
linux/amd64
What did you do?
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
if c.handshakeComplete {
alertErr = c.sendAlert(alertCloseNotify)
}
if err := c.conn.Close(); err != nil {
// c.conn.Close() calls c.ConnectionState() before returning
// this will cause a deadlock
// can the defer be removed from c.handshakeMutex.Unlock() before c.conn.Close()?
return err
}
return alertErr
}
What did you expect to see?
Close() will call c.handshakeMutex.Lock()
Close() will deadlock if c.conn.Close() calls ConnectionState()
https://golang.org/src/crypto/tls/conn.go?s=34139:34345#L1163
ConnectionState() will call c.handshakeMutex.Lock()
https://golang.org/src/crypto/tls/conn.go?s=36916:36964#L1271
What did you see instead?
Is there a reason I shouldn't be able to call ConnectionState from inside of my net.Conn that *tls.Conn is wrapped around?
Could the defer unlock be replaced?
thank you
What version of Go are you using (
go version)?go1.7
What operating system and processor architecture are you using (
go env)?linux/amd64
What did you do?
What did you expect to see?
Close() will call c.handshakeMutex.Lock()
Close() will deadlock if c.conn.Close() calls ConnectionState()
https://golang.org/src/crypto/tls/conn.go?s=34139:34345#L1163
ConnectionState() will call c.handshakeMutex.Lock()
https://golang.org/src/crypto/tls/conn.go?s=36916:36964#L1271
What did you see instead?
Is there a reason I shouldn't be able to call ConnectionState from inside of my net.Conn that *tls.Conn is wrapped around?
Could the defer unlock be replaced?
thank you