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:
parent
8c7d44c8dc
commit
7ad6e235ad
1 changed files with 9 additions and 1 deletions
10
peer.go
10
peer.go
|
@ -33,6 +33,11 @@ const (
|
||||||
// inventory cache.
|
// inventory cache.
|
||||||
maxKnownInventory = 20000
|
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
|
// idleTimeoutMinutes is the number of minutes of inactivity before
|
||||||
// we time out a peer.
|
// we time out a peer.
|
||||||
idleTimeoutMinutes = 5
|
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
|
// inHandler handles all incoming messages for the peer. It must be run as a
|
||||||
// goroutine.
|
// goroutine.
|
||||||
func (p *peer) inHandler() {
|
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
|
// XXX technically very very very slightly racy, doesn't really
|
||||||
// matter.
|
// matter.
|
||||||
if p.versionKnown {
|
if p.versionKnown {
|
||||||
|
|
Loading…
Add table
Reference in a new issue