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 {
208
208
if let Some ( stream) = yamux_state. streams . get_mut ( & frame. stream_id ) {
209
209
// must not underflow
210
210
// 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 ) ;
212
213
}
213
214
}
214
215
YamuxFrameInner :: WindowUpdate { difference } => {
@@ -334,7 +335,7 @@ impl P2pNetworkYamuxState {
334
335
// must not underflow
335
336
// the action must not dispatch if it doesn't fit in the window
336
337
// 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 ) ;
338
339
}
339
340
YamuxFrameInner :: WindowUpdate { difference } => {
340
341
stream. update_window ( true , * difference) ;
@@ -417,11 +418,11 @@ impl YamuxStreamState {
417
418
if * window < decreasing {
418
419
* window = 0 ;
419
420
} else {
420
- * window -= decreasing;
421
+ * window = ( * window ) . wrapping_sub ( decreasing) ;
421
422
}
422
423
} else {
423
424
let increasing = difference as u32 ;
424
- * window += increasing;
425
+ * window = ( * window ) . wrapping_add ( increasing) ;
425
426
}
426
427
}
427
428
}
You can’t perform that action at this time.
0 commit comments