@@ -58,11 +58,14 @@ pub struct Connection {
58
58
blocked_streams : FnvHashSet < StreamId > ,
59
59
/// Limit on outgoing data, dictated by peer
60
60
max_data : u64 ,
61
+ /// Sum of current offsets of all send streams.
61
62
data_sent : u64 ,
62
- /// Sum of end offsets of all streams. Includes gaps, so it's an upper bound.
63
+ /// Sum of end offsets of all receive streams. Includes gaps, so it's an upper bound.
63
64
data_recvd : u64 ,
64
65
/// Limit on incoming data
65
66
local_max_data : u64 ,
67
+ /// Stream data we're sending that hasn't been acknowledged or reset yet
68
+ unacked_data : u64 ,
66
69
client_config : Option < ClientConfig > ,
67
70
/// ConnectionId sent by this client on the first Initial, if a Retry was received.
68
71
orig_rem_cid : Option < ConnectionId > ,
@@ -213,6 +216,7 @@ impl Connection {
213
216
data_sent : 0 ,
214
217
data_recvd : 0 ,
215
218
local_max_data : config. receive_window as u64 ,
219
+ unacked_data : 0 ,
216
220
client_config,
217
221
orig_rem_cid : None ,
218
222
lost_packets : 0 ,
@@ -503,6 +507,7 @@ impl Connection {
503
507
continue ;
504
508
} ;
505
509
ss. bytes_in_flight -= frame. data . len ( ) as u64 ;
510
+ self . unacked_data -= frame. data . len ( ) as u64 ;
506
511
if ss. state == stream:: SendState :: DataSent && ss. bytes_in_flight == 0 {
507
512
ss. state = stream:: SendState :: DataRecvd ;
508
513
self . maybe_cleanup ( frame. id ) ;
@@ -802,6 +807,7 @@ impl Connection {
802
807
ss. offset += data. len ( ) as u64 ;
803
808
ss. bytes_in_flight += data. len ( ) as u64 ;
804
809
self . data_sent += data. len ( ) as u64 ;
810
+ self . unacked_data += data. len ( ) as u64 ;
805
811
self . space_mut ( SpaceId :: Data )
806
812
. pending
807
813
. stream
@@ -2144,6 +2150,7 @@ impl Connection {
2144
2150
. get ( & stream. id )
2145
2151
. map_or ( true , |s| s. send ( ) . unwrap ( ) . state . was_reset ( ) )
2146
2152
{
2153
+ self . unacked_data -= stream. data . len ( ) as u64 ;
2147
2154
continue ;
2148
2155
}
2149
2156
let len = cmp:: min (
@@ -2649,7 +2656,9 @@ impl Connection {
2649
2656
}
2650
2657
2651
2658
fn blocked ( & self ) -> bool {
2652
- self . data_sent >= self . max_data || self . congestion_blocked ( )
2659
+ self . data_sent >= self . max_data
2660
+ || self . congestion_blocked ( )
2661
+ || self . unacked_data >= self . config . send_window
2653
2662
}
2654
2663
2655
2664
fn decrypt_packet (
@@ -2799,7 +2808,10 @@ impl Connection {
2799
2808
}
2800
2809
} ;
2801
2810
2802
- let conn_budget = self . max_data - self . data_sent ;
2811
+ let conn_budget = cmp:: min (
2812
+ self . max_data - self . data_sent ,
2813
+ self . config . send_window - self . unacked_data ,
2814
+ ) ;
2803
2815
let n = conn_budget. min ( stream_budget) . min ( data. len ( ) as u64 ) as usize ;
2804
2816
self . queue_stream_data ( stream, ( & data[ 0 ..n] ) . into ( ) ) ;
2805
2817
trace ! (
0 commit comments