Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfetcher: do recursive request in parallel #3836

Merged
merged 2 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go/cs/segreq/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func newRouter(cfg FetcherConfig, fetcher *segfetcher.Fetcher) snet.Router {
cfg.TopoProvider.Get().Core(),
cfg.Inspector,
cfg.PathDB),
Fetcher: fetcher,
Fetcher: fetcher,
HeaderV2: cfg.HeaderV2,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions go/lib/infra/modules/segfetcher/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ go_library(
"//go/lib/topology:go_default_library",
"//go/pkg/trust:go_default_library",
"//go/proto:go_default_library",
"@com_github_opentracing_opentracing_go//:go_default_library",
],
)

Expand Down
21 changes: 16 additions & 5 deletions go/lib/infra/modules/segfetcher/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"net"
"sync"

"github.com/opentracing/opentracing-go"

"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
"github.com/scionproto/scion/go/lib/infra/messenger"
"github.com/scionproto/scion/go/lib/log"
Expand Down Expand Up @@ -65,15 +67,24 @@ func (r *DefaultRequester) Request(ctx context.Context, reqs Requests) <-chan Re
var wg sync.WaitGroup
for i := range reqs {
req := reqs[i]
dst, err := r.DstProvider.Dst(ctx, req)
if err != nil {
replies <- ReplyOrErr{Req: req, Err: err}
continue
}
span, ctx := opentracing.StartSpanFromContext(ctx, "segfetcher.requester",
opentracing.Tags{
"req.src": req.Src.String(),
"req.dst": req.Dst.String(),
"req.seg_type": req.SegType.String(),
},
)
wg.Add(1)
go func() {
defer log.HandlePanic()
defer wg.Done()
defer span.Finish()

dst, err := r.DstProvider.Dst(ctx, req)
if err != nil {
replies <- ReplyOrErr{Req: req, Err: err}
return
}
reply, err := r.API.GetSegs(ctx, req.ToSegReq(), dst, messenger.NextId())
replies <- ReplyOrErr{Req: req, Reply: reply, Peer: dst, Err: err}
}()
Expand Down