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

Fix constructor ordering #698

Merged
merged 3 commits into from
Dec 9, 2020
Merged

Fix constructor ordering #698

merged 3 commits into from
Dec 9, 2020

Conversation

aschmahmann
Copy link
Contributor

@aschmahmann aschmahmann commented Dec 2, 2020

fixes #697

We seem to have a ordering problem where

go-libp2p-kad-dht/dht.go

Lines 212 to 227 in 7db4172

// register for event bus and network notifications
sn, err := newSubscriberNotifiee(dht)
if err != nil {
return nil, err
}
dht.proc.Go(sn.subscribe)
// handle providers
dht.proc.AddChild(dht.ProviderManager.Process())
dht.proc.Go(dht.populatePeers)
// go-routine to make sure we ALWAYS have RT peer addresses in the peerstore
// since RT membership is decoupled from connectivity
go dht.persistRTPeersInPeerStore()
dht.proc.Go(dht.rtPeerLoop)

subscriberNotifiee is called before rtPeerLoop is started this means that:

// Fill routing table with currently connected peers that are DHT servers
dht.plk.Lock()
defer dht.plk.Unlock()
for _, p := range dht.host.Network().Peers() {
dht.peerFound(dht.ctx, p, false)
}

is called which calls:

go-libp2p-kad-dht/dht.go

Lines 682 to 686 in 7db4172

select {
case dht.addPeerToRTChan <- addPeerRTReq{p, queryPeer}:
case <-dht.ctx.Done():
return
}

which happens before we've started processing the channel in rtPeerLoop

case addReq := <-dht.addPeerToRTChan:

Copy link
Contributor

@petar petar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@aschmahmann aschmahmann merged commit 09d923f into master Dec 9, 2020
@aschmahmann aschmahmann deleted the fix/697 branch December 9, 2020 00:56
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New hangs when started with option ModeServer
2 participants