@@ -37,6 +37,7 @@ pub(crate) struct Dispatcher<'a, TlsSt, S, ReqB> {
3737 addr : SocketAddr ,
3838 keep_alive : Pin < & ' a mut KeepAlive > ,
3939 ka_dur : Duration ,
40+ pong_timeout : Duration ,
4041 service : & ' a S ,
4142 date : & ' a DateTimeHandle ,
4243 _req_body : PhantomData < ReqB > ,
5859 addr : SocketAddr ,
5960 keep_alive : Pin < & ' a mut KeepAlive > ,
6061 ka_dur : Duration ,
62+ pong_timeout : Duration ,
6163 service : & ' a S ,
6264 date : & ' a DateTimeHandle ,
6365 ) -> Self {
6668 addr,
6769 keep_alive,
6870 ka_dur,
71+ pong_timeout,
6972 service,
7073 date,
7174 _req_body : PhantomData ,
7881 addr,
7982 mut keep_alive,
8083 ka_dur,
84+ pong_timeout,
8185 service,
8286 date,
8387 ..
96100 ping_pong,
97101 date,
98102 ka_dur,
103+ pong_timeout,
99104 } ;
100105
101106 let mut queue = Queue :: new ( ) ;
@@ -163,6 +168,7 @@ struct H2PingPong<'a> {
163168 ping_pong : PingPong ,
164169 date : & ' a DateTimeHandle ,
165170 ka_dur : Duration ,
171+ pong_timeout : Duration ,
166172}
167173
168174impl Future for H2PingPong < ' _ > {
@@ -195,10 +201,9 @@ impl Future for H2PingPong<'_> {
195201
196202 this. ping_pong . send_ping ( Ping :: opaque ( ) ) ?;
197203
198- // Update the keep alive to 10 times the normal keep alive duration.
199- // There is no particular reason for the duration choice here. as h2 connection is
200- // suggested to be kept alive for a relative long time.
201- let deadline = this. date . now ( ) + ( this. ka_dur * 10 ) ;
204+ // Update the keep alive to the pong timeout, if pong is not received within this
205+ // time. The connection is considered dead.
206+ let deadline = this. date . now ( ) + this. ka_dur + this. pong_timeout ;
202207
203208 this. keep_alive . as_mut ( ) . update ( deadline) ;
204209
0 commit comments