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
d1c577e3
Commit
d1c577e3
authored
Jan 11, 2015
by
Juan Batiz-Benet
Browse files
p2p/net/swarm/listener: consume peerstream listeners
parent
a1aec82c
Changes
1
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm_listen.go
View file @
d1c577e3
...
...
@@ -66,8 +66,30 @@ func (s *Swarm) setupListener(maddr ma.Multiaddr) error {
// AddListener to the peerstream Listener. this will begin accepting connections
// and streams!
_
,
err
=
s
.
swarm
.
AddListener
(
list
)
return
err
sl
,
err
:=
s
.
swarm
.
AddListener
(
list
)
if
err
!=
nil
{
return
err
}
// go consume peerstream's listen accept errors. note, these ARE errors.
// they may be killing the listener, and if we get _any_ we should be
// fixing this in our conn.Listener (to ignore them or handle them
// differently.)
go
func
(
ctx
context
.
Context
,
sl
*
ps
.
Listener
)
{
for
{
select
{
case
err
,
more
:=
<-
sl
.
AcceptErrors
()
:
if
!
more
{
return
}
log
.
Info
(
err
)
case
<-
ctx
.
Done
()
:
return
}
}
}(
s
.
cg
.
Context
(),
sl
)
return
nil
}
// connHandler is called by the StreamSwarm whenever a new connection is added
...
...
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