From a63433e7579f56ccecc16d08dbf7813cc0ea0d38 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 5 Mar 2026 11:01:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=82=B9=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E9=80=BB=E8=BE=91=EF=BC=9A=E4=BB=8E=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8=E4=B8=AD=E7=A7=BB=E9=99=A4=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=BC=A0=E5=85=A5=E7=82=B9=EF=BC=8C=E5=B9=B6=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=AE=A2=E9=98=85=E7=82=B9=E5=92=8C=E8=BD=AE=E8=AF=A2?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E7=A7=BB=E9=99=A4=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/connection.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index 96f564f..bf53e3d 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -1147,13 +1147,6 @@ impl ConnectionManager { .retain(|_, point_id| !removed_set.contains(point_id)); } - // 从轮询列表中移除已取消订阅的点 - { - let mut status = self.status.write().await; - if let Some(conn_status) = status.get_mut(&source_id) { - conn_status.poll_points.retain(|p| !removed_set.contains(&p.point_id)); - } - } let _ = self .remove_point_write_target_cache_by_point_ids(&removed_point_ids) .await; @@ -1170,9 +1163,27 @@ impl ConnectionManager { history_data.remove(point_id); } } + + // 从轮询列表中移除传入的点,并记录移除的轮询点数量 + let polling_removed_count = { + let mut status = self.status.write().await; + if let Some(conn_status) = status.get_mut(&source_id) { + let before_count = conn_status.poll_points.len(); + conn_status.poll_points.retain(|p| !target_ids.contains(&p.point_id)); + let after_count = conn_status.poll_points.len(); + before_count - after_count + } else { + 0 + } + }; + + // 计算从订阅点和轮询点移除的总数 + let total_removed = removed_point_ids.len() + polling_removed_count; tracing::info!( - "Unsubscribed {} points from source {}", + "Unsubscribed {} points (subscription: {}, polling: {}) from source {}", + total_removed, removed_point_ids.len(), + polling_removed_count, source_id ); Ok(removed_point_ids.len())