summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/peer.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/server/peer.go')
-rw-r--r--pkg/server/peer.go29
1 files changed, 7 insertions, 22 deletions
diff --git a/pkg/server/peer.go b/pkg/server/peer.go
index 83a5d12f..4e51137a 100644
--- a/pkg/server/peer.go
+++ b/pkg/server/peer.go
@@ -29,10 +29,11 @@ import (
)
const (
- flopThreshold = time.Second * 30
- minConnectRetry = 10
+ flopThreshold = time.Second * 30
)
+var minConnectRetry = 10
+
type peerGroup struct {
Conf *config.PeerGroup
members map[string]config.Neighbor
@@ -560,6 +561,7 @@ func (peer *peer) stopFSM() error {
failed := false
peer.fsm.lock.RLock()
addr := peer.fsm.pConf.State.NeighborAddress
+ state := peer.fsm.state
peer.fsm.lock.RUnlock()
t1 := time.AfterFunc(time.Minute*5, func() {
log.WithFields(log.Fields{
@@ -567,33 +569,16 @@ func (peer *peer) stopFSM() error {
}).Warnf("Failed to free the fsm.h.t for %s", addr)
failed = true
})
-
- peer.fsm.h.t.Kill(nil)
- peer.fsm.h.t.Wait()
+ peer.fsm.h.ctxCancel()
+ peer.fsm.h.wg.Wait()
t1.Stop()
if !failed {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": addr,
+ "State": state,
}).Debug("freed fsm.h.t")
cleanInfiniteChannel(peer.outgoing)
}
- failed = false
- t2 := time.AfterFunc(time.Minute*5, func() {
- log.WithFields(log.Fields{
- "Topic": "Peer",
- }).Warnf("Failed to free the fsm.t for %s", addr)
- failed = true
- })
- peer.fsm.t.Kill(nil)
- peer.fsm.t.Wait()
- t2.Stop()
- if !failed {
- log.WithFields(log.Fields{
- "Topic": "Peer",
- "Key": addr,
- }).Debug("freed fsm.t")
- return nil
- }
return fmt.Errorf("Failed to free FSM for %s", addr)
}