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

server: replace FutureDriver with tokio::spawn #1080

Merged
merged 12 commits into from
Apr 17, 2023

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Apr 13, 2023

Close #1063

@niklasad1 niklasad1 changed the title WIP: remove future driver tokio spawn server: replace FutureDriver with tokio::spawn Apr 14, 2023
@niklasad1 niklasad1 marked this pull request as ready for review April 14, 2023 12:04
@niklasad1 niklasad1 requested a review from a team as a code owner April 14, 2023 12:04
@@ -419,21 +356,19 @@ pub(crate) async fn background_task<L: Logger>(
async fn send_task(
rx: mpsc::Receiver<String>,
mut ws_sender: Sender,
stop_handle: StopHandle,
Copy link
Member Author

@niklasad1 niklasad1 Apr 14, 2023

Choose a reason for hiding this comment

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

Basically, the stop handle was passed directly to send task and that stopped when it got the stop signal but it could be the case the pending calls were still in the queue and those were just canceled

so, I changed that we wait until those pending calls are finished and then stop

server/src/transport/ws.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

Looks good to me offhand :)

// executed and the connection has been closed.
tokio::select! {
// All pending calls executed.
_ = pending_calls.for_each(|_| async {}) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

So, we could also timeout out this after 10 minutes or something if someone has a infinite loop or something that never returns in some scenario it may "leak" and never terminate...


module
.register_async_method("infinite_call", |_, _| async move {
futures_util::future::pending::<()>().await;
Copy link
Member Author

@niklasad1 niklasad1 Apr 17, 2023

Choose a reason for hiding this comment

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

This a really bad and shouldn't be used in "real code" but just a way to ensure that the futures won't ever complete.

@niklasad1 niklasad1 merged commit 9c58d09 into master Apr 17, 2023
@niklasad1 niklasad1 deleted the na-remove-future-driver-tokio-spawn branch April 17, 2023 11:07
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.

remove FutureDriver
4 participants