cmd/syncthing, lib/db: Exit/close db faster (fixes #5781) (#5782)

This adds a 10s timeout on closing the db and additionally cancels active
db iterators and waits for them to terminate before closing the db.
This commit is contained in:
Simon Frei
2019-06-17 14:27:25 +02:00
committed by Jakob Borg
parent 0d86166890
commit bf744ded31
2 changed files with 99 additions and 5 deletions

View File

@@ -928,7 +928,17 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
code := exit.waitForExit()
mainService.Stop()
ldb.Close()
done := make(chan struct{})
go func() {
ldb.Close()
close(done)
}()
select {
case <-done:
case <-time.After(10 * time.Second):
l.Warnln("Database failed to stop within 10s")
}
l.Infoln("Exiting")