Skip to content

Commit 77347fd

Browse files
author
pe
committed
Fix: window size was not respected, resulting in flooding and poor TCP performance
Ignore-this: 1eb49b5fe7b8114406e4669b79b6ecc7 darcs-hash:1821a5827431e9b5ac13e8aa42d43867a4541421
1 parent 5063441 commit 77347fd

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/client/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,7 @@ impl<H: Handler> Connection<H> {
496496
}
497497

498498
/// Process all packets available in the buffer, and returns
499-
/// whether at least one complete packet was read. `buffer` and
500-
/// `buffer2` are work spaces mostly used to compute keys. They
501-
/// are cleared before using, hence nothing is expected from them.
499+
/// whether the connection should continue.
502500
fn atomic_poll(&mut self) -> Poll<bool, HandlerError<H::Error>> {
503501

504502
try_ready!(self.pending_poll());

src/server/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ impl Default for Config {
7979
auth_banner: None,
8080
auth_rejection_time: std::time::Duration::from_secs(1),
8181
keys: Vec::new(),
82-
window_size: 1 << 30,
83-
maximum_packet_size: 1 << 20,
82+
window_size: 200000,
83+
maximum_packet_size: 200000,
8484
limits: Limits::default(),
8585
preferred: Default::default(),
8686
max_auth_attempts: 10,

src/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Encrypted {
228228
};
229229
let buf_len = buf.len();
230230

231-
while buf.len() > 0 && channel.recipient_window_size > 0 {
231+
while buf.len() > 0 {
232232
// Compute the length we're allowed to send.
233233
let off = std::cmp::min(buf.len(), channel.recipient_maximum_packet_size as usize);
234234
let off = std::cmp::min(off, channel.recipient_window_size as usize);
@@ -247,6 +247,7 @@ impl Encrypted {
247247
channel.recipient_window_size -= off as u32;
248248
buf = &buf[off..]
249249
}
250+
debug!("buf.len() = {:?}, buf_len = {:?}", buf.len(), buf_len);
250251
Ok(buf_len)
251252
} else {
252253
Err(Error::WrongChannel)

0 commit comments

Comments
 (0)