File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,16 @@ impl Channels {
219219 let ch = self . get_mut ( num) ?;
220220 ch. finished_input ( len) ;
221221 if let Some ( w) = ch. check_window_adjust ( ) ? {
222- s. send ( w) ?;
222+ // The send buffer may be full. Ignore the failure and hope another adjustment is
223+ // sent later. TODO improve this.
224+ match s. send ( w) {
225+ Ok ( _) => ch. pending_adjust = 0 ,
226+ Err ( Error :: NoRoom { .. } ) => {
227+ // TODO better retry rather than hoping a retry occurs
228+ debug ! ( "noroom for adjustment" )
229+ }
230+ error => return error,
231+ }
223232 }
224233 Ok ( ( ) )
225234 }
@@ -1009,11 +1018,12 @@ impl Channel {
10091018 }
10101019
10111020 /// Returns a window adjustment packet if required
1012- fn check_window_adjust ( & mut self ) -> Result < Option < Packet < ' _ > > > {
1013- let num = self . send . as_mut ( ) . trap ( ) ?. num ;
1021+ ///
1022+ /// Does not reset the adjustment to 0, should be done by caller on successful send.
1023+ fn check_window_adjust ( & self ) -> Result < Option < Packet < ' _ > > > {
1024+ let num = self . send . as_ref ( ) . trap ( ) ?. num ;
10141025 if self . pending_adjust > self . full_window / 2 {
10151026 let adjust = self . pending_adjust as u32 ;
1016- self . pending_adjust = 0 ;
10171027 let p = packets:: ChannelWindowAdjust { num, adjust } . into ( ) ;
10181028 Ok ( Some ( p) )
10191029 } else {
Original file line number Diff line number Diff line change @@ -135,7 +135,9 @@ impl KeyState {
135135 buf : & mut [ u8 ] ,
136136 ) -> Result < usize , Error > {
137137 let e = self . enc . encrypt ( payload_len, buf, self . seq_encrypt . 0 ) ;
138- self . seq_encrypt += 1 ;
138+ if !matches ! ( e, Err ( Error :: NoRoom { .. } ) ) {
139+ self . seq_encrypt += 1 ;
140+ }
139141 e
140142 }
141143
You can’t perform that action at this time.
0 commit comments