Skip to content

Commit 7a31432

Browse files
committed
server: fix ListPath returns context error
Return an error of context properly. Signed-off-by: FUJITA Tomonori <[email protected]>
1 parent 2ce6f13 commit 7a31432

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

pkg/server/grpc_server.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,21 +308,21 @@ func (s *server) listPath(ctx context.Context, r *api.ListPathRequest, fn func(*
308308
}
309309

310310
err := s.bgpServer.ListPath(req, func(prefix bgp.NLRI, paths []*apiutil.Path) {
311-
select {
312-
case <-ctx.Done():
311+
if ctx.Err() != nil {
313312
return
314-
default:
315-
d := api.Destination{
316-
Prefix: prefix.String(),
317-
Paths: make([]*api.Path, len(paths)),
318-
}
319-
for i, path := range paths {
320-
d.Paths[i] = toPathApi(path, r.EnableOnlyBinary, r.EnableNlriBinary, r.EnableAttributeBinary)
321-
}
322-
fn(&d)
323313
}
314+
d := api.Destination{
315+
Prefix: prefix.String(),
316+
Paths: make([]*api.Path, len(paths)),
317+
}
318+
for i, path := range paths {
319+
d.Paths[i] = toPathApi(path, r.EnableOnlyBinary, r.EnableNlriBinary, r.EnableAttributeBinary)
320+
}
321+
fn(&d)
324322
})
325-
323+
if ctx.Err() != nil {
324+
return ctx.Err()
325+
}
326326
return err
327327
}
328328

0 commit comments

Comments
 (0)