Skip to content

Conversation

@ThinkerDreamer
Copy link
Member

@ThinkerDreamer ThinkerDreamer commented Jan 22, 2026

Summary

  • MeasureManyStream now returns None when all pings complete, allowing while let loops to exit
  • Added v4_done/v6_done tracking to DualstackMeasureManyStream for proper completion

Problem

The stream never returned None to signal completion. After all ping responses were received, poll_next_unpin would return Poll::Pending forever, causing while let Some(...) = stream.next().await loops to hang indefinitely.

Solution

  • BREAKING CHANGE! Changed poll_next_unpin return type from Poll<(V, Duration)> to Poll<Option<(V, Duration)>>
  • Added completion check: when send_queue is empty AND in_flight is empty, return Poll::Ready(None)
  • Updated Stream impl to pass through the Option directly
  • Added completion state tracking to DualstackMeasureManyStream

Test plan

  • New regression tests verify stream terminates after single/multiple pings
  • Test verifies empty address list terminates immediately
  • Tests run on both current_thread and multi_thread runtimes
  • All existing tests pass

Closes #3

@ThinkerDreamer
Copy link
Member Author

This PR also includes the changes from #2 currently while we wait for that to be merged.

Copy link

@dodomorandi dodomorandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs a rebase

The stream now returns None when all ping requests have been sent and
all responses received. Previously, poll_next_unpin would return
Poll::Pending forever after processing all results, causing
while let loops to hang indefinitely.

Changes:
- poll_next_unpin now returns Poll<Option<...>> instead of Poll<...>
- Added completion check: when send_queue is empty AND in_flight is
  empty, return Poll::Ready(None)
- Updated Stream impl to pass through the Option directly
- Added v4_done/v6_done flags to DualstackMeasureManyStream to
  track completion state of both underlying streams
- Removed unused task::ready imports

Closes M4SS-Code#3
Tests verify that MeasureManyStream properly returns None when:
- Single ping completes
- Multiple pings to different addresses complete
- Empty address list is provided

Tests run on both current_thread and multi_thread runtimes.
@paolobarbolini paolobarbolini merged commit 4fbc22f into M4SS-Code:main Jan 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MeasureManyStream never terminates (returns None)

3 participants