Skip to content

Commit 4bc71ca

Browse files
committed
Better factoring of path response
1 parent 17b3031 commit 4bc71ca

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

neqo-transport/src/connection/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,15 +3387,12 @@ impl Connection {
33873387
}
33883388
Frame::PathResponse { data } => {
33893389
self.stats.borrow_mut().frame_rx.path_response += 1;
3390-
if self
3391-
.paths
3392-
.path_response(data, now, &mut self.stats.borrow_mut())
3390+
if let Some(primary) =
3391+
self.paths
3392+
.path_response(data, now, &mut self.stats.borrow_mut())
33933393
{
3394-
// This PATH_RESPONSE enabled migration; tell loss recovery.
3394+
self.path_migrated(&primary);
33953395
self.loss_recovery.migrate();
3396-
if let Some(primary) = self.paths.primary() {
3397-
self.path_migrated(&primary);
3398-
}
33993396
}
34003397
}
34013398
Frame::ConnectionClose {

neqo-transport/src/path.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ impl Paths {
322322
}
323323

324324
/// A `PATH_RESPONSE` was received.
325-
/// Returns `true` if migration occurred.
325+
/// Returns `Some` with the new primary path if migration occurred.
326326
/// If PMTUD is enabled and migration occurs, it will be started on the new primary path.
327327
#[must_use]
328-
pub fn path_response(&mut self, response: [u8; 8], now: Instant, stats: &mut Stats) -> bool {
328+
pub fn path_response(&mut self, response: [u8; 8], now: Instant, stats: &mut Stats) -> Option<PathRef> {
329329
// TODO(mt) consider recording an RTT measurement here as we don't train
330330
// RTT for non-primary paths.
331331
for p in &self.paths {
@@ -340,12 +340,12 @@ impl Paths {
340340
if self.pmtud {
341341
primary.borrow_mut().pmtud_mut().start(now, stats);
342342
}
343-
return true;
343+
return Some(primary);
344344
}
345345
break;
346346
}
347347
}
348-
false
348+
None
349349
}
350350

351351
/// Retire all of the connection IDs prior to the indicated sequence number.

0 commit comments

Comments
 (0)