Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions http/src/h2/proto/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub(crate) struct Dispatcher<'a, TlsSt, S, ReqB> {
addr: SocketAddr,
keep_alive: Pin<&'a mut KeepAlive>,
ka_dur: Duration,
pong_timeout: Duration,
service: &'a S,
date: &'a DateTimeHandle,
_req_body: PhantomData<ReqB>,
Expand All @@ -56,6 +57,7 @@ where
addr: SocketAddr,
keep_alive: Pin<&'a mut KeepAlive>,
ka_dur: Duration,
pong_timeout: Duration,
service: &'a S,
date: &'a DateTimeHandle,
) -> Self {
Expand All @@ -64,6 +66,7 @@ where
addr,
keep_alive,
ka_dur,
pong_timeout,
service,
date,
_req_body: PhantomData,
Expand All @@ -76,6 +79,7 @@ where
addr,
mut keep_alive,
ka_dur,
pong_timeout,
service,
date,
..
Expand All @@ -94,6 +98,7 @@ where
ping_pong,
date,
ka_dur,
pong_timeout,
};

let mut queue = Queue::new();
Expand Down Expand Up @@ -161,6 +166,7 @@ struct H2PingPong<'a> {
ping_pong: PingPong,
date: &'a DateTimeHandle,
ka_dur: Duration,
pong_timeout: Duration,
}

impl Future for H2PingPong<'_> {
Expand Down Expand Up @@ -193,10 +199,9 @@ impl Future for H2PingPong<'_> {

this.ping_pong.send_ping(Ping::opaque())?;

// Update the keep alive to 10 times the normal keep alive duration.
// There is no particular reason for the duration choice here. as h2 connection is
// suggested to be kept alive for a relative long time.
let deadline = this.date.now() + (this.ka_dur * 10);
// Update the keep alive to the pong timeout, if pong is not received within this
// time. The connection is considered dead.
let deadline = this.date.now() + this.ka_dur + this.pong_timeout;

this.keep_alive.as_mut().update(deadline);

Expand Down
1 change: 1 addition & 0 deletions http/src/h2/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ where
addr,
timer,
self.config.keep_alive_timeout,
self.config.keep_alive_timeout,
&self.service,
self.date.get(),
);
Expand Down
1 change: 1 addition & 0 deletions http/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ where
_addr,
timer.as_mut(),
self.config.keep_alive_timeout,
self.config.keep_alive_timeout,
&self.service,
self.date.get(),
)
Expand Down
Loading