Skip to content

Commit

Permalink
Fix lock in the managed routing table
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Aug 23, 2019
1 parent 9b3ad84 commit 4d6f014
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/router/managed_routing_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ func manageRoutingTable(rt routing.Table) *managedRoutingTable {
}

func (rt *managedRoutingTable) AddRule(rule routing.Rule) (routing.RouteID, error) {
rt.mu.Lock()
defer rt.mu.Unlock()

routeID, err := rt.Table.AddRule(rule)
if err != nil {
return 0, err
}

rt.mu.Lock()
// set the initial activity for rule not to be timed out instantly
rt.activity[routeID] = time.Now()
rt.mu.Unlock()

return routeID, nil
}
Expand Down

0 comments on commit 4d6f014

Please sign in to comment.