Commit 602b30a4 authored by Petar Radovic's avatar Petar Radovic Committed by GitHub

Handle zombie streams with fullclose - pingpong (#401)

* add stream fullclose to pingpong to reset the stream in the case of an error
parent 44a37a10
...@@ -72,7 +72,9 @@ func (s *Service) Ping(ctx context.Context, address swarm.Address, msgs ...strin ...@@ -72,7 +72,9 @@ func (s *Service) Ping(ctx context.Context, address swarm.Address, msgs ...strin
if err != nil { if err != nil {
return 0, fmt.Errorf("new stream: %w", err) return 0, fmt.Errorf("new stream: %w", err)
} }
defer stream.Close() defer func() {
go stream.FullClose()
}()
w, r := protobuf.NewWriterAndReader(stream) w, r := protobuf.NewWriterAndReader(stream)
...@@ -100,7 +102,7 @@ func (s *Service) Ping(ctx context.Context, address swarm.Address, msgs ...strin ...@@ -100,7 +102,7 @@ func (s *Service) Ping(ctx context.Context, address swarm.Address, msgs ...strin
func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) error { func (s *Service) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) error {
w, r := protobuf.NewWriterAndReader(stream) w, r := protobuf.NewWriterAndReader(stream)
defer stream.Close() defer stream.FullClose()
span, logger, ctx := s.tracer.StartSpanFromContext(ctx, "pingpong-p2p-handler", s.logger) span, logger, ctx := s.tracer.StartSpanFromContext(ctx, "pingpong-p2p-handler", s.logger)
defer span.Finish() defer span.Finish()
......
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