From fc809a55fecebce1585637f6d4f5cba06a7f9c51 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 2 Dec 2024 17:54:37 +0800 Subject: [PATCH] fix loop hang --- crates/pubsub-client/src/lib.rs | 16 ++++++++-------- crates/src/drift_idl.rs | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/pubsub-client/src/lib.rs b/crates/pubsub-client/src/lib.rs index 769f9b4..54ad5bd 100644 --- a/crates/pubsub-client/src/lib.rs +++ b/crates/pubsub-client/src/lib.rs @@ -368,6 +368,14 @@ impl PubsubClient { 'manager: loop { tokio::select! { biased; + // Send close on shutdown signal + _ = (&mut shutdown_receiver) => { + log::info!("PubsubClient received shutdown"); + let frame = CloseFrame { code: CloseCode::Normal, reason: "".into() }; + ws.send(Message::Close(Some(frame))).await?; + ws.flush().await?; + break 'reconnect Ok(()); + }, // Read incoming WebSocket message next_msg = ws.next() => { let msg = match next_msg { @@ -487,14 +495,6 @@ impl PubsubClient { continue 'manager; } } - // Send close on shutdown signal - _ = (&mut shutdown_receiver) => { - log::info!("PubsubClient received shutdown"); - let frame = CloseFrame { code: CloseCode::Normal, reason: "".into() }; - ws.send(Message::Close(Some(frame))).await?; - ws.flush().await?; - break 'reconnect Ok(()); - }, // Read message for subscribe Some((operation, params, response_sender)) = subscribe_receiver.recv() => { request_id += 1; diff --git a/crates/src/drift_idl.rs b/crates/src/drift_idl.rs index ae29ea4..024c170 100644 --- a/crates/src/drift_idl.rs +++ b/crates/src/drift_idl.rs @@ -2,7 +2,6 @@ #![doc = r""] #![doc = r" Auto-generated IDL types, manual edits do not persist (see `crates/drift-idl-gen`)"] #![doc = r""] -use self::traits::ToAccountMetas; use anchor_lang::{ prelude::{ account, @@ -13,6 +12,8 @@ use anchor_lang::{ }; use serde::{Deserialize, Serialize}; use solana_sdk::{instruction::AccountMeta, pubkey::Pubkey}; + +use self::traits::ToAccountMetas; pub mod traits { use solana_sdk::instruction::AccountMeta; #[doc = r" This is distinct from the anchor_lang version of the trait"] @@ -1918,8 +1919,9 @@ pub mod instructions { } pub mod types { #![doc = r" IDL types"] - use super::*; use std::ops::Mul; + + use super::*; #[doc = ""] #[doc = " backwards compatible u128 deserializing data from rust <=1.76.0 when u/i128 was 8-byte aligned"] #[doc = " https://solana.stackexchange.com/questions/7720/using-u128-without-sacrificing-alignment-8"]