Skip to content

Commit

Permalink
Always close direct fd on db close
Browse files Browse the repository at this point in the history
If Litestream is used as a library and the database can be closed
and re-opened more than once during its lifetime the leaking fd can
break SQLite OFD completely.
  • Loading branch information
hifi committed Nov 12, 2023
1 parent ed7121b commit dcfba90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ func (db *DB) Close() (err error) {
}
}

if db.f != nil {
if e := db.f.Close(); e != nil && err == nil {
err = e
}
}

return err
}

Expand Down

0 comments on commit dcfba90

Please sign in to comment.