Skip to content

Commit

Permalink
main: Defer database close.
Browse files Browse the repository at this point in the history
This defers the database close once opened to ensure it is always
properly closed on all error paths.
  • Loading branch information
davecgh committed Sep 12, 2023
1 parent 7344dcc commit 290ea16
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions dcrpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ func realMain() error {
} else {
db, err = pool.InitBoltDB(cfg.DBFile)
}

if err != nil {
mpLog.Errorf("failed to initialize database: %v", err)
return err
}
defer db.Close()

p, err := newPool(db, cfg)
if err != nil {
Expand Down Expand Up @@ -226,7 +226,6 @@ func realMain() error {
}
}

db.Close()
mpLog.Info("dcrpool shut down.")
return nil
}
Expand Down

0 comments on commit 290ea16

Please sign in to comment.