From 360f72818b60d471da1bf8cd673272e927595d4a Mon Sep 17 00:00:00 2001 From: Eiichiro Watanabe Date: Sat, 10 Nov 2018 17:27:15 +0900 Subject: server: avoid deadlock peer.ID() uses lock in itself. --- pkg/server/peer.go | 3 ++- pkg/server/server.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/server') diff --git a/pkg/server/peer.go b/pkg/server/peer.go index 1c2e7d41..83a5d12f 100644 --- a/pkg/server/peer.go +++ b/pkg/server/peer.go @@ -215,6 +215,7 @@ func (peer *peer) negotiatedRFList() []bgp.RouteFamily { } func (peer *peer) toGlobalFamilies(families []bgp.RouteFamily) []bgp.RouteFamily { + id := peer.ID() peer.fsm.lock.RLock() defer peer.fsm.lock.RUnlock() if peer.fsm.pConf.Config.Vrf != "" { @@ -228,7 +229,7 @@ func (peer *peer) toGlobalFamilies(families []bgp.RouteFamily) []bgp.RouteFamily default: log.WithFields(log.Fields{ "Topic": "Peer", - "Key": peer.ID(), + "Key": id, "Family": f, "VRF": peer.fsm.pConf.Config.Vrf, }).Warn("invalid family configured for neighbor with vrf") diff --git a/pkg/server/server.go b/pkg/server/server.go index ed78d292..48cdc819 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1695,13 +1695,12 @@ func (s *BgpServer) SetPolicies(ctx context.Context, r *api.SetPoliciesRequest) "Topic": "Peer", "Key": peer.fsm.pConf.State.NeighborAddress, }).Info("call set policy") + peer.fsm.lock.RUnlock() a, err := getConfig(peer.ID()) if err != nil { - peer.fsm.lock.RUnlock() return err } ap[peer.ID()] = *a - peer.fsm.lock.RUnlock() } return s.policy.Reset(rp, ap) }, false) -- cgit v1.2.3