Skip to content

Commit

Permalink
fix(windows-agent): Fix panic due to early closure of database (#368)
Browse files Browse the repository at this point in the history
This regression was introduced in
f41de3b
  • Loading branch information
EduardGomezEscandell authored Oct 27, 2023
2 parents e71aab4 + 76ddfb7 commit d44438b
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 d44438b

Please sign in to comment.