Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
fix: prevent double node.Shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Jun 15, 2021
1 parent 60b0e08 commit baedb5a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package node

import (
"errors"
"fmt"
"runtime"
"time"
Expand Down Expand Up @@ -134,7 +135,12 @@ func (n *Node) HandlePubSub(raw []byte) {

// Shutdown stops all services (hub, controller)
func (n *Node) Shutdown() (err error) {
if n.shutdownCh == nil {
return errors.New("Already shut down")
}

close(n.shutdownCh)
n.shutdownCh = nil

if n.hub != nil {
n.hub.Shutdown()
Expand Down

0 comments on commit baedb5a

Please sign in to comment.