Skip to content
Open
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
15 changes: 12 additions & 3 deletions src/adnl/src/quic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,19 @@ impl QuicNode {
};
let name = Self::key_id_to_server_name(key_id);
// Update last-added name for SNI fallback (C++ ngtcp2 doesn't send SNI)
if let Ok(mut last) = endpoint_state.last_added_name.lock() {
*last = Some(name);
let changed = if let Ok(mut last) = endpoint_state.last_added_name.lock() {
if last.as_deref() == Some(name.as_str()) {
false
} else {
*last = Some(name);
true
}
} else {
false
Comment on lines +850 to +858
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If endpoint_state.last_added_name mutex is poisoned, changed becomes false and the activation request is silently ignored (and no log is emitted). Consider logging a warn/error in the Err(_) branch, and optionally recovering via PoisonError::into_inner() so the fallback identity can still be updated after a panic.

Suggested change
let changed = if let Ok(mut last) = endpoint_state.last_added_name.lock() {
if last.as_deref() == Some(name.as_str()) {
false
} else {
*last = Some(name);
true
}
} else {
false
let changed = match endpoint_state.last_added_name.lock() {
Ok(mut last) => {
if last.as_deref() == Some(name.as_str()) {
false
} else {
*last = Some(name);
true
}
}
Err(poisoned) => {
log::warn!(
target: TARGET,
"activate_key: last_added_name lock poisoned for key {} on port {}, recovering",
key_id,
port
);
let mut last = poisoned.into_inner();
if last.as_deref() == Some(name.as_str()) {
false
} else {
*last = Some(name);
true
}
}

Copilot uses AI. Check for mistakes.
};
if changed {
log::info!(target: TARGET, "Activated QUIC identity {} on port {}", key_id, port);
}
log::info!(target: TARGET, "Activated QUIC identity {} on port {}", key_id, port);
}

pub fn add_peer_key(&self, key_id: Arc<KeyId>, addr: SocketAddr) -> Result<()> {
Expand Down
Loading