Skip to content

Commit

Permalink
Close connection while dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
godmodegalactus committed Apr 2, 2024
1 parent d0a2fe2 commit 5ef1391
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion services/src/quic_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::quic_connection_utils::{
use futures::FutureExt;
use log::warn;
use prometheus::{core::GenericGauge, opts, register_int_gauge};
use quinn::{Connection, Endpoint};
use quinn::{Connection, Endpoint, VarInt};
use solana_lite_rpc_core::structures::rotating_queue::RotatingQueue;
use solana_sdk::pubkey::Pubkey;
use std::{
Expand Down Expand Up @@ -44,6 +44,15 @@ pub struct QuicConnection {
has_connected_once: Arc<AtomicBool>,
}

impl Drop for QuicConnection {
fn drop(&mut self) {
let lk = self.connection.blocking_read();
if let Some(connection) = lk.as_ref() {
connection.close(VarInt::from_u32(0), b"Not needed")
}
}
}

impl QuicConnection {
pub fn new(
identity: Pubkey,
Expand Down

0 comments on commit 5ef1391

Please sign in to comment.