Skip to content

Commit

Permalink
Fix infinite loop in single-stream connection (#2751)
Browse files Browse the repository at this point in the history
Fix #2750
  • Loading branch information
tomaka authored Sep 16, 2022
1 parent c660afd commit 13fe1fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bin/wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- Fix potential infinite loop in networking connection task. ([#2751](https://github.com/paritytech/smoldot/pull/2751))

### Changed

- No longer try to connect to a peer for 20 seconds after failing to connect to it. This prevents loops where we keep trying to connect to the same address(es) over and over again ([#2747](https://github.com/paritytech/smoldot/pull/2747)).
Expand Down
11 changes: 7 additions & 4 deletions src/libp2p/connection/established/single_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,14 @@ where

if let Some(event) = event {
return Ok((self, Some(event)));
} else if num_read == 0 {
// Substream doesn't accept anymore data because it is blocked on writing out.
return Ok((self, None));
} else {
// Jump back to the beginning of the loop. We don't want to read more data
// until this specific substream's data has been processed.
continue;
}

// Jump back to the beginning of the loop. We don't want to read more data until
// this specific substream's data has been processed.
continue;
}

// Transfer data from `incoming_data` to the internal buffer in `self.encryption`.
Expand Down

0 comments on commit 13fe1fe

Please sign in to comment.