From e9a6a344809daf5c0a3b725dd52e1527382d8c41 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:04:18 -0400 Subject: [PATCH] Forbid `chan.try_send` on closed buffered channels --- core/sync/chan/chan.odin | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/sync/chan/chan.odin b/core/sync/chan/chan.odin index cb299f23f..f0b04f3b4 100644 --- a/core/sync/chan/chan.odin +++ b/core/sync/chan/chan.odin @@ -260,6 +260,10 @@ try_send_raw :: proc "contextless" (c: ^Raw_Chan, msg_in: rawptr) -> (ok: bool) return false } + if sync.atomic_load(&c.closed) { + return false + } + ok = raw_queue_push(c.queue, msg_in) if sync.atomic_load(&c.r_waiting) > 0 { sync.signal(&c.r_cond)