Close connection while dropping

This commit is contained in:
godmodegalactus 2024-04-02 23:06:52 +02:00
parent d0a2fe200b
commit 5ef1391b9a
No known key found for this signature in database
GPG Key ID: 22DA4A30887FDA3C
1 changed files with 10 additions and 1 deletions

View File

@ -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::{
@ -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,