Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
2a7f53f7
Commit
2a7f53f7
authored
Jun 22, 2015
by
rht
Browse files
Use WithContextAndTeardown whenever possible
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
316ba886
Changes
3
Hide whitespace changes
Inline
Side-by-side
net/conn/listen.go
View file @
2a7f53f7
...
...
@@ -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
)
...
...
net/mock/mock_peernet.go
View file @
2a7f53f7
...
...
@@ -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
}
...
...
net/swarm/swarm.go
View file @
2a7f53f7
...
...
@@ -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
...
...
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