Reduce the initial idle timeout to 30 seconds.

This commit reduces the initial idle timeout before version negotiation
has happened on a new peer to 30 seconds.  Previously it could take 5
minutes due to the general idle timeout.
This commit is contained in:
Dave Collins 2014-01-18 01:39:31 -06:00
parent 8c7d44c8dc
commit 7ad6e235ad

10
peer.go
View file

@ -33,6 +33,11 @@ const (
// inventory cache.
maxKnownInventory = 20000
// negotiateTimeoutSeconds is the number of seconds of inactivity before
// we timeout a peer that hasn't completed the initial version
// negotiation.
negotiateTimeoutSeconds = 30
// idleTimeoutMinutes is the number of minutes of inactivity before
// we time out a peer.
idleTimeoutMinutes = 5
@ -1019,7 +1024,10 @@ func (p *peer) isAllowedByRegression(err error) bool {
// inHandler handles all incoming messages for the peer. It must be run as a
// goroutine.
func (p *peer) inHandler() {
idleTimer := time.AfterFunc(idleTimeoutMinutes*time.Minute, func() {
// Peers must complete the initial version negotiation within a shorter
// timeframe than a general idle timeout. The timer is then reset below
// to idleTimeoutMinutes for all future messages.
idleTimer := time.AfterFunc(negotiateTimeoutSeconds*time.Second, func() {
// XXX technically very very very slightly racy, doesn't really
// matter.
if p.versionKnown {