Skip to content

Commit

Permalink
fix: calling message queue Shutdown twice causes panic (because close…
Browse files Browse the repository at this point in the history
… is called twice on done channel) (#414)
  • Loading branch information
dirkmc authored Mar 21, 2023
1 parent 18ee3cb commit 975c0f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion messagequeue/messagequeue.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type MessageQueue struct {

outgoingWork chan struct{}
done chan struct{}
doneOnce sync.Once

// internal do not touch outside go routines
sender gsnet.MessageSender
Expand Down Expand Up @@ -144,7 +145,9 @@ func (mq *MessageQueue) Startup() {

// Shutdown stops the processing of messages for a message queue.
func (mq *MessageQueue) Shutdown() {
close(mq.done)
mq.doneOnce.Do(func() {
close(mq.done)
})
}

func (mq *MessageQueue) runQueue() {
Expand Down

0 comments on commit 975c0f7

Please sign in to comment.