peer: enforce strict timeout on opening handshake

This commit modifies the logic around the opening p2p handshake to
enforce a strict timeout around the receipt of the responding init
message. Before this commit, it was possible for the daemon and certain
RPC calls to deadlock as if a peer connected, but didn’t respond with
an init msg, then we’d be sitting there waiting for them to respond.
With this commit, we’ll now time out, kill the connection and then
possible attempt to re-connect if the connection was persistent.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-03-29 19:00:40 -07:00
1 parent 98d5dde9b2
commit 0e96d273d9
2 files changed
+23 -6

No files matched your search

-3
View File
@@ -550,9 +550,6 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, inbound
if err := p.Start(); err != nil {
srvrLog.Errorf("unable to start peer: %v", err)
if p.connReq != nil {
s.connMgr.Remove(p.connReq.ID())
}
p.Disconnect()
return
}