From 3854c1ed68a6170e394ba76485a0ab4497a5d4c2 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 7 May 2018 19:10:44 -0700 Subject: [PATCH] discovery/gossiper: exit early on validation barrier quit --- discovery/gossiper.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index a2e8ec9c..90b84590 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -906,13 +906,26 @@ func (d *AuthenticatedGossiper) networkHandler() { // have thousands of goroutines active. validationBarrier.InitJobDependencies(announcement.msg) + d.wg.Add(1) go func() { + defer d.wg.Done() defer validationBarrier.CompleteJob() // If this message has an existing dependency, // then we'll wait until that has been fully // validated before we proceed. - validationBarrier.WaitForDependants(announcement.msg) + err := validationBarrier.WaitForDependants( + announcement.msg, + ) + if err != nil { + if err != routing.ErrVBarrierShuttingDown { + log.Warnf("unexpected error "+ + "during validation "+ + "barrier shutdown: %v", + err) + } + return + } // Process the network announcement to determine if // this is either a new announcement from our PoV