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

Periodically wake DriverSelect so we can poll whether or not stop had been called. #556

Merged
merged 4 commits into from
Nov 11, 2021

Conversation

maciejhirsz
Copy link
Contributor

Fixes #549. This is all pretty esoteric, but TL;DR is:

  • The loop in the per-connection background task has been reworked to more closely resemble the loop in accepting incoming connections, making sure we check the StopMonitor every time the driver has been polled.
  • Added an Interval internally in FutureDriver, which is only polled in the DriverSelect instances. It effectively triggers a forced poll every second, which checks the stop flag, which will shut down all loops.

The tests are now properly terminating without having to drop the client (with a 1s delay):

$ cargo test --test resource_limiting
   Compiling jsonrpsee-integration-tests v0.4.1 (/home/maciej/rust/jsonrpsee/tests)
    Finished test [unoptimized + debuginfo] target(s) in 2.94s
     Running tests/resource_limiting.rs (target/debug/deps/resource_limiting-17aaec4a6e8ab5eb)

running 4 tests
test http_server_with_macro_module ... ok
test http_server_with_manual_module ... ok
test ws_server_with_manual_module ... ok
test ws_server_with_macro_module ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.00s

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

LGTM,

Did you run benches by any chance?

ws-server/src/future.rs Outdated Show resolved Hide resolved
FutureDriver { futures: Vec::new() }
let mut heartbeat = time::interval(Duration::from_millis(POLLING_HEARTBEAT));

heartbeat.set_missed_tick_behavior(time::MissedTickBehavior::Skip);
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

ws-server/src/future.rs Outdated Show resolved Hide resolved
ws-server/src/server.rs Outdated Show resolved Hide resolved
ws-server/src/server.rs Outdated Show resolved Hide resolved
ws-server/src/server.rs Outdated Show resolved Hide resolved
ws-server/src/future.rs Outdated Show resolved Hide resolved
maciejhirsz and others added 2 commits November 11, 2021 15:35
Co-authored-by: David <dvdplm@gmail.com>
@maciejhirsz maciejhirsz merged commit aacf7c0 into master Nov 11, 2021
@maciejhirsz maciejhirsz deleted the mh-stop-handle-fix branch November 11, 2021 15:53
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.

WsServer not shutting down if a connected client stays idle
3 participants