Przeglądaj źródła

Forbid `chan.try_send` on closed buffered channels

Feoramund 1 rok temu
rodzic
commit
e9a6a34480
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      core/sync/chan/chan.odin

+ 4 - 0
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)