Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-routing
Commits
b3235e16
Commit
b3235e16
authored
Jul 05, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure process context is set last
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
d3b46b8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
+3
-5
dht/dht.go
dht/dht.go
+2
-1
dht/query.go
dht/query.go
+1
-4
No files found.
dht/dht.go
View file @
b3235e16
...
...
@@ -73,7 +73,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
// register for network notifs.
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
dht
.
proc
=
goprocess
ctx
.
With
ContextAnd
Teardown
(
ctx
,
func
()
error
{
dht
.
proc
=
goprocess
.
WithTeardown
(
func
()
error
{
// remove ourselves from network notifs.
dht
.
host
.
Network
()
.
StopNotify
((
*
netNotifiee
)(
dht
))
return
nil
...
...
@@ -84,6 +84,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
h
.
SetStreamHandler
(
ProtocolDHT
,
dht
.
handleNewStream
)
dht
.
providers
=
NewProviderManager
(
dht
.
ctx
,
dht
.
self
)
dht
.
proc
.
AddChild
(
dht
.
providers
.
proc
)
goprocessctx
.
CloseAfterContext
(
dht
.
proc
,
ctx
)
dht
.
routingTable
=
kb
.
NewRoutingTable
(
20
,
kb
.
ConvertPeerID
(
dht
.
self
),
time
.
Minute
,
dht
.
peerstore
)
dht
.
birth
=
time
.
Now
()
...
...
dht/query.go
View file @
b3235e16
...
...
@@ -127,10 +127,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
// now, if the context finishes, close the proc.
// we have to do it here because the logic before is setup, which
// should run without closing the proc.
go
func
()
{
<-
ctx
.
Done
()
r
.
proc
.
Close
()
}()
ctxproc
.
CloseAfterContext
(
r
.
proc
,
ctx
)
select
{
case
<-
r
.
peersRemaining
.
Done
()
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment