fix(client): report counter overflows clearly
This commit is contained in:
3 files changed
+65
-9
No files matched your search
@@ -241,14 +241,20 @@ impl Client {
|
|||||||
session.pending.insert(pending)?;
|
session.pending.insert(pending)?;
|
||||||
|
|
||||||
session.next_wire_seq = session.next_wire_seq.wrapping_add(1);
|
session.next_wire_seq = session.next_wire_seq.wrapping_add(1);
|
||||||
session.next_logical_seq = session
|
session.next_logical_seq =
|
||||||
.next_logical_seq
|
session
|
||||||
.checked_add(1)
|
.next_logical_seq
|
||||||
.ok_or(ClientError::DurationOverflow)?;
|
.checked_add(1)
|
||||||
session.packets_sent = session
|
.ok_or(ClientError::CounterOverflow {
|
||||||
.packets_sent
|
counter: "next_logical_seq",
|
||||||
.checked_add(1)
|
})?;
|
||||||
.ok_or(ClientError::DurationOverflow)?;
|
session.packets_sent =
|
||||||
|
session
|
||||||
|
.packets_sent
|
||||||
|
.checked_add(1)
|
||||||
|
.ok_or(ClientError::CounterOverflow {
|
||||||
|
counter: "packets_sent",
|
||||||
|
})?;
|
||||||
|
|
||||||
let negotiated = self
|
let negotiated = self
|
||||||
.negotiated
|
.negotiated
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ fn send_probe_reports_schedule_overflow() {
|
|||||||
};
|
};
|
||||||
let mut client = Client::connect(config).unwrap();
|
let mut client = Client::connect(config).unwrap();
|
||||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||||
client.session.as_mut().unwrap().packets_sent = u64::MAX;
|
client.session.as_mut().unwrap().packets_sent = u64::MAX - 1;
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
client.send_probe(),
|
client.send_probe(),
|
||||||
@@ -311,6 +311,54 @@ fn send_probe_reports_schedule_overflow() {
|
|||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn send_probe_reports_logical_sequence_counter_overflow() {
|
||||||
|
let params = default_params();
|
||||||
|
let server = silent_open_server(params);
|
||||||
|
let config = ClientConfig {
|
||||||
|
socket_config: crate::SocketConfig {
|
||||||
|
recv_timeout: Some(Duration::from_millis(200)),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..default_test_config(server.addr)
|
||||||
|
};
|
||||||
|
let mut client = Client::connect(config).unwrap();
|
||||||
|
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||||
|
client.session.as_mut().unwrap().next_logical_seq = u64::MAX;
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
client.send_probe(),
|
||||||
|
Err(ClientError::CounterOverflow {
|
||||||
|
counter: "next_logical_seq"
|
||||||
|
})
|
||||||
|
));
|
||||||
|
server.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn send_probe_reports_packets_sent_counter_overflow() {
|
||||||
|
let params = default_params();
|
||||||
|
let server = silent_open_server(params);
|
||||||
|
let config = ClientConfig {
|
||||||
|
socket_config: crate::SocketConfig {
|
||||||
|
recv_timeout: Some(Duration::from_millis(200)),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..default_test_config(server.addr)
|
||||||
|
};
|
||||||
|
let mut client = Client::connect(config).unwrap();
|
||||||
|
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||||
|
client.session.as_mut().unwrap().packets_sent = u64::MAX;
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
client.send_probe(),
|
||||||
|
Err(ClientError::CounterOverflow {
|
||||||
|
counter: "packets_sent"
|
||||||
|
})
|
||||||
|
));
|
||||||
|
server.join();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recv_once_returns_empty_on_timeout() {
|
fn recv_once_returns_empty_on_timeout() {
|
||||||
let params = default_params();
|
let params = default_params();
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ pub enum ClientError {
|
|||||||
AlreadyClosed,
|
AlreadyClosed,
|
||||||
#[error("duration is too large to encode as nanoseconds")]
|
#[error("duration is too large to encode as nanoseconds")]
|
||||||
DurationOverflow,
|
DurationOverflow,
|
||||||
|
#[error("counter {counter} overflowed")]
|
||||||
|
CounterOverflow { counter: &'static str },
|
||||||
#[error("pending probe limit exceeded ({limit})")]
|
#[error("pending probe limit exceeded ({limit})")]
|
||||||
PendingLimitExceeded { limit: usize },
|
PendingLimitExceeded { limit: usize },
|
||||||
#[error("invalid configuration: {reason}")]
|
#[error("invalid configuration: {reason}")]
|
||||||
|
|||||||
Reference in new issue
Block a user