Skip to content

Commit

Permalink
Improve shutdown/close code
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Feb 26, 2019
1 parent 45b8d80 commit 21b4f30
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions balloon/balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ type Balloon struct {

func NewBalloon(store storage.Store, hasherF func() hashing.Hasher) (*Balloon, error) {

// create caches
hyperCache := cache.NewFreeCache(hyper.CacheSize)

// create trees
historyTree := history.NewHistoryTree(hasherF, store, 300)
hyperTree := hyper.NewHyperTree(hasherF, store, hyperCache)
hyperTree := hyper.NewHyperTree(hasherF, store, cache.NewFreeCache(hyper.CacheSize))

balloon := &Balloon{
version: 0,
Expand Down
3 changes: 2 additions & 1 deletion raftwal/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ func (fsm *BalloonFSM) Restore(rc io.ReadCloser) error {
}

func (fsm *BalloonFSM) Close() error {
return fsm.store.Close()
fsm.balloon.Close()
return nil
}

func (fsm *BalloonFSM) applyAdd(event []byte, state *fsmState) *fsmAddResponse {
Expand Down
3 changes: 3 additions & 0 deletions raftwal/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ func (b *RaftBalloon) Close(wait bool) error {
b.store.log = nil
b.store.stable = nil

// Close FSM
b.fsm.Close()

return nil
}

Expand Down

0 comments on commit 21b4f30

Please sign in to comment.