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:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user