Skip to content

Commit 975c0f7

Browse files
authored
fix: calling message queue Shutdown twice causes panic (because close is called twice on done channel) (ipfs#414)
1 parent 18ee3cb commit 975c0f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

messagequeue/messagequeue.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type MessageQueue struct {
6868

6969
outgoingWork chan struct{}
7070
done chan struct{}
71+
doneOnce sync.Once
7172

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

145146
// Shutdown stops the processing of messages for a message queue.
146147
func (mq *MessageQueue) Shutdown() {
147-
close(mq.done)
148+
mq.doneOnce.Do(func() {
149+
close(mq.done)
150+
})
148151
}
149152

150153
func (mq *MessageQueue) runQueue() {

0 commit comments

Comments
 (0)