summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alessandro Ghedini <alessandro@ghedini.me> 2021-05-12 09:45:46 +0100
committerGravatar Alessandro Ghedini <alessandro@ghedini.me> 2021-05-12 17:39:16 +0100
commit567cc5ebc530ed5cf2c14dd4af88a2496bacb290 (patch)
tree38126fb7b9c92eada169d5f36d21aa3b8d9abd28
parent94b38d5bd0774e68bb5b64307908471bf7f6b615 (diff)
downloadquiche-567cc5ebc530ed5cf2c14dd4af88a2496bacb290.tar.gz
quiche-567cc5ebc530ed5cf2c14dd4af88a2496bacb290.tar.zst
quiche-567cc5ebc530ed5cf2c14dd4af88a2496bacb290.zip
stop sending packets if draining
This check is currently done in `Connection::send()` as well, but when coalescing multiple packets, if one causes the connection to move to draining (e.g. because a CONNECTION_CLOSE was sent), we should stop trying to write additional coalesced packets.
-rw-r--r--src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 90b60d2b..16a9af29 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2344,6 +2344,10 @@ impl Connection {
return Err(Error::BufferTooShort);
}
+ if self.is_draining() {
+ return Err(Error::Done);
+ }
+
let is_closing = self.local_error.is_some();
let mut b = octets::OctetsMut::with_slice(out);
@@ -5873,6 +5877,8 @@ mod tests {
#[test]
fn handshake_alpn_mismatch() {
+ let mut buf = [0; 65535];
+
let mut config = Config::new(PROTOCOL_VERSION).unwrap();
config
.set_application_protos(b"\x06proto3\x06proto4")
@@ -5884,6 +5890,11 @@ mod tests {
assert_eq!(pipe.client.application_proto(), b"");
assert_eq!(pipe.server.application_proto(), b"");
+
+ // Server should only send one packet in response to ALPN mismatch.
+ assert_eq!(pipe.server.send(&mut buf), Ok(1200));
+ assert_eq!(pipe.server.send(&mut buf), Err(Error::Done));
+ assert_eq!(pipe.server.sent_count, 1);
}
#[test]