Closed johanneswuerbach closed 5 months ago
I don't think this is the right fix: it doesn't actually have anything to do with the isClosed variable being racy does it?
Yes and no. From my understanding Close
is essentially trying to signal running consumers that the channel has been closed, but if the startGoroutines
wasn't finished yet, this signalling doesn't work and a consumers starts nevertheless.
As Close
and Run
(or specifically the init part) depend on each other, I think using a shared lock here makes sense.
When running
consumer.Close
before theconsumer.Run
has finished,Run
will never return.Prevent this by also getting the
isClosedMux
lock while initialising the handler.