Skip to content

Infinite task wakeup after an h2 connection being shutdown #25

@bdbai

Description

@bdbai

Code to reproduce:

use compio::time::sleep;
use cyper::Client;
use http::Version;
use std::time::Duration;

#[compio::main]
async fn main() {
    let client = Client::new();
    println!("Send request 1");
    let response = client
        .get("https://example.com/")
        .unwrap()
        .version(Version::HTTP_2)
        .send()
        .await
        .unwrap();
    println!("Request 1 done, sleeping");
    sleep(Duration::from_secs(180)).await;
    println!("Send request 2");
    client
        .get("https://example.com/")
        .unwrap()
        .version(Version::HTTP_2)
        .send()
        .await
        .unwrap();
    println!("Now check your CPU usage");
    loop {
        sleep(Duration::from_secs(600)).await;
    }
}

Debugger shows that the task is being woken up unconditionally in h2's Connection::poll without any scheduling. Initial investigation might indicate the following issues:

  • The shutdown op in cyper (or compio) never finishes in this scenario, and/or
  • The h2 crate never considers a runtime where shutdown does not return Poll::Ready immediately, leading to a flawed poll implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions