go-rabbitmq icon indicating copy to clipboard operation
go-rabbitmq copied to clipboard

fix: consumer close before run

Open johanneswuerbach opened this issue 11 months ago • 2 comments

When running consumer.Close before the consumer.Run has finished, Run will never return.

Prevent this by also getting the isClosedMux lock while initialising the handler.

johanneswuerbach avatar Mar 19 '24 09:03 johanneswuerbach

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?

wagslane avatar Mar 25 '24 18:03 wagslane

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.

johanneswuerbach avatar Mar 25 '24 19:03 johanneswuerbach