summaryrefslogtreecommitdiffhomepage
path: root/pkg/server
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2018-11-10 17:27:15 +0900
committerEiichiro Watanabe <a16tochjp@gmail.com>2018-11-10 18:35:17 +0900
commit360f72818b60d471da1bf8cd673272e927595d4a (patch)
tree85c230dbe1d59fc96b1f45886ae180c1d5a996a2 /pkg/server
parent076d019b75c058456f64b97c90b48f69c7dd1877 (diff)
server: avoid deadlock
peer.ID() uses lock in itself.
Diffstat (limited to 'pkg/server')
-rw-r--r--pkg/server/peer.go3
-rw-r--r--pkg/server/server.go3
2 files changed, 3 insertions, 3 deletions
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)