From 84d73c1b45006c40764c1587207b5ad67598e893 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Mon, 9 Nov 2015 14:14:16 -0800 Subject: server: move POLICY_DIRECTION_IN processing from peer to fsm For parallel processing. Each peer's rx goroutine can process IN policy. Note that RWLock() should be called in looking at policies via grpc too but such operaitons are done in the main goroutine so not called. Signed-off-by: FUJITA Tomonori --- server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index 9c160e8b..d6aad66c 100644 --- a/server/server.go +++ b/server/server.go @@ -30,6 +30,7 @@ import ( "os" "strconv" "strings" + "sync" "time" ) @@ -37,6 +38,8 @@ const ( GLOBAL_RIB_NAME = "global" ) +var policyMutex sync.RWMutex + type SenderMsg struct { messages []*bgp.BGPMessage sendCh chan *bgp.BGPMessage @@ -2000,6 +2003,8 @@ func (server *BgpServer) policyInUse(x *table.Policy) bool { } func (server *BgpServer) handleGrpcModPolicy(grpcReq *GrpcRequest) error { + policyMutex.Lock() + defer policyMutex.Unlock() arg := grpcReq.Data.(*api.ModPolicyArguments) x, err := table.NewPolicyFromApiStruct(arg.Policy, server.policy.DefinedSetMap) if err != nil { @@ -2121,6 +2126,8 @@ func (server *BgpServer) handleGrpcModPolicyAssignment(grpcReq *GrpcRequest) err var err error var dir table.PolicyDirection var i policyPoint + policyMutex.Lock() + defer policyMutex.Unlock() arg := grpcReq.Data.(*api.ModPolicyAssignmentArguments) assignment := arg.Assignment i, dir, err = server.getPolicyInfo(assignment) -- cgit v1.2.3