@@ -158,7 +158,7 @@ impl Prioritize {
158158 }
159159
160160 // Update the buffered data counter
161- stream. buffered_send_data += sz;
161+ stream. buffered_send_data += sz as usize ;
162162
163163 let span =
164164 tracing:: trace_span!( "send_data" , sz, requested = stream. requested_send_capacity) ;
@@ -167,9 +167,10 @@ impl Prioritize {
167167
168168 // Implicitly request more send capacity if not enough has been
169169 // requested yet.
170- if stream. requested_send_capacity < stream. buffered_send_data {
170+ if ( stream. requested_send_capacity as usize ) < stream. buffered_send_data {
171171 // Update the target requested capacity
172- stream. requested_send_capacity = stream. buffered_send_data ;
172+ stream. requested_send_capacity =
173+ cmp:: min ( stream. buffered_send_data , WindowSize :: MAX as usize ) as WindowSize ;
173174
174175 self . try_assign_capacity ( stream) ;
175176 }
@@ -217,28 +218,28 @@ impl Prioritize {
217218 "reserve_capacity" ,
218219 ?stream. id,
219220 requested = capacity,
220- effective = capacity + stream. buffered_send_data,
221+ effective = ( capacity as usize ) + stream. buffered_send_data,
221222 curr = stream. requested_send_capacity
222223 ) ;
223224 let _e = span. enter ( ) ;
224225
225226 // Actual capacity is `capacity` + the current amount of buffered data.
226227 // If it were less, then we could never send out the buffered data.
227- let capacity = capacity + stream. buffered_send_data ;
228+ let capacity = ( capacity as usize ) + stream. buffered_send_data ;
228229
229- if capacity == stream. requested_send_capacity {
230+ if capacity == stream. requested_send_capacity as usize {
230231 // Nothing to do
231- } else if capacity < stream. requested_send_capacity {
232+ } else if capacity < stream. requested_send_capacity as usize {
232233 // Update the target requested capacity
233- stream. requested_send_capacity = capacity;
234+ stream. requested_send_capacity = capacity as WindowSize ;
234235
235236 // Currently available capacity assigned to the stream
236237 let available = stream. send_flow . available ( ) . as_size ( ) ;
237238
238239 // If the stream has more assigned capacity than requested, reclaim
239240 // some for the connection
240- if available > capacity {
241- let diff = available - capacity;
241+ if available as usize > capacity {
242+ let diff = available - capacity as WindowSize ;
242243
243244 stream. send_flow . claim_capacity ( diff) ;
244245
@@ -252,7 +253,8 @@ impl Prioritize {
252253 }
253254
254255 // Update the target requested capacity
255- stream. requested_send_capacity = capacity;
256+ stream. requested_send_capacity =
257+ cmp:: min ( capacity, WindowSize :: MAX as usize ) as WindowSize ;
256258
257259 // Try to assign additional capacity to the stream. If none is
258260 // currently available, the stream will be queued to receive some
@@ -316,8 +318,8 @@ impl Prioritize {
316318 /// it to the connection
317319 pub fn reclaim_reserved_capacity ( & mut self , stream : & mut store:: Ptr , counts : & mut Counts ) {
318320 // only reclaim requested capacity that isn't already buffered
319- if stream. requested_send_capacity > stream. buffered_send_data {
320- let reserved = stream. requested_send_capacity - stream. buffered_send_data ;
321+ if stream. requested_send_capacity as usize > stream. buffered_send_data {
322+ let reserved = stream. requested_send_capacity - stream. buffered_send_data as WindowSize ;
321323
322324 stream. send_flow . claim_capacity ( reserved) ;
323325 self . assign_connection_capacity ( reserved, stream, counts) ;
@@ -377,7 +379,7 @@ impl Prioritize {
377379
378380 // Total requested should never go below actual assigned
379381 // (Note: the window size can go lower than assigned)
380- debug_assert ! ( total_requested >= stream. send_flow. available( ) ) ;
382+ debug_assert ! ( stream. send_flow. available( ) <= total_requested as usize ) ;
381383
382384 // The amount of additional capacity that the stream requests.
383385 // Don't assign more than the window has available!
@@ -435,7 +437,7 @@ impl Prioritize {
435437 has_unavailable = %stream. send_flow. has_unavailable( )
436438 ) ;
437439
438- if stream. send_flow . available ( ) < stream. requested_send_capacity
440+ if stream. send_flow . available ( ) < stream. requested_send_capacity as usize
439441 && stream. send_flow . has_unavailable ( )
440442 {
441443 // The stream requires additional capacity and the stream's
@@ -735,8 +737,8 @@ impl Prioritize {
735737 stream. send_flow . send_data ( len) ;
736738
737739 // Decrement the stream's buffered data counter
738- debug_assert ! ( stream. buffered_send_data >= len) ;
739- stream. buffered_send_data -= len;
740+ debug_assert ! ( stream. buffered_send_data >= len as usize ) ;
741+ stream. buffered_send_data -= len as usize ;
740742 stream. requested_send_capacity -= len;
741743
742744 // Assign the capacity back to the connection that
0 commit comments