Skip to content

Commit

Permalink
more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Sep 28, 2023
1 parent 3c0bc21 commit 2c92e50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
4 changes: 3 additions & 1 deletion p2p/protocol/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ func (p *PingService) PingHandler(s network.Stream) {
for {
_, err := io.ReadFull(s, buf)
if err != nil {
log.Error("read failed: ", err)
errCh <- err
return
}

_, err = s.Write(buf)
if err != nil {
log.Error("write failed: ", err)
errCh <- err
return
}
log.Error("written to stream")
log.Error("one ping done")
timer.Reset(pingTimeout)
}
}
Expand Down
18 changes: 1 addition & 17 deletions p2p/transport/webrtc/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,7 @@ func newStream(
}
}

if s.isDone() {
// onDone removes the stream from the connection and requires the connection lock.
// This callback(onBufferedAmountLow) is executing in the sctp readLoop goroutine.
// If Connection.Close is called concurrently, the closing goroutine will acquire
// the connection lock and wait for sctp readLoop to exit, the sctp readLoop will
// wait for the connection lock before exiting, causing a deadlock.
// Run this in a different goroutine to avoid the deadlock.
go func() {
s.mx.Lock()
defer s.mx.Unlock()
// TODO: we should be closing the underlying datachannel, but this resets the stream
// See https://github.com/libp2p/specs/issues/575 for details.
// _ = s.dataChannel.Close()
// TODO: write for the spawned reader to return
s.onDone()
}()
}
s.maybeDeclareStreamDone()

select {
case s.writeAvailable <- struct{}{}:
Expand Down

0 comments on commit 2c92e50

Please sign in to comment.