Commit d1c577e3 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet
Browse files

p2p/net/swarm/listener: consume peerstream listeners

parent a1aec82c
...@@ -66,8 +66,30 @@ func (s *Swarm) setupListener(maddr ma.Multiaddr) error { ...@@ -66,8 +66,30 @@ func (s *Swarm) setupListener(maddr ma.Multiaddr) error {
// AddListener to the peerstream Listener. this will begin accepting connections // AddListener to the peerstream Listener. this will begin accepting connections
// and streams! // and streams!
_, err = s.swarm.AddListener(list) sl, err := s.swarm.AddListener(list)
if err != nil {
return err 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 // connHandler is called by the StreamSwarm whenever a new connection is added
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment