mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-24 07:28:27 +00:00
Don't potentially block forever in Close() (fixes #655)
This commit is contained in:
parent
1e51fca0b0
commit
5d85a24977
@ -5,6 +5,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -474,6 +475,13 @@ func (m *Model) Close(node protocol.NodeID, err error) {
|
|||||||
|
|
||||||
conn, ok := m.rawConn[node]
|
conn, ok := m.rawConn[node]
|
||||||
if ok {
|
if ok {
|
||||||
|
if conn, ok := conn.(*tls.Conn); ok {
|
||||||
|
// If the underlying connection is a *tls.Conn, Close() does more
|
||||||
|
// than it says on the tin. Specifically, it sends a TLS alert
|
||||||
|
// message, which might block forever if the connection is dead
|
||||||
|
// and we don't have a deadline site.
|
||||||
|
conn.SetWriteDeadline(time.Now().Add(250 * time.Millisecond))
|
||||||
|
}
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
delete(m.protoConn, node)
|
delete(m.protoConn, node)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user