From 0b7360af1660c5e1dd434c40f65bfa5d32f24fb8 Mon Sep 17 00:00:00 2001 From: Michael Pilquist Date: Thu, 20 May 2021 09:05:00 -0400 Subject: [PATCH] Fix memory leak in Channel --- core/shared/src/main/scala/fs2/concurrent/Channel.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/shared/src/main/scala/fs2/concurrent/Channel.scala b/core/shared/src/main/scala/fs2/concurrent/Channel.scala index c56fc3ebac..f1c4a9647e 100644 --- a/core/shared/src/main/scala/fs2/concurrent/Channel.scala +++ b/core/shared/src/main/scala/fs2/concurrent/Channel.scala @@ -209,7 +209,8 @@ object Channel { ( State(values, size, waiting.some, producers, closed), F.pure( - (Pull.eval(waiting.get) >> consumeLoop).unlessA(closed) + if (closed) Pull.done + else (Pull.eval(waiting.get) >> consumeLoop) ) ) }