From b8b5f00e9695f46ea30af3ce63aec6dd17f356ae Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 27 Jun 2024 02:39:31 +0200 Subject: Improve async channels error handling and replace unbounded channels with bounded channels Remove all unbounded channels to prevent unbounded memory usage and potential crashes. Use `FuturesUnordered` for sending to multiple channels simultaneously. This prevents the sending loop from blocking if one channel is blocked, and helps handle errors properly. --- core/src/async_util/task_group.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'core/src/async_util/task_group.rs') diff --git a/core/src/async_util/task_group.rs b/core/src/async_util/task_group.rs index 63c1541..c55b9a1 100644 --- a/core/src/async_util/task_group.rs +++ b/core/src/async_util/task_group.rs @@ -87,6 +87,7 @@ impl TaskGroup { self.stop_signal.broadcast().await; loop { + // XXX BE CAREFUL HERE, it hold synchronous mutex across .await point. let task = self.tasks.lock().pop(); if let Some(t) = task { t.cancel().await -- cgit v1.2.3