From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 86E521FF17E for ; Thu, 27 Nov 2025 16:36:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4E6937E64; Thu, 27 Nov 2025 16:36:52 +0100 (CET) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 16:36:05 +0100 Message-ID: <20251127153609.440415-4-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251127153609.440415-1-s.sterz@proxmox.com> References: <20251127153609.440415-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764257737081 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.085 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager 2/6] ui: main: move requests into an async pool and drop it on logout X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" this will abort requests that are still in flight during a log out. such requests can then end up in a race condition with the next login. if the login goes through before these requests return, a user will be logged out right after logging in again. Signed-off-by: Shannon Sterz --- ui/src/main.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ui/src/main.rs b/ui/src/main.rs index 026b7ab..985220c 100644 --- a/ui/src/main.rs +++ b/ui/src/main.rs @@ -12,6 +12,7 @@ use pwt::prelude::*; use pwt::props::TextRenderFn; use pwt::state::{Loader, PersistentState, SharedStateObserver}; use pwt::widget::{Column, DesktopApp, Dialog, Mask}; +use pwt::AsyncPool; use pbs_api_types::TaskListItem; use proxmox_login::Authentication; @@ -60,6 +61,8 @@ struct DatacenterManagerApp { view_list: Vec, view_list_context: ViewListContext, _view_list_observer: SharedStateObserver, + + async_pool: AsyncPool, } async fn check_subscription() -> Msg { @@ -95,7 +98,8 @@ impl DatacenterManagerApp { if self.subscription_confirmed { ctx.link().send_message(Msg::ConfirmSubscription); } else { - ctx.link().send_future(check_subscription()); + self.async_pool + .send_future(ctx.link().clone(), check_subscription()); } } else { ctx.link().send_message(Msg::ConfirmSubscription); @@ -103,13 +107,13 @@ impl DatacenterManagerApp { } //ctx.link().send_future_batch(get_fingerprint()); // - self.remote_list_timeout = Self::poll_remote_list(ctx, true); + self.remote_list_timeout = self.poll_remote_list(ctx, true); self.update_views(ctx); } } fn update_views(&mut self, ctx: &Context) { - ctx.link().send_future(async move { + self.async_pool.send_future(ctx.link().clone(), async move { let res = http_get("/config/views", None) .await .map(|list: Vec| { @@ -123,7 +127,7 @@ impl DatacenterManagerApp { } fn update_remotes(&mut self, ctx: &Context, result: MsgRemoteList) -> bool { - self.remote_list_timeout = Self::poll_remote_list(ctx, false); + self.remote_list_timeout = self.poll_remote_list(ctx, false); let mut changed = false; match result { Err(err) => { @@ -160,10 +164,13 @@ impl DatacenterManagerApp { changed } - fn poll_remote_list(ctx: &Context, first: bool) -> Option { + fn poll_remote_list(&self, ctx: &Context, first: bool) -> Option { let link = ctx.link().clone(); + let async_pool = self.async_pool.clone(); let timeout = Timeout::new(if first { 0 } else { 5_000 }, move || { - link.send_future(async move { Msg::RemoteList(Self::get_remote_list().await) }) + async_pool.send_future(link, async move { + Msg::RemoteList(Self::get_remote_list().await) + }) }); Some(timeout) } @@ -226,6 +233,7 @@ impl Component for DatacenterManagerApp { view_list: Vec::new(), view_list_context, _view_list_observer, + async_pool: AsyncPool::new(), }; this.on_login(ctx, false); @@ -249,6 +257,8 @@ impl Component for DatacenterManagerApp { } Msg::Logout => { //log::info!("CLEAR COOKIE"); + // this will drop the pool and abort all current requests + self.async_pool = AsyncPool::new(); self.running_tasks.abort(); self.remote_list_timeout = None; proxmox_yew_comp::http_clear_auth(); -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel