Skip to content

Commit

Permalink
Fix ctx handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Aug 20, 2019
1 parent 7b2196d commit de2e52d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/setup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (sn *Node) createRoute(ctx context.Context, expireAt time.Time, route routi
resultingRouteIDCh := make(chan routing.RouteID, 2)

// context to cancel rule setup in case of errors
ctx, cancel := context.WithCancel(context.Background())
cancellableCtx, cancel := context.WithCancel(ctx)
for i := len(r) - 1; i >= 0; i-- {
var reqIDChIn, reqIDChOut chan routing.RouteID
// goroutine[0] doesn't need to pass the route ID from the 1st step to anyone
Expand All @@ -277,7 +277,7 @@ func (sn *Node) createRoute(ctx context.Context, expireAt time.Time, route routi

go func(i int, pk cipher.PubKey, rule routing.Rule, reqIDChIn <-chan routing.RouteID,
reqIDChOut chan<- routing.RouteID) {
routeID, err := sn.setupRule(ctx, pk, rule, reqIDChIn, reqIDChOut)
routeID, err := sn.setupRule(cancellableCtx, pk, rule, reqIDChIn, reqIDChOut)
if err != nil {
// filter out context cancellation errors
if err == context.Canceled {
Expand Down

0 comments on commit de2e52d

Please sign in to comment.