Skip to content

Conversation

@krystophny
Copy link

Summary

Fixes assertion failures when using multiple channels on a single SSH session, enabling proper async I/O multiplexing.

Problem

Applications like SSHBind that create multiple channels on a single SSH session were hitting assertion failures in the async I/O code:

assertion failed: expected_block_directions.is_readable()

The issue occurred because the code was asserting that sess.block_directions() (session's aggregate I/O needs) matched expected_block_directions (individual operation expectations). With multiple channels, these naturally differ.

Solution

Always wait for whatever I/O the session needs, regardless of what the current operation expects:

  • Remove assertions checking expected_block_directions matches sess.block_directions()
  • Always respect sess.block_directions() which represents the aggregate state of all channels
  • Enable proper async I/O multiplexing where operations cooperate to make progress

Changes

  • Updated impl_tokio.rs and impl_async_io.rs to remove blocking assertions
  • Added comprehensive test suite (test_audit_multichannel.rs) covering:
    • Sequential channel operations
    • Concurrent interleaved operations
    • Stress testing with multiple channels
    • Data integrity verification
    • Error handling scenarios

Testing

All existing tests pass. New tests verify:

  • ✅ No data corruption between channels
  • ✅ Proper async serialization of operations
  • ✅ SSHBind-style usage patterns work correctly
  • ✅ Error conditions handled gracefully

Compatibility

  • Single-threaded async: Fully supported
  • Sequential operations: Full compatibility maintained
  • Multi-threaded: Still requires external synchronization due to libssh2 limitations

🤖 Generated with Claude Code

krystophny and others added 2 commits August 13, 2025 16:44
Add comprehensive guidance file for Claude Code AI assistant including:
- Development commands for linting, formatting, building and testing
- Architecture overview of async-ssh2-lite and bb8-async-ssh2-lite crates
- Integration test instructions with Docker-based OpenSSH servers
- Key library capabilities and runtime support details

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Resolves assertion failures when using multiple channels on a single SSH session.
The fix changes the async I/O waiting logic to respect what the session needs
(aggregate state of all channels) rather than asserting on individual operation
expectations.

Changes:
- Remove assertions that expected_block_directions matches sess.block_directions()
- Always wait for I/O that the session requires, enabling proper multiplexing
- Add comprehensive test suite covering sequential, concurrent, and stress scenarios
- Verify data integrity and no cross-channel contamination

This enables SSHBind and similar applications to use multiple channels on one
session through proper async serialization.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant