Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Dispatching message failed with full channel twice!" #3153

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions handel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ log = { workspace = true }
instant = { version = "0.1", features = ["wasm-bindgen"] }
parking_lot = "0.12"
thiserror = "2.0"
tokio = { version = "1.41", features = ["rt"] }

nimiq-bls = { workspace = true }
nimiq-collections = { workspace = true }
Expand Down
14 changes: 13 additions & 1 deletion handel/src/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use futures::{
stream::{BoxStream, Stream, StreamExt},
};
use nimiq_time::{interval, Interval};
use tokio::task;

use crate::{
config::Config,
Expand Down Expand Up @@ -438,7 +439,18 @@ where

// Poll the input stream for new level updates.
let evaluator = self.protocol.evaluator();
while let Poll::Ready(Some(update)) = self.input_stream.poll_next_unpin(cx) {
while let Poll::Ready(Some(update)) =
// Our caller assumes that calling `poll_next` on this stream
// clears the queue.
//
// The tokio runtime would usually insert spurious `Poll::Pending`s
// for cooperative scheduling, it could happen that we poll and get
// nothing even though there are items in the channel.
//
// Use `task::unconstrained` to make sure that tokio does not
// cooperate from this particular future.
task::unconstrained(self.input_stream.next()).poll_unpin(cx)
{
// Verify the level update.
if let Err(error) = evaluator.verify(&update) {
warn!(
Expand Down