Skip to content

Commit dd67a94

Browse files
committed
Fix remote path status state
1 parent d10c6d0 commit dd67a94

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,16 @@ impl Connection {
570570
}
571571
}
572572

573+
/// Returns the remote path status
574+
// TODO(flub): Probably should also be some kind of path event? Not even sure if I like
575+
// this as an API, but for now it allows me to write a test easily.
576+
// TODO(flub): Technically this should be a Result<Option<PathSTatus>>?
577+
pub fn remote_path_status(&self, path_id: PathId) -> Option<PathStatus> {
578+
self.paths
579+
.get(&path_id)
580+
.and_then(|path| path.data.status.remote_status)
581+
}
582+
573583
/// Gets the [`PathData`] for a known [`PathId`].
574584
///
575585
/// Will panic if the path_id does not reference any known path.

quinn-proto/src/connection/paths.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ pub(super) struct PathStatusState {
487487
/// This is the number of the *next* path status frame to be sent.
488488
pub(super) local_seq: VarInt,
489489
/// The status set by the remote
490-
pub(super) remote_status: PathStatus,
490+
pub(super) remote_status: Option<PathStatus>,
491491
/// Remote sequence number, for both PATH_AVAIALABLE and PATH_BACKUP
492492
pub(super) remote_seq: Option<VarInt>,
493493
}
@@ -500,8 +500,8 @@ impl PathStatusState {
500500
return;
501501
}
502502
self.remote_seq = Some(seq);
503-
let prev = std::mem::replace(&mut self.remote_status, status);
504-
if prev != status {
503+
let prev = std::mem::replace(&mut self.remote_status, Some(status));
504+
if prev != Some(status) {
505505
debug!(?status, ?seq, "remote changed path status");
506506
}
507507
}

quinn-proto/src/tests/multipath.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ fn path_status() {
9696
let _guard = subscribe();
9797
let (mut pair, client_ch, server_ch) = multipath_pair();
9898

99-
info!("client sets PATH_BACKUP");
10099
let client_conn = pair.client_conn_mut(client_ch);
101100
let prev_status = client_conn
102101
.set_path_status(PathId::ZERO, PathStatus::Backup)
@@ -108,15 +107,7 @@ fn path_status() {
108107

109108
let server_conn = pair.server_conn_mut(server_ch);
110109
assert_eq!(
111-
server_conn.path_status(PathId::ZERO).unwrap(),
110+
server_conn.remote_path_status(PathId::ZERO).unwrap(),
112111
PathStatus::Backup
113112
);
114-
115-
info!("server sets PATH_AVAILABLE");
116-
server_conn
117-
.set_path_status(PathId::ZERO, PathStatus::Available)
118-
.unwrap();
119-
120-
// Send the frame to the client
121-
pair.drive()
122113
}

0 commit comments

Comments
 (0)