diff --git a/dial_sync.go b/dial_sync.go index 734901fc..69739e54 100644 --- a/dial_sync.go +++ b/dial_sync.go @@ -36,7 +36,6 @@ type activeDial struct { } func (dr *activeDial) wait(ctx context.Context) (*Conn, error) { - dr.incref() defer dr.decref() select { case <-dr.waitch: @@ -97,6 +96,9 @@ func (ds *DialSync) getActiveDial(p peer.ID) *activeDial { go actd.start(adctx) } + // increase ref count before dropping dialsLk + actd.incref() + return actd }