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

Refactor wait(::Session) so that the polling happens asynchronously #17

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

JamesWrigley
Copy link
Collaborator

Previously each call to wait(::Session) would poll the sessions file descriptor individually. This is kinda not great because one caller may be woken up for some data that's intended for another caller. In practice this hasn't caused problems so far because most of LibSSH's usage has been in the tests where we do a single operation at a time, but the new architecture should be safer.

Now there's a separate waiter task that lives for as long as the session that can be woken up by callers wanting to wait() on the session, who will in turn be woken up whenever the waiter tasks polls the session file descriptor successfully. i.e. it turns the waiting from a 1-to-1 thing to a 1-to-many thing.

@JamesWrigley JamesWrigley self-assigned this Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 92.13483% with 7 lines in your changes missing coverage. Please review.

Project coverage is 60.43%. Comparing base (4dcead5) to head (c7028a3).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/session.jl 92.59% 4 Missing ⚠️
src/LibSSH.jl 66.66% 1 Missing ⚠️
src/server.jl 88.88% 1 Missing ⚠️
src/sftp.jl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage   59.52%   60.43%   +0.91%     
==========================================
  Files          11       11              
  Lines        2777     2836      +59     
==========================================
+ Hits         1653     1714      +61     
+ Misses       1124     1122       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Previously each call to `wait(::Session)` would poll the sessions file
descriptor individually. This is kinda not great because one caller may be woken
up for some data that's intended for another caller. In practice this hasn't
caused problems so far because most of LibSSH's usage has been in the tests
where we do a single operation at a time, but the new architecture should be
safer.

Now there's a separate waiter task that lives for as long as the session that
can be woken up by callers wanting to wait() on the session, who will in turn be
woken up whenever the waiter tasks polls the session file descriptor
successfully. i.e. it turns the waiting from a 1-to-1 thing to a 1-to-many
thing.
@JamesWrigley JamesWrigley merged commit a509680 into master Oct 10, 2024
6 checks passed
@JamesWrigley JamesWrigley deleted the polling branch October 10, 2024 14:23
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