File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,8 @@ impl P2pNetworkYamuxState {
208208 if let Some ( stream) = yamux_state. streams . get_mut ( & frame. stream_id ) {
209209 // must not underflow
210210 // TODO: check it and disconnect peer that violates flow rules
211- stream. window_ours -= data. len ( ) as u32 ;
211+ stream. window_ours =
212+ stream. window_ours . wrapping_sub ( data. len ( ) as u32 ) ;
212213 }
213214 }
214215 YamuxFrameInner :: WindowUpdate { difference } => {
@@ -334,7 +335,7 @@ impl P2pNetworkYamuxState {
334335 // must not underflow
335336 // the action must not dispatch if it doesn't fit in the window
336337 // TODO: add pending queue, where frames will wait for window increase
337- stream. window_theirs -= data. len ( ) as u32 ;
338+ stream. window_theirs = stream . window_theirs . wrapping_sub ( data. len ( ) as u32 ) ;
338339 }
339340 YamuxFrameInner :: WindowUpdate { difference } => {
340341 stream. update_window ( true , * difference) ;
@@ -417,11 +418,11 @@ impl YamuxStreamState {
417418 if * window < decreasing {
418419 * window = 0 ;
419420 } else {
420- * window -= decreasing;
421+ * window = ( * window ) . wrapping_sub ( decreasing) ;
421422 }
422423 } else {
423424 let increasing = difference as u32 ;
424- * window += increasing;
425+ * window = ( * window ) . wrapping_add ( increasing) ;
425426 }
426427 }
427428}
You can’t perform that action at this time.
0 commit comments