Skip to content

Commit

Permalink
bugfix: Fix panic due to early closure of database
Browse files Browse the repository at this point in the history
This regression was introduced in f41de3b
  • Loading branch information
EduardGomezEscandell committed Oct 27, 2023
1 parent f41de3b commit 76ddfb7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion windows-agent/internal/proservices/proservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ func New(ctx context.Context, args ...Option) (s Manager, err error) {
if err != nil {
return s, err
}
defer db.Close(ctx)
defer func() {
// Close DB if we return error
// Otherwise, it'll be closed in the call to Manager.Stop
if err != nil {
db.Close(ctx)
}
}()

if err := conf.UpdateRegistrySettings(ctx, opts.cacheDir, db); err != nil {
log.Warningf(ctx, "Could not update registry settings: %v", err)
Expand Down

0 comments on commit 76ddfb7

Please sign in to comment.