@@ -43,7 +43,8 @@ struct ConnectionState {
43
43
readiness : RefCell < VecDeque < pool:: Sender < ( ) > > > ,
44
44
45
45
rst_count : Cell < u32 > ,
46
- total_count : Cell < u32 > ,
46
+ streams_count : Cell < u32 > ,
47
+ pings_count : Cell < u16 > ,
47
48
48
49
// Local config
49
50
local_config : Config ,
@@ -105,7 +106,8 @@ impl Connection {
105
106
active_remote_streams : Cell :: new ( 0 ) ,
106
107
active_local_streams : Cell :: new ( 0 ) ,
107
108
rst_count : Cell :: new ( 0 ) ,
108
- total_count : Cell :: new ( 0 ) ,
109
+ streams_count : Cell :: new ( 0 ) ,
110
+ pings_count : Cell :: new ( 0 ) ,
109
111
readiness : RefCell :: new ( VecDeque :: new ( ) ) ,
110
112
next_stream_id : Cell :: new ( StreamId :: new ( 1 ) ) ,
111
113
local_config : config,
@@ -391,6 +393,10 @@ impl Connection {
391
393
pub ( crate ) fn recv_half ( & self ) -> RecvHalfConnection {
392
394
RecvHalfConnection ( self . 0 . clone ( ) )
393
395
}
396
+
397
+ pub ( crate ) fn pings_count ( & self ) -> u16 {
398
+ self . 0 . pings_count . get ( )
399
+ }
394
400
}
395
401
396
402
impl RecvHalfConnection {
@@ -498,7 +504,7 @@ impl RecvHalfConnection {
498
504
} else {
499
505
let stream = StreamRef :: new ( id, true , Connection ( self . 0 . clone ( ) ) ) ;
500
506
self . 0 . next_stream_id . set ( id) ;
501
- self . 0 . total_count . set ( self . 0 . total_count . get ( ) + 1 ) ;
507
+ self . 0 . streams_count . set ( self . 0 . streams_count . get ( ) + 1 ) ;
502
508
self . 0 . streams . borrow_mut ( ) . insert ( id, stream. clone ( ) ) ;
503
509
self . 0
504
510
. active_remote_streams
@@ -666,8 +672,8 @@ impl RecvHalfConnection {
666
672
667
673
fn update_rst_count ( & self ) -> Result < ( ) , Either < ConnectionError , StreamErrorInner > > {
668
674
let count = self . 0 . rst_count . get ( ) + 1 ;
669
- let total_count = self . 0 . total_count . get ( ) ;
670
- if total_count >= 10 && count >= total_count >> 1 {
675
+ let streams_count = self . 0 . streams_count . get ( ) ;
676
+ if streams_count >= 10 && count >= streams_count >> 1 {
671
677
Err ( Either :: Left ( ConnectionError :: ConcurrencyOverflow ) )
672
678
} else {
673
679
self . 0 . rst_count . set ( count) ;
@@ -867,5 +873,6 @@ async fn ping(st: Connection, timeout: time::Seconds, io: IoRef) {
867
873
counter += 1 ;
868
874
st. unset_flags ( ConnectionFlags :: RECV_PONG ) ;
869
875
st. encode ( frame:: Ping :: new ( counter. to_be_bytes ( ) ) ) ;
876
+ st. 0 . pings_count . set ( st. 0 . pings_count . get ( ) + 1 ) ;
870
877
}
871
878
}
0 commit comments