Commit 14d544b8 authored by Steven Allen's avatar Steven Allen

fix: do not use the request context when dialing

Otherwise, canceling one dial request will cancel all "joined" dial requests.
parent d73f313e
......@@ -96,13 +96,17 @@ func (ad *activeDial) start(ctx context.Context) {
ad.cancel()
}
func (ds *DialSync) getActiveDial(ctx context.Context, p peer.ID) *activeDial {
func (ds *DialSync) getActiveDial(p peer.ID) *activeDial {
ds.dialsLk.Lock()
defer ds.dialsLk.Unlock()
actd, ok := ds.dials[p]
if !ok {
adctx, cancel := context.WithCancel(ctx)
// This code intentionally uses the background context. Otherwise, if the first call
// to Dial is canceled, subsequent dial calls will also be canceled.
// XXX: this also breaks direct connection logic. We will need to pipe the
// information through some other way.
adctx, cancel := context.WithCancel(context.Background())
actd = &activeDial{
id: p,
cancel: cancel,
......@@ -123,7 +127,7 @@ func (ds *DialSync) getActiveDial(ctx context.Context, p peer.ID) *activeDial {
// DialLock initiates a dial to the given peer if there are none in progress
// then waits for the dial to that peer to complete.
func (ds *DialSync) DialLock(ctx context.Context, p peer.ID) (*Conn, error) {
return ds.getActiveDial(ctx, p).wait(ctx)
return ds.getActiveDial(p).wait(ctx)
}
// CancelDial cancels all in-progress dials to the given peer.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment