hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

h1_header_read_timeout_running is never set to true #2888

Closed silence-coding closed 2 years ago

silence-coding commented 2 years ago

https://github.com/hyperium/hyper/blob/78de8914eadeab4b9a2c71a82c77b2ce33fe6c74/src/proto/h1/io.rs#L195

silence-coding commented 2 years ago

maybe fix

https://github.com/hyperium/hyper/blob/4545c3ef191ce9b5f5d250ee27c4c96f9b71d2c6/src/proto/h1/role.rs#L83

    #[cfg(all(feature = "server", feature = "runtime"))]
    if !*ctx.h1_header_read_timeout_running {
        if let Some(h1_header_read_timeout) = ctx.h1_header_read_timeout {
            let deadline = Instant::now() + h1_header_read_timeout;
            ctx.h1_header_read_timeout_running = true;
            match ctx.h1_header_read_timeout_fut {
                Some(h1_header_read_timeout_fut) => {
                    debug!("resetting h1 header read timeout timer");
                    h1_header_read_timeout_fut.as_mut().reset(deadline);
                }
                None => {
                    debug!("setting h1 header read timeout timer");
                    *ctx.h1_header_read_timeout_fut =
                        Some(Box::pin(tokio::time::sleep_until(deadline)));
                }
            }
        }
    }
silence-coding commented 2 years ago

@paolobarbolini

paolobarbolini commented 2 years ago

I don't currently have time to test it but the fix looks right, if you'd like to send the PR before I get to it