Skip to content

feat: Put tokens into Rc #2780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion neqo-transport/src/pmtud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ mod tests {
Some(u16::MAX as usize),
];

const fn make_sent_packet(pn: u64, now: Instant, len: usize) -> sent::Packet {
fn make_sent_packet(pn: u64, now: Instant, len: usize) -> sent::Packet {
sent::Packet::new(
packet::Type::Short,
pn,
Expand Down
11 changes: 6 additions & 5 deletions neqo-transport/src/recovery/sent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use std::{
collections::BTreeMap,
ops::RangeInclusive,
rc::Rc,
time::{Duration, Instant},
};

Expand All @@ -21,7 +22,7 @@ pub struct Packet {
ack_eliciting: bool,
time_sent: Instant,
primary_path: bool,
tokens: recovery::Tokens,
tokens: Rc<recovery::Tokens>,

time_declared_lost: Option<Instant>,
/// After a PTO, this is true when the packet has been released.
Expand All @@ -32,7 +33,7 @@ pub struct Packet {

impl Packet {
#[must_use]
pub const fn new(
pub fn new(
pt: packet::Type,
pn: packet::Number,
time_sent: Instant,
Expand All @@ -46,7 +47,7 @@ impl Packet {
time_sent,
ack_eliciting,
primary_path: true,
tokens,
tokens: Rc::new(tokens),
time_declared_lost: None,
pto: false,
len,
Expand Down Expand Up @@ -104,8 +105,8 @@ impl Packet {

/// Access the recovery tokens that this holds.
#[must_use]
pub const fn tokens(&self) -> &recovery::Tokens {
&self.tokens
pub fn tokens(&self) -> &recovery::Tokens {
self.tokens.as_ref()
}

/// Clears the flag that had this packet on the primary path.
Expand Down
Loading