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
Commits
0ceac5de
Commit
0ceac5de
authored
Jun 22, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use WithContextAndTeardown whenever possible
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
bcae8392
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
13 deletions
+7
-13
core/core.go
core/core.go
+2
-4
p2p/net/conn/listen.go
p2p/net/conn/listen.go
+1
-2
p2p/net/mock/mock_peernet.go
p2p/net/mock/mock_peernet.go
+1
-2
p2p/net/swarm/swarm.go
p2p/net/swarm/swarm.go
+1
-2
routing/dht/dht.go
routing/dht/dht.go
+2
-3
No files found.
core/core.go
View file @
0ceac5de
...
...
@@ -128,15 +128,13 @@ func NewIPFSNode(ctx context.Context, option ConfigOption) (*IpfsNode, error) {
return
nil
,
err
}
proc
:=
goprocessctx
.
WithContext
(
ctx
)
proc
.
SetTeardown
(
node
.
teardown
)
node
.
proc
=
proc
node
.
proc
=
goprocessctx
.
WithContextAndTeardown
(
ctx
,
node
.
teardown
)
node
.
ctx
=
ctx
success
:=
false
// flip to true after all sub-system inits succeed
defer
func
()
{
if
!
success
{
proc
.
Close
()
node
.
proc
.
Close
()
}
}()
...
...
p2p/net/conn/listen.go
View file @
0ceac5de
...
...
@@ -158,9 +158,8 @@ func Listen(ctx context.Context, addr ma.Multiaddr, local peer.ID, sk ic.PrivKey
Listener
:
ml
,
local
:
local
,
privk
:
sk
,
proc
:
goprocessctx
.
WithContext
(
ctx
),
}
l
.
proc
.
Set
Teardown
(
l
.
teardown
)
l
.
proc
=
goprocessctx
.
WithContextAnd
Teardown
(
ctx
,
l
.
teardown
)
log
.
Debugf
(
"Conn Listener on %s"
,
l
.
Multiaddr
())
log
.
Event
(
ctx
,
"swarmListen"
,
l
)
...
...
p2p/net/mock/mock_peernet.go
View file @
0ceac5de
...
...
@@ -58,7 +58,6 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
mocknet
:
m
,
peer
:
p
,
ps
:
ps
,
proc
:
goprocessctx
.
WithContext
(
ctx
),
connsByPeer
:
map
[
peer
.
ID
]
map
[
*
conn
]
struct
{}{},
connsByLink
:
map
[
*
link
]
map
[
*
conn
]
struct
{}{},
...
...
@@ -66,7 +65,7 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
notifs
:
make
(
map
[
inet
.
Notifiee
]
struct
{}),
}
n
.
proc
.
Set
Teardown
(
n
.
teardown
)
n
.
proc
=
goprocessctx
.
WithContextAnd
Teardown
(
ctx
,
n
.
teardown
)
return
n
,
nil
}
...
...
p2p/net/swarm/swarm.go
View file @
0ceac5de
...
...
@@ -82,7 +82,6 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
swarm
:
ps
.
NewSwarm
(
PSTransport
),
local
:
local
,
peers
:
peers
,
proc
:
goprocessctx
.
WithContext
(
ctx
),
ctx
:
ctx
,
dialT
:
DialTimeout
,
notifs
:
make
(
map
[
inet
.
Notifiee
]
ps
.
Notifiee
),
...
...
@@ -91,7 +90,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
}
// configure Swarm
s
.
proc
.
Set
Teardown
(
s
.
teardown
)
s
.
proc
=
goprocessctx
.
WithContextAnd
Teardown
(
ctx
,
s
.
teardown
)
s
.
SetConnHandler
(
nil
)
// make sure to setup our own conn handler.
// setup swarm metrics
...
...
routing/dht/dht.go
View file @
0ceac5de
...
...
@@ -73,13 +73,12 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
// register for network notifs.
dht
.
host
.
Network
()
.
Notify
((
*
netNotifiee
)(
dht
))
proc
:=
goprocessctx
.
WithContext
(
ctx
)
proc
.
SetTeardown
(
func
()
error
{
dht
.
proc
=
goprocessctx
.
WithContextAndTeardown
(
ctx
,
func
()
error
{
// remove ourselves from network notifs.
dht
.
host
.
Network
()
.
StopNotify
((
*
netNotifiee
)(
dht
))
return
nil
})
dht
.
proc
=
proc
dht
.
ctx
=
ctx
h
.
SetStreamHandler
(
ProtocolDHT
,
dht
.
handleNewStream
)
...
...
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